Skip to content

Commit

Permalink
Merge pull request #27 from thomaswmorris/reorg
Browse files Browse the repository at this point in the history
Reorganized the code structure
  • Loading branch information
thomaswmorris authored Aug 27, 2023
2 parents 03663b6 + 1bcd684 commit 1ba2715
Show file tree
Hide file tree
Showing 56 changed files with 528 additions and 913 deletions.
2 changes: 1 addition & 1 deletion docs/source/tutorials/atmosphere.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"AtLAST = maria.get_array(\"MUSTANG-2\", \n",
" primary_size=200)\n",
"\n",
"daisy_scan = maria.get_pointing(\"DAISY-2deg\", \n",
"daisy_scan = maria.get_pointing(\"daisy\", \n",
" integration_time=60,\n",
" coord_center=[0,90],\n",
" coord_frame=\"az_el\")\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials/customizing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"AtLAST = maria.get_array(\"MUSTANG-2\", \n",
" primary_size=200)\n",
"\n",
"daisy_scan = maria.get_pointing(\"DAISY-2deg\", \n",
"daisy_scan = maria.get_pointing(\"daisy\", \n",
" integration_time=60,\n",
" coord_center=[0,90],\n",
" coord_frame=\"az_el\")\n",
Expand Down
24 changes: 4 additions & 20 deletions docs/source/tutorials/getting-started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "16efcfb6",
"metadata": {},
"outputs": [],
"source": [
"import maria\n",
"from maria import Simulation\n",
"\n",
"sim = Simulation(\n",
" array = 'MUSTANG-2', # Array type\n",
" pointing = 'DAISY-2deg', # Scanning strategy \n",
" pointing = 'daisy', # Scanning strategy \n",
" site = 'GBT', # Site\n",
" atm_model = 'linear_angular', # The atmospheric model, set to None if you want a noiseless observation.\n",
") \n"
Expand Down Expand Up @@ -66,7 +67,7 @@
"metadata": {},
"outputs": [],
"source": [
"daisy_scan = maria.get_pointing(\"DAISY-2deg\")\n",
"daisy_scan = maria.get_pointing(\"daisy\")\n",
"daisy_scan.description"
]
},
Expand All @@ -80,23 +81,6 @@
"daisy_scan.scan_radius"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "542b3f89",
"metadata": {},
"outputs": [],
"source": [
"plt.figure(figsize=(4,4))\n",
"\n",
"plt.plot(np.degrees(daisy_scan.ra), \n",
" np.degrees(daisy_scan.dec),\n",
" lw=5e-1)\n",
"\n",
"plt.xlabel(r'RA (degrees)')\n",
"plt.ylabel(r'Dec. (degrees)')"
]
},
{
"cell_type": "markdown",
"id": "352f68d6",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials/ingredients.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"metadata": {},
"outputs": [],
"source": [
"daisy_scan = maria.get_pointing(\"DAISY-2deg\")\n",
"daisy_scan = maria.get_pointing(\"daisy\")\n",
"daisy_scan.description"
]
},
Expand Down
6 changes: 3 additions & 3 deletions docs/source/tutorials/mock-observations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"metadata": {},
"source": [
"## Set up the Simulation\n",
"The \"Simulation\" class offers the flexibility to incorporate various inputs tailored to atmospheric simulations. For instance, it allows the creation of an observatory like 'AtLAST,' situated at the APEX site. Similarly, if the intention is to simulate Mustang-2 observations but, for instance, under less favorable weather conditions, adjusting the 'quantiles' parameter within the Simulation keywords can achieve this.\n",
"The \"Simulation\" class offers the flexibility to incorporate various inputs tailored to atmospheric simulations. For instance, it allows the creation of an observatory like 'AtLAST,' situated at the APEX site. Similarly, if the intention is to simulate Mustang-2 observations but, for instance, under less favorable weather conditions, adjusting the 'weather_quantiles' parameter within the Simulation keywords can achieve this.\n",
"\n",
"Furthermore, the Simulation class accommodates the exploration of how different scanning strategies affect the filtering of large scales. Standard strategies, such as the back-and-forth or Daisy scan patterns, have been implemented for this purpose. This feature enables the study of how the chosen scanning approach influences the overall large-scale filtering.\n",
"\n",
Expand All @@ -73,7 +73,7 @@
" # Mandatory minimal weither settings\n",
" # ---------------------\n",
" array = 'MUSTANG-2', # Array type\n",
" pointing = 'DAISY-2deg', # Scanning strategy \n",
" pointing = 'daisy', # Scanning strategy \n",
" site = 'GBT', # Site\n",
" atm_model = 'linear_angular', # The atmospheric model, set to None if you want a noiseless observation.\n",
" # atm_model = None, # The atmospheric model, set to None if you want a noiseless observation.\n",
Expand All @@ -93,7 +93,7 @@
"\n",
" # Additional inputs:\n",
" # ----------------------\n",
" quantiles = {'column_water_vapor' : 0.5}, # Weather conditions specific for that site\n",
" weather_quantiles = {'column_water_vapor' : 0.5}, # Weather conditions specific for that site\n",
" map_units = 'Jy/pixel', # Kelvin Rayleigh Jeans (K, defeault) or Jy/pixel \n",
" map_inbright = -2e-9, # Linearly scale the map to have this peak value.\n",
" map_res = 0.1 / 1000, # degree, overwrites header information\n",
Expand Down
28 changes: 2 additions & 26 deletions maria/__init__.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
# Ave, María, grátia plena, Dóminus tecum

from ._version import get_versions
__version__ = get_versions()["version"]

del get_versions

import os
import numpy as np
import scipy as sp

import astropy as ap

import pandas as pd
import h5py
import glob
import re
import json
import time
import copy

import weathergen
from tqdm import tqdm

import warnings
import healpy as hp

from matplotlib import pyplot as plt
from astropy.io import fits
from . import site

from .array import get_array, get_array_config
from .pointing import get_pointing, get_pointing_config
from .site import get_site, get_site_config

from .sim import Simulation

here, this_filename = os.path.split(__file__)
from .sim import Simulation
44 changes: 11 additions & 33 deletions maria/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@

import matplotlib.pyplot as plt

import glob
import os

from . import utils

from collections.abc import Mapping


here, this_filename = os.path.split(__file__)

# -- Specific packages --
ARRAY_CONFIGS = utils.read_yaml(f'{here}/configs/arrays.yml')

ARRAYS = list((ARRAY_CONFIGS.keys()))

ARRAY_CONFIGS = utils.io.read_yaml(f"{here}/configs/arrays.yml")
ARRAY_PARAMS = set()
for key, config in ARRAY_CONFIGS.items():
ARRAY_PARAMS |= set(config.keys())

class UnsupportedArrayError(Exception):
def __init__(self, invalid_array):
array_df = pd.DataFrame(columns=["description"])
for key, config in ARRAY_CONFIGS.items():
array_df.loc[key] = config["description"]
super().__init__(f"The array \'{invalid_array}\' is not in the database of default arrays. "
f"Default arrays are:\n\n{sorted(list(ARRAY_CONFIGS.keys()))}")

f"Default arrays are:\n\n{array_df.sort_index()}")

def get_array_config(array_name, **kwargs):
if not array_name in ARRAY_CONFIGS.keys():
Expand All @@ -33,35 +34,18 @@ def get_array_config(array_name, **kwargs):
ARRAY_CONFIG[k] = v
return ARRAY_CONFIG


def get_array(array_name, **kwargs):
return Array(**get_array_config(array_name, **kwargs))


def get_array_from_fits(array_name, **kwargs):
return Array(**get_array_config(array_name, **kwargs))


class Array:
def __init__(self, **kwargs):

DEFAULT_ARRAY_CONFIG = {
"detectors": [
[150e9, 10e9, 100],
],
"geometry": "hex",
"field_of_view": 1.3,
"primary_size": 50,
"band_grouping": "randomized",
"az_bounds": [0, 360],
"el_bounds": [20, 90],
"max_az_vel": 3,
"max_el_vel": 2,
"max_az_acc": 1,
"max_el_acc": 0.25
}
for k, v in kwargs.items():
setattr(self, k, v)
for key, default_value in ARRAY_CONFIGS["default"].items():
setattr(self, key, kwargs.get(key, default_value))

detectors = kwargs.get("detectors", "")

Expand Down Expand Up @@ -97,12 +81,6 @@ def __init__(self, **kwargs):
else:
raise ValueError("Supplied arg 'detectors' must be either a mapping or a dataframe!")

#self.band = np.array([f"f{int(nu/10**(3*int(np.log10(nu)/3))):03}" for nu in self.band_center])





# compute detector offset
self.hull = sp.spatial.ConvexHull(self.offset)

Expand Down
79 changes: 0 additions & 79 deletions maria/arrays/act.yml

This file was deleted.

19 changes: 0 additions & 19 deletions maria/arrays/atlast.yml

This file was deleted.

Loading

0 comments on commit 1ba2715

Please sign in to comment.