Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 12, 2023
1 parent 6a98fbb commit 4a28e01
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
24 changes: 16 additions & 8 deletions pyuvdata/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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],
Expand All @@ -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):
"""
Expand All @@ -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(
Expand Down
27 changes: 19 additions & 8 deletions pyuvdata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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),
):
"""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -4215,15 +4226,15 @@ 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,
time_array=time_array,
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
Expand Down
5 changes: 2 additions & 3 deletions pyuvdata/uvdata/uvdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down

0 comments on commit 4a28e01

Please sign in to comment.