Skip to content

Commit

Permalink
Merge pull request #36 from thomaswmorris/multi-layer
Browse files Browse the repository at this point in the history
Add back multi layer simulations
  • Loading branch information
thomaswmorris authored Nov 1, 2023
2 parents 0729a78 + 8727555 commit 6563a2f
Show file tree
Hide file tree
Showing 26 changed files with 911 additions and 702 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflows will upload a Python Package when a release is created.
# For more information see:
# - https://docs.pypi.org/trusted-publishers/adding-a-publisher/
# - https://github.com/pypa/gh-action-pypi-publish

name: PyPI upload

on:
release:
types: [created]

jobs:
publish_pypi:
name: Publish package to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Build package
run: |
set -vxeuo pipefail
python -m pip install --upgrade pip
pip install wheel setuptools
python setup.py sdist bdist_wheel
- name: Publish wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./dist/
40 changes: 24 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
MIT License
BSD 3-Clause License

Copyright (c) 2023 Thomas W. Morris
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
maria
=====

.. image:: ./docs/source/_static/cloud_64_b.gif
.. image:: ./docs/source/_static/cloud_128_a.gif
:width: 256px
:alt: StreamPlayer

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
maria
=====

.. image:: ./_static/cloud_64_b.gif
.. image:: ./_static/cloud_128_a.gif
:scale: 30%
:alt: StreamPlayer

Expand Down
134 changes: 67 additions & 67 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@ A database of supported arrays can be found at::

Supported arrays are customizeable by passing extra keywords to the ``get_array()`` function. We can double the size of the Green Bank Telescope and increase MUSTANG's field of view to one degree with::

mustang = maria.get_array("MUSTANG-2",
mustang = maria.get_array("MUSTANG-2",
field_of_view=10, # in degrees
primary_size=200 # in meters
)

The arrays

- **array** telescope and array design parameters
- Predefined configurations: `MUSTANG-2`, `ALMA`, `AtLAST`, `SCUBA-2`
- specific keys:
- dets (dict): {'float': [number of detectors (int), band_center in Hz (float), band_width in Hz (float)]}
- field_of_view (float): in degrees
- geometry (string): options are `hex` (defeault), `flower`, `square`
- primary_size (float): meters
- az_bounds (list): [lower (float), upper (float)] in degrees
- el_bounds (list): [lower (float), upper (float)] in degrees
- max_az_vel (float): ...
- max_el_vel (float): ...
- max_az_acc (float): ...
- max_el_acc (float): ...
- max_baseline (float): meters (only for ALMA)
- Predefined configurations: `MUSTANG-2`, `ALMA`, `AtLAST`, `SCUBA-2`
- specific keys:
- dets (dict): {'float': [number of detectors (int), band_center in Hz (float), band_width in Hz (float)]}
- field_of_view (float): in degrees
- geometry (string): options are `hex` (defeault), `flower`, `square`
- primary_size (float): meters
- az_bounds (list): [lower (float), upper (float)] in degrees
- el_bounds (list): [lower (float), upper (float)] in degrees
- max_az_vel (float): ...
- max_el_vel (float): ...
- max_az_acc (float): ...
- max_el_acc (float): ...
- max_baseline (float): meters (only for ALMA)


Pointings
Expand Down Expand Up @@ -102,69 +102,69 @@ Simulation parameters
^^^^^^^^^^^^^^^^^^^^^

- **array** telescope and array design parameters
- Predefined configurations: `MUSTANG-2`, `ALMA`, `AtLAST`, `SCUBA-2`
- specific keys:
- dets (Mappable of Mappables): {'float': [number of detectors (int), band_center in Hz (float), band_width in Hz (float)]}
- field_of_view (float): in degrees
- geometry (string): options are `hex` (defeault), `flower`, `square`
- primary_size (float): meters
- az_bounds (list): [lower (float), upper (float)] in degrees
- el_bounds (list): [lower (float), upper (float)] in degrees
- max_az_vel (float): ...
- max_el_vel (float): ...
- max_az_acc (float): ...
- max_el_acc (float): ...
- max_baseline (float): meters (only for ALMA)
- Predefined configurations: `MUSTANG-2`, `ALMA`, `AtLAST`, `SCUBA-2`
- specific keys:
- dets (Mappable of Mappables): {'float': [number of detectors (int), band_center in Hz (float), band_width in Hz (float)]}
- field_of_view (float): in degrees
- geometry (string): options are `hex` (defeault), `flower`, `square`
- primary_size (float): meters
- az_bounds (list): [lower (float), upper (float)] in degrees
- el_bounds (list): [lower (float), upper (float)] in degrees
- max_az_vel (float): ...
- max_el_vel (float): ...
- max_az_acc (float): ...
- max_el_acc (float): ...
- max_baseline (float): meters (only for ALMA)

- **pointing:** Scanning strategy
- Predefined configurations: `stare`, `daisy`, `BAF`,
- specific keys:
- start_time (string): reference point for generating weather, example: '2022-02-10T06:00:00'
- integration_time (float): in seconds
- scan_pattern (string): options are `daisy` or `back-and-forth`
- pointing_frame (string): options are `az_el` or `ra_dec`
- scan_center (list): [RA (float), Dec (float)] in degree
- scan_radius (float): in meters
- scan_period (float): in seconds
- scan_rate (float): in seconds
- Predefined configurations: `stare`, `daisy`, `BAF`,
- specific keys:
- start_time (string): reference point for generating weather, example: '2022-02-10T06:00:00'
- integration_time (float): in seconds
- scan_pattern (string): options are `daisy` or `back-and-forth`
- pointing_frame (string): options are `az_el` or `ra_dec`
- scan_center (list): [RA (float), Dec (float)] in degree
- scan_radius (float): in meters
- scan_period (float): in seconds
- scan_rate (float): in seconds

- **site:** Site locations
- Predefined configurations: `APEX`, `ACT`, `GBT`, `JCMT`, `SPT`, `SRT`
- specific keys:
- region (string): options are `chajnantor`, `green_bank`, `mauna_kea`, `south_pole`, `sardinia`
- latitude (float): in degree
- longtitude (float): in degree
- altitude (float): in meters
- seasonal (bool):
- diurnal (bool):
- weather_quantiles (dict): keys: `column_water_vapor` (float), ...
- pwv_rms (float): ...
- Predefined configurations: `APEX`, `ACT`, `GBT`, `JCMT`, `SPT`, `SRT`
- specific keys:
- region (string): options are `chajnantor`, `green_bank`, `mauna_kea`, `south_pole`, `sardinia`
- latitude (float): in degree
- longtitude (float): in degree
- altitude (float): in meters
- seasonal (bool):
- diurnal (bool):
- weather_quantiles (dict): keys: `column_water_vapor` (float), ...
- pwv_rms (float): ...

- **atm_model:** Different atmospheric models
- Predefined configurations: `single_layer`, None
- specific keys:
- min_depth (float): in meters
- max_depth (float): in meters
- n_layers (int): number of atmospheric layers
- min_beam_res (int):
- Predefined configurations: `single_layer`, None
- specific keys:
- min_depth (float): in meters
- max_depth (float): in meters
- n_layers (int): number of atmospheric layers
- min_beam_res (int):

- **mapper:** Different mappers
- Only one mapper is implemented, the `BinMapper`
- specific keys:
- map_height (float): radians
- map_width (float): radians
- map_res (float): radians
- map_filter (bool): Fourier filter the time streams before common-mode subtraction
- n_modes_to_remove (int): number of eigen modes to remove. Set to 0 for no common-mode subtraction.
- Only one mapper is implemented, the `BinMapper`
- specific keys:
- map_height (float): radians
- map_width (float): radians
- map_res (float): radians
- map_filter (bool): Fourier filter the time streams before common-mode subtraction
- n_modes_to_remove (int): number of eigen modes to remove. Set to 0 for no common-mode subtraction.

- **sky:** Input file
- specific keys:
- map_file (string): `path_to_fits_file.fits`
- map_frame (string): options are `az_el` or `ra_dec`
- map_center (list): [RA (float), Dec (float)] in degree
- map_res (float): in degrees
- map_inbright (float): scale the map so the brightest pixel value becomes this value
- map_units (string): options are `K_RJ` or `Jy/pixel`
- specific keys:
- map_file (string): `path_to_fits_file.fits`
- map_frame (string): options are `az_el` or `ra_dec`
- map_center (list): [RA (float), Dec (float)] in degree
- map_res (float): in degrees
- map_inbright (float): scale the map so the brightest pixel value becomes this value
- map_units (string): options are `K_RJ` or `Jy/pixel`



Expand Down
7 changes: 4 additions & 3 deletions maria/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
del get_versions

from . import array, pointing, site, utils, weather # noqa F401
from .array import get_array # noqa F401
from .pointing import get_pointing # noqa F401
from .array import all_arrays, get_array # noqa F401
from .pointing import all_pointings, get_pointing # noqa F401
from .sim import Simulation # noqa F401
from .site import get_site # noqa F401
from .site import all_sites, get_site # noqa F401
from .weather import all_regions # noqa F401
5 changes: 3 additions & 2 deletions maria/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
ARRAY_PARAMS |= set(config.keys())

DISPLAY_COLUMNS = ["description", "field_of_view", "primary_size"]
supported_arrays = pd.DataFrame(ARRAY_CONFIGS).T
supported_arrays_table = pd.DataFrame(ARRAY_CONFIGS).T
all_arrays = supported_arrays_table.index.values


class InvalidArrayError(Exception):
def __init__(self, invalid_array):
super().__init__(
f"The array '{invalid_array}' is not supported."
f"Supported arrays are:\n\n{supported_arrays.loc[:, DISPLAY_COLUMNS].to_string()}"
f"Supported arrays are:\n\n{supported_arrays_table.loc[:, DISPLAY_COLUMNS].to_string()}"
)


Expand Down
3 changes: 2 additions & 1 deletion maria/atmosphere/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from .linear_angular import LinearAngularSimulation # noqa F401
from .single_layer import SingleLayerSimulation # noqa F401

# how do we do the bands? this is a great question.
# because all practical telescope instrumentation assume a constant band

# from .kolmogorov_taylor import KolmogorovTaylorSimulation
# from .linear_angular import LinearAngularSimulation


ATMOSPHERE_PARAMS = {
"min_depth": 500,
Expand Down
23 changes: 23 additions & 0 deletions maria/atmosphere/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@
here, this_filename = os.path.split(__file__)


def extrude(
values: np.array,
A: np.array,
B: np.array,
n_steps: int,
n_i: int,
n_j: int,
i_sample_index: int,
j_sample_index: int,
):
# muy rapido
BUFFER = np.zeros((n_steps + n_i) * n_j)
BUFFER[n_steps * n_j :] = values

# remember that (e, c) -> n_c * e + c
for buffer_index in np.arange(n_steps)[::-1]:
BUFFER[buffer_index * n_j + np.arange(n_j)] = A @ BUFFER[
n_j * (buffer_index + 1 + i_sample_index) + j_sample_index
] + B @ np.random.standard_normal(size=n_j)

return BUFFER[: n_steps * n_j]


class AtmosphericSpectrum:
def __init__(self, filepath):
"""
Expand Down
Loading

0 comments on commit 6563a2f

Please sign in to comment.