diff --git a/pyuvdata/parameter.py b/pyuvdata/parameter.py index 5578653c75..ee8ff4673c 100644 --- a/pyuvdata/parameter.py +++ b/pyuvdata/parameter.py @@ -936,7 +936,10 @@ def lat_lon_alt(self): else: # check defaults to False b/c exposed check kwarg exists in UVData return utils.LatLonAlt_from_XYZ( - self.value, check_acceptability=False, frame=self.frame + self.value, + check_acceptability=False, + frame=self.frame, + lunar_ellipsoid=self.lunar_ellipsoid, ) def set_lat_lon_alt(self, lat_lon_alt): @@ -953,7 +956,11 @@ def set_lat_lon_alt(self, lat_lon_alt): self.value = None else: self.value = utils.XYZ_from_LatLonAlt( - lat_lon_alt[0], lat_lon_alt[1], lat_lon_alt[2], frame=self.frame + lat_lon_alt[0], + lat_lon_alt[1], + lat_lon_alt[2], + frame=self.frame, + lunar_ellipsoid=self.lunar_ellipsoid, ) def lat_lon_alt_degrees(self): @@ -984,6 +991,7 @@ def set_lat_lon_alt_degrees(self, lat_lon_alt_degree): longitude * np.pi / 180.0, altitude, frame=self.frame, + lunar_ellipsoid=self.lunar_ellipsoid, ) def check_acceptability(self): diff --git a/pyuvdata/tests/test_parameter.py b/pyuvdata/tests/test_parameter.py index 0a9fa01369..69b3c69624 100644 --- a/pyuvdata/tests/test_parameter.py +++ b/pyuvdata/tests/test_parameter.py @@ -9,6 +9,13 @@ from astropy.coordinates import CartesianRepresentation, Latitude, Longitude, SkyCoord from pyuvdata import parameter as uvp +from pyuvdata.tests.test_utils import ( + frame_selenoid, + ref_latlonalt, + ref_latlonalt_moon, + ref_xyz, + ref_xyz_moon, +) from pyuvdata.uvbase import UVBase @@ -397,6 +404,38 @@ def test_location_set_lat_lon_alt_degrees_none(): assert param1.value is None +@pytest.mark.parametrize(["frame", "selenoid"], frame_selenoid) +def test_location_xyz_latlonalt_match(frame, selenoid): + if frame == "itrs": + xyz_val = ref_xyz + latlonalt_val = ref_latlonalt + else: + xyz_val = ref_xyz_moon[selenoid] + latlonalt_val = ref_latlonalt_moon + + param1 = uvp.LocationParameter( + name="p1", value=xyz_val, frame=frame, lunar_ellipsoid=selenoid + ) + np.testing.assert_allclose(latlonalt_val, param1.lat_lon_alt()) + + param2 = uvp.LocationParameter(name="p2", frame=frame, lunar_ellipsoid=selenoid) + param2.set_lat_lon_alt(latlonalt_val) + + np.testing.assert_allclose(xyz_val, param2.value) + + param3 = uvp.LocationParameter(name="p2", frame=frame, lunar_ellipsoid=selenoid) + latlonalt_deg_val = np.array( + [ + latlonalt_val[0] * 180 / np.pi, + latlonalt_val[1] * 180 / np.pi, + latlonalt_val[2], + ] + ) + param3.set_lat_lon_alt_degrees(latlonalt_deg_val) + + np.testing.assert_allclose(xyz_val, param3.value) + + def test_location_acceptability(): """Test check_acceptability with LocationParameters""" val = np.array([0.5, 0.5, 0.5]) diff --git a/pyuvdata/uvdata/tests/test_uvfits.py b/pyuvdata/uvdata/tests/test_uvfits.py index 3151acbbc4..fe506e9761 100644 --- a/pyuvdata/uvdata/tests/test_uvfits.py +++ b/pyuvdata/uvdata/tests/test_uvfits.py @@ -16,6 +16,7 @@ import pyuvdata.utils as uvutils from pyuvdata import UVData from pyuvdata.data import DATA_PATH +from pyuvdata.tests.test_utils import frame_selenoid from pyuvdata.uvdata.uvdata import _future_array_shapes_warning casa_tutorial_uvfits = os.path.join( @@ -24,11 +25,6 @@ paper_uvfits = os.path.join(DATA_PATH, "zen.2456865.60537.xy.uvcRREAAM.uvfits") -selenoids = ["SPHERE", "GSFC", "GRAIL23", "CE-1-LAM-GEO"] -frame_selenoid = [["itrs", "SPHERE"]] -for snd in selenoids: - frame_selenoid.append(["mcmf", snd]) - def _fix_uvfits_multi_group_params(vis_hdu): par_names = vis_hdu.data.parnames diff --git a/pyuvdata/uvdata/tests/test_uvh5.py b/pyuvdata/uvdata/tests/test_uvh5.py index ec72cbcbc0..401dd1ac56 100644 --- a/pyuvdata/uvdata/tests/test_uvh5.py +++ b/pyuvdata/uvdata/tests/test_uvh5.py @@ -23,6 +23,7 @@ import pyuvdata.utils as uvutils from pyuvdata import UVData from pyuvdata.data import DATA_PATH +from pyuvdata.tests.test_utils import frame_selenoid from pyuvdata.uvdata.uvdata import _future_array_shapes_warning from .. import uvh5 @@ -33,11 +34,6 @@ pytest.mark.filterwarnings("ignore:Telescope EVLA is not"), ] -selenoids = ["SPHERE", "GSFC", "GRAIL23", "CE-1-LAM-GEO"] -frame_selenoid = [["itrs", "SPHERE"]] -for snd in selenoids: - frame_selenoid.append(["mcmf", snd]) - @pytest.fixture(scope="session") def uv_uvh5_main():