@@ -10747,6 +10747,37 @@ def test_fix_phase(hera_uvh5, tmp_path, use_ant_pos, phase_frame, file_type):
1074710747
1074810748 # Make some copies of the data
1074910749 uv_in = hera_uvh5
10750+ uv_in_bad = uv_in .copy ()
10751+
10752+ del uv_in_bad .phase_center_catalog [0 ]
10753+ uv_in_bad .phase_center_catalog [1 ] = {
10754+ "cat_dist" : None ,
10755+ "cat_epoch" : np .float64 (2000.0 ),
10756+ "cat_frame" : phase_frame ,
10757+ "cat_lat" : np .float64 (- 0.17855186342047605 ),
10758+ "cat_lon" : np .float64 (3.502185879515176 ),
10759+ "cat_name" : "foo" ,
10760+ "cat_pm_dec" : None ,
10761+ "cat_pm_ra" : None ,
10762+ "cat_times" : None ,
10763+ "cat_type" : "sidereal" ,
10764+ "cat_vrad" : None ,
10765+ "info_source" : "user" ,
10766+ }
10767+ uv_in_bad .phase_center_id_array [:] = 1
10768+ uv_in_bad ._set_app_coords_helper ()
10769+
10770+ if use_ant_pos :
10771+ uvw_path = f"oldproj_antpos_{ phase_frame } _uvw.npy"
10772+ else :
10773+ uvw_path = f"oldproj_{ phase_frame } _uvw.npy"
10774+
10775+ uv_in_bad .uvw_array = np .load (os .path .join (DATA_PATH , uvw_path ))
10776+ uv_in_bad ._apply_w_proj (
10777+ new_w_vals = uv_in_bad .uvw_array [:, - 1 ],
10778+ old_w_vals = 0.0 ,
10779+ select_mask = (uv_in_bad .ant_1_array != uv_in_bad .ant_2_array ),
10780+ )
1075010781
1075110782 # These values could be anything -- we're just picking something that we know should
1075210783 # be visible from the telescope at the time of obs (ignoring horizon limits).
@@ -10756,14 +10787,6 @@ def test_fix_phase(hera_uvh5, tmp_path, use_ant_pos, phase_frame, file_type):
1075610787 # Do the improved phasing on the data set.
1075710788 uv_in .phase (lon = phase_ra , lat = phase_dec , phase_frame = phase_frame , cat_name = "foo" )
1075810789
10759- if use_ant_pos :
10760- antpos_str = "_antpos"
10761- else :
10762- antpos_str = ""
10763- bad_data_path = os .path .join (
10764- DATA_PATH , f"zen.2458661.23480.HH_oldproj{ antpos_str } _{ phase_frame } .uvh5"
10765- )
10766-
1076710790 if use_ant_pos :
1076810791 warn_msg = ["Fixing phases using antenna positions." ]
1076910792 else :
@@ -10772,22 +10795,20 @@ def test_fix_phase(hera_uvh5, tmp_path, use_ant_pos, phase_frame, file_type):
1077210795 read_warn_msg = copy .deepcopy (warn_msg )
1077310796 read_warn_type = [UserWarning ]
1077410797
10775- uv_in_bad = UVData .from_file (bad_data_path , fix_old_proj = False )
1077610798 uv_in_bad_copy = uv_in_bad .copy ()
1077710799 if file_type == "uvh5" :
10778- outfile = bad_data_path
10779- else :
10780- if file_type == "uvfits" :
10781- outfile = os .path .join (tmp_path , "test_bad_phase.uvfits" )
10782- uv_in_bad_copy .write_uvfits (outfile )
10783- elif file_type == "miriad" :
10784- outfile = os .path .join (tmp_path , "test_bad_phase.uv" )
10785- with check_warnings (
10786- UserWarning ,
10787- "writing default values for restfreq, vsource, veldop, jyperk, and"
10788- " systemp" ,
10789- ):
10790- uv_in_bad_copy .write_miriad (outfile , clobber = True )
10800+ outfile = os .path .join (tmp_path , "test_bad_phase.uvh5" )
10801+ uv_in_bad_copy .write_uvh5 (outfile )
10802+ elif file_type == "uvfits" :
10803+ outfile = os .path .join (tmp_path , "test_bad_phase.uvfits" )
10804+ uv_in_bad_copy .write_uvfits (outfile )
10805+ elif file_type == "miriad" :
10806+ outfile = os .path .join (tmp_path , "test_bad_phase.uv" )
10807+ with check_warnings (
10808+ UserWarning ,
10809+ "writing default values for restfreq, vsource, veldop, jyperk, and systemp" ,
10810+ ):
10811+ uv_in_bad_copy .write_miriad (outfile , clobber = True )
1079110812
1079210813 with check_warnings (read_warn_type , match = read_warn_msg ), warnings .catch_warnings ():
1079310814 warnings .filterwarnings ("ignore" , "Fixing auto-correlations to be be real-only" )
0 commit comments