Skip to content

Commit

Permalink
I was told test coverage is a good thing.
Browse files Browse the repository at this point in the history
  • Loading branch information
kartographer committed Sep 21, 2023
1 parent 5af9238 commit 515fe96
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
32 changes: 32 additions & 0 deletions pyuvdata/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4131,3 +4131,35 @@ def test_calc_app_coords_time_obj():

assert np.allclose(app_ra_to, app_ra_nto)
assert np.allclose(app_dec_to, app_dec_nto)


@pytest.mark.parametrize("flip_u", [False, True])
def test_uvw_track_generator(flip_u):
sma_mir = UVData.from_file(os.path.join(DATA_PATH, "sma_test.mir"))
sma_mir.set_lsts_from_time_array()
sma_mir._set_app_coords_helper()
sma_mir.set_uvws_from_antenna_positions()

cat_dict = sma_mir.phase_center_catalog[1]
gen_results = uvutils.uvw_track_generator(
lon_coord=cat_dict["cat_lon"],
lat_coord=cat_dict["cat_lat"],
coord_frame=cat_dict["cat_frame"],
coord_epoch=cat_dict["cat_epoch"],
telescope_loc=sma_mir.telescope_location_lat_lon_alt_degrees,
time_array=sma_mir.time_array,
antenna_positions=sma_mir.antenna_positions,
ant_1_array=sma_mir.ant_1_array,
ant_2_array=sma_mir.ant_2_array,
antenna_numbers=sma_mir.antenna_numbers,
force_postive_u=flip_u,
)

assert sma_mir._phase_center_app_ra.compare_value(gen_results["app_ra"])
assert sma_mir._phase_center_app_dec.compare_value(gen_results["app_dec"])
assert sma_mir._phase_center_frame_pa.compare_value(gen_results["frame_pa"])
assert sma_mir._lst_array.compare_value(gen_results["lst"])
if flip_u:
assert sma_mir._uvw_array.compare_value(-gen_results["uvw"])
else:
assert sma_mir._uvw_array.compare_value(gen_results["uvw"])
4 changes: 2 additions & 2 deletions pyuvdata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4058,7 +4058,7 @@ def uvw_track_generator(
ITRF latitude, longitude, and altitude (rel to sea-level) of the phase center
of the array. Can either be provided as an astropy EarthLocation, a lunarsky
Moonlocation, or a tuple of shape (3,) containing (in order) the latitude,
longitude, and altitude for a position on Earth in units of radians, radians,
longitude, and altitude for a position on Earth in units of degrees, degrees,
and meters, respectively.
antenna_frame : str, optional
Reference frame for latitude/longitude/altitude. Options are itrs (default) or
Expand Down Expand Up @@ -4159,7 +4159,7 @@ def uvw_track_generator(
app_ra, app_dec = calc_app_coords(
lon_coord=lon_coord,
lat_coord=lat_coord,
coord_frame="icrs",
coord_frame=coord_frame,
coord_type=coord_type,
time_array=time_array,
lst_array=lst_array,
Expand Down

0 comments on commit 515fe96

Please sign in to comment.