Skip to content

Commit

Permalink
feat: include access to ska array postions via ska-ost-array-config p…
Browse files Browse the repository at this point in the history
…ackage
  • Loading branch information
DanielaBreitman committed Dec 13, 2024
2 parents e87894d + c9de480 commit f65001c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/py21cmsense/observatory.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ def from_profile(cls, profile: str, frequency: tp.Frequency | None = None, **kwa
return obj.clone(**kwargs)

@classmethod
def from_ska(cls, subarray_type: str, array_type = 'low', frequency: tp.Frequency | None = None, **kwargs) -> Observatory:
def from_ska(
cls, subarray_type: str, array_type="low", frequency: tp.Frequency | None = None, **kwargs
) -> Observatory:
"""Instantiate an SKA Observatory.
Parameters
Expand All @@ -242,19 +244,22 @@ def from_ska(cls, subarray_type: str, array_type = 'low', frequency: tp.Frequen
try:
from ska_ost_array_config.array_config import LowSubArray, MidSubArray
except ImportError:
raise ImportError("ska-ost-array-config package is required," +
"see https://gitlab.com/ska-telescope/ost/ska-ost-array-config")
if array_type == 'low':
raise ImportError(
"ska-ost-array-config package is required, "+
"see https://gitlab.com/ska-telescope/ost/ska-ost-array-config"
)
if array_type == "low":
subarray = LowSubArray(subarray_type, **kwargs)
elif array_type == 'mid':
elif array_type == "mid":
subarray = MidSubArray(subarray_type, **kwargs)
else:
raise ValueError("array_type must be 'low' or 'mid'.")
antpos = subarray.array_config.xyz.data * un.m
_beam = beam.GaussianBeam(frequency=frequency if frequency is not None else 150.*un.MHz,
dish_size = 35.*un.m)
lat = subarray.array_config.location.lat.rad *un.rad
return cls(antpos=antpos, beam=_beam, latitude = lat, Trcv = 100. * un.K)
_beam = beam.GaussianBeam(
frequency=frequency if frequency is not None else 150.0 * un.MHz, dish_size=35.0 * un.m
)
lat = subarray.array_config.location.lat.rad * un.rad
return cls(antpos=antpos, beam=_beam, latitude=lat, Trcv=100.0 * un.K)

@cached_property
def baselines_metres(self) -> tp.Meters:
Expand Down
1 change: 1 addition & 0 deletions tests/test_observatory.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def test_from_yaml(bm):
with pytest.raises(ValueError, match="yaml_file must be a string filepath"):
Observatory.from_yaml(3)


def test_from_ska():
Observatory.from_ska(subarray_type="AA*", array_type="low", frequency=300.*units.MHz)
Observatory.from_ska(subarray_type="AA*", array_type="mid", frequency=300.*units.MHz)
Expand Down

0 comments on commit f65001c

Please sign in to comment.