From 515fe9628a9c20c9a98c24cd5344016e548d2ee2 Mon Sep 17 00:00:00 2001 From: Garrett 'Karto' Keating Date: Thu, 21 Sep 2023 13:52:21 -0400 Subject: [PATCH] I was told test coverage is a good thing. --- pyuvdata/tests/test_utils.py | 32 ++++++++++++++++++++++++++++++++ pyuvdata/utils.py | 4 ++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/pyuvdata/tests/test_utils.py b/pyuvdata/tests/test_utils.py index 428af4efda..d6ccbba029 100644 --- a/pyuvdata/tests/test_utils.py +++ b/pyuvdata/tests/test_utils.py @@ -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"]) diff --git a/pyuvdata/utils.py b/pyuvdata/utils.py index 62f6f06daf..4506149017 100644 --- a/pyuvdata/utils.py +++ b/pyuvdata/utils.py @@ -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 @@ -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,