diff --git a/pyuvdata/tests/test_utils.py b/pyuvdata/tests/test_utils.py index af37d9057e..b7848ca2a6 100644 --- a/pyuvdata/tests/test_utils.py +++ b/pyuvdata/tests/test_utils.py @@ -67,7 +67,9 @@ def astrometry_args(): ) if hasmoon: - default_args["moon_telescope_loc"] = tuple(np.deg2rad(x) for x in (0.6875, 24.433, 0)) + default_args["moon_telescope_loc"] = tuple( + np.deg2rad(x) for x in (0.6875, 24.433, 0) + ) default_args["moon_lst_array"] = uvutils.get_lst_for_time( default_args["time_array"], default_args["moon_telescope_loc"][0] * (180.0 / np.pi), @@ -116,7 +118,7 @@ def astrometry_args(): default_args["icrs_ra"], default_args["icrs_dec"], default_args["moon_telescope_loc"], - antenna_frame='mcmf' + antenna_frame="mcmf", ) default_args["moon_app_coord"] = SkyCoord( @@ -272,11 +274,15 @@ def test_no_moon(): with pytest.raises(ValueError, match=msg): uvutils.ECEF_from_ENU(None, 0.0, 1.0, 10.0, frame="mcmf") with pytest.raises(ValueError, match=msg): - uvutils.transform_icrs_to_app([2451545.0],0,0,(0,0,0),antenna_frame="mcmf") + uvutils.transform_icrs_to_app( + [2451545.0], 0, 0, (0, 0, 0), antenna_frame="mcmf" + ) with pytest.raises(ValueError, match=msg): - uvutils.transform_app_to_icrs([2451545.0],0,0,(0,0,0),antenna_frame="mcmf") + uvutils.transform_app_to_icrs( + [2451545.0], 0, 0, (0, 0, 0), antenna_frame="mcmf" + ) with pytest.raises(ValueError, match=msg): - uvutils.calc_app_coords(0,0,antenna_frame="mcmf") + uvutils.calc_app_coords(0, 0, antenna_frame="mcmf") def test_lla_xyz_lla_roundtrip(): @@ -1403,7 +1409,8 @@ def test_transform_fk5_fk4_icrs_loop(astrometry_args): check_ra, check_dec = uvutils.transform_sidereal_coords( fk4_ra, - fk4_dec, "fk4", + fk4_dec, + "fk4", "icrs", in_coord_epoch="B1950.0", out_coord_epoch="J2000.0", @@ -2020,6 +2027,7 @@ def test_transform_icrs_to_app_time_obj(astrometry_args, telescope_frame): assert np.all(check_ra == astrometry_args[app_ra_name]) assert np.all(check_dec == astrometry_args[app_dec_name]) + def test_transform_app_to_icrs_objs(astrometry_args): """ Test that we recover identical values when using Time/EarthLocation objects instead @@ -2030,7 +2038,6 @@ def test_transform_app_to_icrs_objs(astrometry_args): astrometry_args["telescope_loc"][0] * (180.0 / np.pi), height=astrometry_args["telescope_loc"][2], ) - icrs_ra, icrs_dec = uvutils.transform_app_to_icrs( astrometry_args["time_array"][0], @@ -2049,6 +2056,7 @@ def test_transform_app_to_icrs_objs(astrometry_args): assert np.all(check_ra == icrs_ra) assert np.all(check_dec == icrs_dec) + @pytest.mark.parametrize("telescope_frame", telescope_frame) def test_calc_app_coords_objs(astrometry_args, telescope_frame): """ @@ -2075,7 +2083,7 @@ def test_calc_app_coords_objs(astrometry_args, telescope_frame): astrometry_args["icrs_dec"], time_array=astrometry_args["time_array"][0], telescope_loc=astrometry_args["telescope_loc"], - antenna_frame=telescope_frame + antenna_frame=telescope_frame, ) check_ra, check_dec = uvutils.calc_app_coords( diff --git a/pyuvdata/utils.py b/pyuvdata/utils.py index a94628d240..9c3cb55008 100644 --- a/pyuvdata/utils.py +++ b/pyuvdata/utils.py @@ -2440,7 +2440,7 @@ def transform_icrs_to_app( ra, dec, telescope_loc, - antenna_frame='itrs', + antenna_frame="itrs", epoch=2000.0, pm_ra=None, pm_dec=None, @@ -2580,7 +2580,7 @@ def transform_icrs_to_app( site_loc = MoonLocation.from_selenodetic( telescope_loc[1] * (180.0 / np.pi), telescope_loc[0] * (180.0 / np.pi), - height = telescope_loc[2], + height=telescope_loc[2], ) else: site_loc = EarthLocation.from_geodetic( @@ -2876,7 +2876,12 @@ def transform_icrs_to_app( def transform_app_to_icrs( - time_array, app_ra, app_dec, telescope_loc, antenna_frame='itrs', astrometry_library=None + time_array, + app_ra, + app_dec, + telescope_loc, + antenna_frame="itrs", + astrometry_library=None, ): """ Transform a set of coordinates in topocentric/apparent to ICRS coordinates. @@ -2963,7 +2968,7 @@ def transform_app_to_icrs( site_loc = MoonLocation.from_selenodetic( telescope_loc[1] * (180.0 / np.pi), telescope_loc[0] * (180.0 / np.pi), - height = telescope_loc[2], + height=telescope_loc[2], ) else: site_loc = EarthLocation.from_geodetic( @@ -3098,7 +3103,7 @@ def calc_frame_pos_angle( telescope_loc, ref_frame, ref_epoch=None, - antenna_frame='itrs', + antenna_frame="itrs", offset_pos=(np.pi / 360.0), ): """ @@ -3751,7 +3756,13 @@ def calc_app_coords( def calc_sidereal_coords( - time_array, app_ra, app_dec, telescope_loc, coord_frame, antenna_frame='itrs', coord_epoch=None + time_array, + app_ra, + app_dec, + telescope_loc, + coord_frame, + antenna_frame="itrs", + coord_epoch=None, ): """ Calculate sidereal coordinates given apparent coordinates. @@ -4215,7 +4226,8 @@ def uvw_track_generator( lst_array = get_lst_for_time( jd_array=time_array, telescope_loc=site_loc, frame=antenna_frame ) - app_ra, app_dec = calc_app_coords(lon_coord=lon_coord, + app_ra, app_dec = calc_app_coords( + lon_coord=lon_coord, lat_coord=lat_coord, coord_frame=coord_frame, coord_type=coord_type, @@ -4223,7 +4235,6 @@ def uvw_track_generator( lst_array=lst_array, telescope_loc=site_loc, ) - frame_pa = calc_frame_pos_angle( time_array, app_ra, app_dec, site_loc, coord_frame, ref_epoch=coord_epoch diff --git a/pyuvdata/uvdata/uvdata.py b/pyuvdata/uvdata/uvdata.py index c66439f575..578568185e 100644 --- a/pyuvdata/uvdata/uvdata.py +++ b/pyuvdata/uvdata/uvdata.py @@ -5868,10 +5868,9 @@ def phase( vrad=phase_dict["cat_vrad"], dist=phase_dict["cat_dist"], telescope_loc=self.telescope_location_lat_lon_alt, - antenna_frame=self._telescope_location.frame + antenna_frame=self._telescope_location.frame, ) - # Now calculate position angles. if not phase_frame == "altaz": new_frame_pa = uvutils.calc_frame_pos_angle( @@ -5881,7 +5880,7 @@ def phase( self.telescope_location_lat_lon_alt, phase_frame, ref_epoch=epoch, - antenna_frame=self._telescope_location.frame + antenna_frame=self._telescope_location.frame, ) else: new_frame_pa = np.zeros(time_array.shape, dtype=float)