From 8f706ddc6b882d886579e1ea9fed8cd952406d4c Mon Sep 17 00:00:00 2001 From: Willow Smith Date: Fri, 13 Dec 2024 12:43:57 -0500 Subject: [PATCH] lunar array support Also includes "ultra_optimistic" no foregrounds model and z=30 theory model. Need to make more user friendly --- src/py21cmsense/observatory.py | 3 ++- src/py21cmsense/sensitivity.py | 2 +- tests/test_uvw.py | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/py21cmsense/observatory.py b/src/py21cmsense/observatory.py index 9bce0ca..177336f 100644 --- a/src/py21cmsense/observatory.py +++ b/src/py21cmsense/observatory.py @@ -86,7 +86,8 @@ class Observatory: default=0.0 * un.m, validator=(tp.vld_physical_type("length"), ut.nonnegative) ) beam_crossing_time_incl_latitude: bool = attr.ib(default=True, converter=bool) - world: str = attr.ib(default = 'earth') #add validator stuff later + world: str = attr.ib(default = "earth", validator=vld.in_(["earth", "moon"]) + ) @_antpos.validator def _antpos_validator(self, att, val): diff --git a/src/py21cmsense/sensitivity.py b/src/py21cmsense/sensitivity.py index 121a867..ff947d4 100644 --- a/src/py21cmsense/sensitivity.py +++ b/src/py21cmsense/sensitivity.py @@ -472,7 +472,7 @@ def horizon_limit(self, umag: float) -> tp.Wavenumber: elif self.foreground_model in ["optimistic"]: return horizon * np.sin(self.observation.observatory.beam.first_null / 2) elif self.foreground_model in ["ultra_optimistic"]: - return horizon + return 0 def _average_sense_to_1d( self, sense: dict[tp.Wavenumber, tp.Delta], k1d: tp.Wavenumber | None = None diff --git a/tests/test_uvw.py b/tests/test_uvw.py index 7f281b7..b166627 100644 --- a/tests/test_uvw.py +++ b/tests/test_uvw.py @@ -24,6 +24,7 @@ def test_phase_at_zenith(lat, use_apparent): time_past_zenith=0.0 * un.day, bls_enu=bls_enu, latitude=lat * un.rad, + world = 'earth', use_apparent=use_apparent, ) @@ -45,6 +46,7 @@ def test_phase_past_zenith(use_apparent): time_past_zenith=0.2 * un.day, bls_enu=bls_enu, latitude=0 * un.rad, + world = 'earth', use_apparent=use_apparent, ) ) @@ -67,7 +69,7 @@ def test_phase_past_zenith_shape(): times = np.array([0, 0.1, 0, 0.1]) * un.day # Almost rotated to the horizon. - uvws = phase_past_zenith(time_past_zenith=times, bls_enu=bls_enu, latitude=0 * un.rad) + uvws = phase_past_zenith(time_past_zenith=times, bls_enu=bls_enu, latitude=0 * un.rad, world='earth') assert uvws.shape == (5, 4, 3) assert np.allclose(uvws[0], uvws[2]) # Same baselines @@ -87,11 +89,12 @@ def test_use_apparent(lat): times = np.linspace(-1, 1, 3) * un.hour # Almost rotated to the horizon. - uvws = phase_past_zenith(time_past_zenith=times, bls_enu=bls_enu, latitude=lat * un.rad) + uvws = phase_past_zenith(time_past_zenith=times, bls_enu=bls_enu, latitude=lat * un.rad, world='earth') uvws0 = phase_past_zenith( time_past_zenith=times, bls_enu=bls_enu, latitude=lat * un.rad, + world = 'earth', use_apparent=True, )