diff --git a/docs/uvcal_tutorial.rst b/docs/uvcal_tutorial.rst index af0b2751b..2a95e3edd 100644 --- a/docs/uvcal_tutorial.rst +++ b/docs/uvcal_tutorial.rst @@ -587,7 +587,7 @@ specified by passing an index array. True >>> # Prepend a ``-`` to the sort string to sort in descending order. - >>> cal.reorder_antennas(order='-number') + >>> cal.reorder_antennas('-number') >>> print(np.min(np.diff(cal.ant_array)) <= 0) True @@ -671,7 +671,7 @@ array for the time axis. True >>> # Prepend a ``-`` to the sort string to sort in descending order. - >>> cal.reorder_times(order='-time') + >>> cal.reorder_times('-time') >>> print(np.min(np.diff(cal.time_array)) <= 0) True diff --git a/docs/uvdata_tutorial.rst b/docs/uvdata_tutorial.rst index bfd846bf6..7c634cf4d 100644 --- a/docs/uvdata_tutorial.rst +++ b/docs/uvdata_tutorial.rst @@ -1600,17 +1600,17 @@ an option to sort the auto visibilities before the cross visibilities (``autos_f >>> # Explicity sorting by 'time' then 'baseline' gets the same result >>> uvd2 = uvd.copy() - >>> uvd2.reorder_blts(order='time', minor_order='baseline') + >>> uvd2.reorder_blts('time', minor_order='baseline') >>> print(uvd == uvd2) True - >>> uvd.reorder_blts(order='ant1', minor_order='ant2') + >>> uvd.reorder_blts('ant1', minor_order='ant2') >>> print(np.min(np.diff(uvd.ant_1_array)) >= 0) True >>> # You can also sort and conjugate in a single step for the purposes of comparing two objects - >>> uvd.reorder_blts(order='bda', conj_convention='ant1>> uvd2.reorder_blts(order='bda', conj_convention='ant1>> uvd.reorder_blts('bda', conj_convention='ant1>> uvd2.reorder_blts('bda', conj_convention='ant1>> print(uvd == uvd2) True @@ -1680,7 +1680,7 @@ ordering set by the user. >>> print(uvutils.polnum2str(uvd.polarization_array)) ['rr', 'll', 'rl', 'lr'] - >>> uvd.reorder_pols(order='CASA') + >>> uvd.reorder_pols('CASA') >>> print(uvutils.polnum2str(uvd.polarization_array)) ['rr', 'rl', 'lr', 'll'] diff --git a/pyuvdata/uvcal/tests/test_uvcal.py b/pyuvdata/uvcal/tests/test_uvcal.py index 678a1244e..1444a1836 100644 --- a/pyuvdata/uvcal/tests/test_uvcal.py +++ b/pyuvdata/uvcal/tests/test_uvcal.py @@ -1891,12 +1891,12 @@ def test_reorder_ants( ant_num_diff = np.diff(calobj2.ant_array) assert np.all(ant_num_diff > 0) - calobj2.reorder_antennas(order="-number") + calobj2.reorder_antennas("-number") ant_num_diff = np.diff(calobj2.ant_array) assert np.all(ant_num_diff < 0) sorted_names = np.sort(calobj.antenna_names) - calobj.reorder_antennas(order="name") + calobj.reorder_antennas("name") temp = np.asarray(calobj.antenna_names) dtype_use = temp.dtype name_array = np.zeros_like(calobj.ant_array, dtype=dtype_use) @@ -1908,10 +1908,10 @@ def test_reorder_ants( assert np.all(sorted_names == name_array) # test sorting with an integer array. First resort back to by number - calobj2.reorder_antennas(order="number") + calobj2.reorder_antennas("number") sorted_nums = [int(name[3:]) for name in sorted_names] index_array = [np.nonzero(calobj2.ant_array == ant)[0][0] for ant in sorted_nums] - calobj2.reorder_antennas(order=index_array) + calobj2.reorder_antennas(index_array) assert calobj2 == calobj @@ -1921,21 +1921,21 @@ def test_reorder_ants_errors(gain_data): match="order must be one of 'number', 'name', '-number', '-name' or an " "index array of length Nants_data", ): - gain_data.reorder_antennas(order="foo") + gain_data.reorder_antennas("foo") with pytest.raises( ValueError, match="If order is an index array, it must contain all indicies for the" "ant_array, without duplicates.", ): - gain_data.reorder_antennas(order=gain_data.antenna_numbers.astype(float)) + gain_data.reorder_antennas(gain_data.antenna_numbers.astype(float)) with pytest.raises( ValueError, match="If order is an index array, it must contain all indicies for the" "ant_array, without duplicates.", ): - gain_data.reorder_antennas(order=gain_data.antenna_numbers[:8]) + gain_data.reorder_antennas(gain_data.antenna_numbers[:8]) @pytest.mark.filterwarnings("ignore:The input_flag_array is deprecated") @@ -2118,7 +2118,7 @@ def test_reorder_times( calobj.reorder_times() assert calobj == calobj2 - calobj2.reorder_times(order="-time") + calobj2.reorder_times("-time") if time_range: time_diff = np.diff(calobj2.time_range[:, 0]) else: @@ -2133,7 +2133,7 @@ def test_reorder_times( total_quality_diff = np.diff(calobj2.total_quality_array, axis=2) assert np.all(total_quality_diff < 0) - calobj.reorder_times(order=np.flip(np.arange(calobj.Ntimes))) + calobj.reorder_times(np.flip(np.arange(calobj.Ntimes))) assert calobj == calobj2 @@ -2142,21 +2142,21 @@ def test_reorder_times_errors(gain_data): ValueError, match="order must be one of 'time', '-time' or an index array of length Ntimes", ): - gain_data.reorder_times(order="foo") + gain_data.reorder_times("foo") with pytest.raises( ValueError, match="If order is an array, it must contain all indicies for the time axis, " "without duplicates.", ): - gain_data.reorder_times(order=np.arange(gain_data.Ntimes) * 2) + gain_data.reorder_times(np.arange(gain_data.Ntimes) * 2) with pytest.raises( ValueError, match="If order is an array, it must contain all indicies for the time axis, " "without duplicates.", ): - gain_data.reorder_times(order=np.arange(7)) + gain_data.reorder_times(np.arange(7)) gain_data = time_array_to_time_range(gain_data, keep_time_array=True) with uvtest.check_warnings( @@ -2206,11 +2206,11 @@ def test_reorder_jones( calobj = calobj2.copy() # this is a no-op because it's already sorted this way - calobj2.reorder_jones(order="-number") + calobj2.reorder_jones("-number") jnum_diff = np.diff(calobj2.jones_array) assert np.all(jnum_diff < 0) - calobj2.reorder_jones(order="number") + calobj2.reorder_jones("number") jnum_diff = np.diff(calobj2.jones_array) assert np.all(jnum_diff > 0) @@ -2234,7 +2234,7 @@ def test_reorder_jones( # test sorting with an index array. Sort back to number first so indexing works sorted_nums = uvutils.jstr2num(sorted_names, x_orientation=calobj.x_orientation) index_array = [np.nonzero(calobj.jones_array == num)[0][0] for num in sorted_nums] - calobj.reorder_jones(order=index_array) + calobj.reorder_jones(index_array) assert calobj2 == calobj @@ -2248,21 +2248,21 @@ def test_reorder_jones_errors(gain_data): match="order must be one of 'number', 'name', '-number', '-name' or an " "index array of length Njones", ): - calobj.reorder_jones(order="foo") + calobj.reorder_jones("foo") with pytest.raises( ValueError, match="If order is an array, it must contain all indicies for " "the jones axis, without duplicates.", ): - calobj.reorder_jones(order=np.arange(gain_data.Njones) * 2) + calobj.reorder_jones(np.arange(gain_data.Njones) * 2) with pytest.raises( ValueError, match="If order is an array, it must contain all indicies for " "the jones axis, without duplicates.", ): - calobj.reorder_jones(order=np.arange(2)) + calobj.reorder_jones(np.arange(2)) @pytest.mark.filterwarnings("ignore:The input_flag_array is deprecated") @@ -2325,14 +2325,14 @@ def test_add_different_sorting( cal2 = calobj.select(jones=np.array([-6, -8]), inplace=False) if sort_type == "ant": - cal1.reorder_antennas(order="number") - cal2.reorder_antennas(order="-number") - calobj.reorder_antennas(order="name") + cal1.reorder_antennas("number") + cal2.reorder_antennas("-number") + calobj.reorder_antennas("name") order_check = cal1._ant_array == cal2._ant_array elif sort_type == "time": - cal1.reorder_times(order="time") - cal2.reorder_times(order="-time") - calobj.reorder_times(order="time") + cal1.reorder_times("time") + cal2.reorder_times("-time") + calobj.reorder_times("time") order_check = cal1._time_array == cal2._time_array elif sort_type == "freq": if wide_band: @@ -2346,9 +2346,9 @@ def test_add_different_sorting( calobj.reorder_freqs(channel_order="freq") order_check = cal1._freq_array == cal2._freq_array elif sort_type == "jones": - cal1.reorder_jones(order="name") - cal2.reorder_jones(order="-number") - calobj.reorder_jones(order="number") + cal1.reorder_jones("name") + cal2.reorder_jones("-number") + calobj.reorder_jones("number") order_check = cal1._jones_array == cal2._jones_array # Make sure that the order has actually been scrambled @@ -2359,11 +2359,11 @@ def test_add_different_sorting( cal4 = cal2 + cal1 if sort_type == "ant": - cal3.reorder_antennas(order="name") - cal4.reorder_antennas(order="name") + cal3.reorder_antennas("name") + cal4.reorder_antennas("name") elif sort_type == "time": - cal3.reorder_times(order="time") - cal4.reorder_times(order="time") + cal3.reorder_times("time") + cal4.reorder_times("time") elif sort_type == "freq": if wide_band: cal3.reorder_freqs() @@ -2372,8 +2372,8 @@ def test_add_different_sorting( cal3.reorder_freqs(channel_order="freq") cal4.reorder_freqs(channel_order="freq") elif sort_type == "jones": - cal3.reorder_jones(order="number") - cal4.reorder_jones(order="number") + cal3.reorder_jones("number") + cal4.reorder_jones("number") # Deal with the history separately, since it will be different assert str.startswith(cal3.history, calobj.history) diff --git a/pyuvdata/uvcal/uvcal.py b/pyuvdata/uvcal/uvcal.py index 34743e98d..a5d47f3b6 100644 --- a/pyuvdata/uvcal/uvcal.py +++ b/pyuvdata/uvcal/uvcal.py @@ -1738,8 +1738,8 @@ def get_time_array(self): def reorder_antennas( self, - *, order="number", + *, run_check=True, check_extra=True, run_check_acceptability=True, @@ -1983,8 +1983,8 @@ def reorder_freqs( def reorder_times( self, - *, order="time", + *, run_check=True, check_extra=True, run_check_acceptability=True, @@ -2086,8 +2086,8 @@ def reorder_times( def reorder_jones( self, - *, order="name", + *, run_check=True, check_extra=True, run_check_acceptability=True, @@ -2630,7 +2630,7 @@ def __add__( this_ants_ind[other_argsort] ] - this.reorder_antennas(order=temp_ind) + this.reorder_antennas(temp_ind) if len(this_times_ind) != 0: this_argsort = np.argsort(this_times_ind) @@ -2642,7 +2642,7 @@ def __add__( this_times_ind[other_argsort] ] - this.reorder_times(order=temp_ind) + this.reorder_times(temp_ind) if len(this_freq_ind) != 0: this_argsort = np.argsort(this_freq_ind) @@ -2672,7 +2672,7 @@ def __add__( this_jones_ind[other_argsort] ] - this.reorder_jones(order=temp_ind) + this.reorder_jones(temp_ind) # Update filename parameter this.filename = uvutils._combine_filenames(this.filename, other.filename) diff --git a/pyuvdata/uvdata/miriad.py b/pyuvdata/uvdata/miriad.py index 455a7c590..4480290aa 100644 --- a/pyuvdata/uvdata/miriad.py +++ b/pyuvdata/uvdata/miriad.py @@ -1586,7 +1586,7 @@ def read_miriad( else: order = self.blt_order[0] minor_order = None - self.reorder_blts(order=order, minor_order=minor_order) + self.reorder_blts(order, minor_order=minor_order) # If the data set was recorded using the old phasing method, fix that now. if fix_old_proj and projected: diff --git a/pyuvdata/uvdata/ms.py b/pyuvdata/uvdata/ms.py index bdf558b43..ff3dfd50f 100644 --- a/pyuvdata/uvdata/ms.py +++ b/pyuvdata/uvdata/ms.py @@ -2332,7 +2332,7 @@ def read_ms( self.freq_array = np.expand_dims(self.freq_array, 0) # order polarizations - self.reorder_pols(order=pol_order, run_check=False) + self.reorder_pols(pol_order, run_check=False) if use_future_array_shapes: self.use_future_array_shapes() diff --git a/pyuvdata/uvdata/tests/test_miriad.py b/pyuvdata/uvdata/tests/test_miriad.py index 9e1db262d..cceeae9cf 100644 --- a/pyuvdata/uvdata/tests/test_miriad.py +++ b/pyuvdata/uvdata/tests/test_miriad.py @@ -1147,7 +1147,7 @@ def test_roundtrip_optional_params(uv_in_paper, tmp_path): assert uv_in == uv_out # test with bda as well (single entry in tuple) - uv_in.reorder_blts(order="bda") + uv_in.reorder_blts("bda") uv_in.write_miriad(testfile, clobber=True) uv_out.read(testfile, use_future_array_shapes=True) diff --git a/pyuvdata/uvdata/tests/test_uvdata.py b/pyuvdata/uvdata/tests/test_uvdata.py index 007227cd3..a1c9934bc 100644 --- a/pyuvdata/uvdata/tests/test_uvdata.py +++ b/pyuvdata/uvdata/tests/test_uvdata.py @@ -351,8 +351,8 @@ def uv_phase_time_split(hera_uvh5): uv_phase = hera_uvh5.copy uv_raw = hera_uvh5.copy - uv_phase.reorder_blts(order="time", minor_order="baseline") - uv_raw.reorder_blts(order="time", minor_order="baseline") + uv_phase.reorder_blts("time", minor_order="baseline") + uv_raw.reorder_blts("time", minor_order="baseline") uv_phase.phase(ra=0, dec=0, cat_name="npole", epoch="J2000", use_ant_pos=True) times = np.unique(uv_phase.time_array) @@ -1439,7 +1439,7 @@ def test_select_phase_center_id(tmp_path, carma_miriad): @pytest.mark.filterwarnings("ignore:The uvw_array does not match the expected values") def test_select_phase_center_id_blts(carma_miriad): uv_obj = carma_miriad - uv_obj.reorder_blts(order="baseline") + uv_obj.reorder_blts("baseline") uv1 = uv_obj.select( phase_center_ids=0, blt_inds=np.arange(uv_obj.Nblts // 2), inplace=False @@ -3106,7 +3106,7 @@ def test_reorder_pols(casa_uvfits, future_shapes): uv2.data_array = uv2.data_array[:, :, :, order] uv2.nsample_array = uv2.nsample_array[:, :, :, order] uv2.flag_array = uv2.flag_array[:, :, :, order] - uv1.reorder_pols(order=order) + uv1.reorder_pols(order) assert uv1 == uv2 # Restore original order @@ -3114,13 +3114,13 @@ def test_reorder_pols(casa_uvfits, future_shapes): uv2.reorder_pols() assert uv1 == uv2 - uv1.reorder_pols(order="AIPS") + uv1.reorder_pols("AIPS") # check that we have aips ordering aips_pols = np.array([-1, -2, -3, -4]).astype(int) assert np.all(uv1.polarization_array == aips_pols) uv2 = uv1.copy() - uv2.reorder_pols(order="CASA") + uv2.reorder_pols("CASA") # check that we have casa ordering casa_pols = np.array([-1, -3, -4, -2]).astype(int) assert np.all(uv2.polarization_array == casa_pols) @@ -3132,7 +3132,7 @@ def test_reorder_pols(casa_uvfits, future_shapes): assert np.all(uv2.data_array == uv1.data_array[:, :, :, order]) assert np.all(uv2.flag_array == uv1.flag_array[:, :, :, order]) - uv2.reorder_pols(order="AIPS") + uv2.reorder_pols("AIPS") # check that we have aips ordering again assert uv1 == uv2 @@ -3141,11 +3141,11 @@ def test_reorder_pols(casa_uvfits, future_shapes): ValueError, match="order must be one of: 'AIPS', 'CASA', or an index array of length Npols", ): - uv2.reorder_pols(order={"order": "foo"}) + uv2.reorder_pols({"order": "foo"}) # check error if order is an array of the wrong length with pytest.raises(ValueError, match="If order is an index array, it must"): - uv2.reorder_pols(order=[3, 2, 1]) + uv2.reorder_pols([3, 2, 1]) @pytest.mark.filterwarnings("ignore:Telescope EVLA is not") @@ -3167,7 +3167,7 @@ def test_reorder_blts_errs(casa_uvfits, order, minor_order, msg): Verify that reorder_blts throws expected errors when supplied with bad args """ with pytest.raises(ValueError, match=msg): - casa_uvfits.reorder_blts(order=order, minor_order=minor_order) + casa_uvfits.reorder_blts(order, minor_order=minor_order) @pytest.mark.filterwarnings("ignore:This method will be removed in version 3.0 when") @@ -3270,7 +3270,7 @@ def test_reorder_blts_equiv(casa_uvfits, args1, args2, future_shapes): def test_reorder_blts_sort_order( hera_uvh5, order, m_order, check_tuple, check_attr, autos_first ): - hera_uvh5.reorder_blts(order=order, minor_order=m_order, autos_first=autos_first) + hera_uvh5.reorder_blts(order, minor_order=m_order, autos_first=autos_first) assert hera_uvh5.blt_order == check_tuple if isinstance(order, str) and autos_first: auto_inds = np.nonzero(hera_uvh5.ant_1_array == hera_uvh5.ant_2_array)[0] @@ -7060,7 +7060,7 @@ def test_upsample_in_time(hera_uvh5, future_shapes): uv_object.phase_center_catalog[0] = init_phase_dict # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline") + uv_object.reorder_blts("baseline") # save some values for later init_data_size = uv_object.data_array.size @@ -7096,7 +7096,7 @@ def test_upsample_in_time_with_flags(hera_uvh5): uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline") + uv_object.reorder_blts("baseline") # save some values for later init_wf = uv_object.get_data(0, 1) @@ -7132,7 +7132,7 @@ def test_upsample_in_time_noninteger_resampling(hera_uvh5): uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline") + uv_object.reorder_blts("baseline") # save some values for later init_data_size = uv_object.data_array.size @@ -7193,7 +7193,7 @@ def test_upsample_in_time_summing_correlator_mode(hera_uvh5): uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline") + uv_object.reorder_blts("baseline") # save some values for later init_data_size = uv_object.data_array.size @@ -7231,7 +7231,7 @@ def test_upsample_in_time_summing_correlator_mode_with_flags(hera_uvh5): uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline") + uv_object.reorder_blts("baseline") # save some values for later init_wf = uv_object.get_data(0, 1) @@ -7269,7 +7269,7 @@ def test_upsample_in_time_summing_correlator_mode_nonint_resampling(hera_uvh5): uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline") + uv_object.reorder_blts("baseline") # save some values for later init_data_size = uv_object.data_array.size @@ -7312,7 +7312,7 @@ def test_partial_upsample_in_time(hera_uvh5): uv_object.integration_time[bl_inds] = uv_object.integration_time[0] / 2.0 # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline") + uv_object.reorder_blts("baseline") # save some values for later init_wf_01 = uv_object.get_data(0, 1) @@ -7351,7 +7351,7 @@ def test_upsample_in_time_drift(hera_uvh5): uv_object = hera_uvh5 # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline") + uv_object.reorder_blts("baseline") # save some values for later init_data_size = uv_object.data_array.size @@ -7408,7 +7408,7 @@ def test_upsample_in_time_drift_no_phasing(hera_uvh5, driftscan, partial_phase): ) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline") + uv_object.reorder_blts("baseline") # save some values for later init_data_size = uv_object.data_array.size @@ -7454,7 +7454,7 @@ def test_downsample_in_time(hera_uvh5, future_shapes): uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") uv_object2 = uv_object.copy() # save some values for later @@ -7505,7 +7505,7 @@ def test_downsample_in_time_partial_flags(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # save some values for later init_wf = uv_object.get_data(0, 1) original_int_time = np.amax(uv_object.integration_time) @@ -7559,7 +7559,7 @@ def test_downsample_in_time_totally_flagged(hera_uvh5, future_shapes): uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") uv_object2 = uv_object.copy() # save some values for later @@ -7613,7 +7613,7 @@ def test_downsample_in_time_uneven_samples(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") uv_object2 = uv_object.copy() # save some values for later @@ -7667,7 +7667,7 @@ def test_downsample_in_time_uneven_samples_keep_ragged(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") uv_object2 = uv_object.copy() # save some values for later @@ -7709,7 +7709,7 @@ def test_downsample_in_time_summing_correlator_mode(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # save some values for later init_data_size = uv_object.data_array.size @@ -7754,7 +7754,7 @@ def test_downsample_in_time_summing_correlator_mode_partial_flags(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # save some values for later init_wf = uv_object.get_data(0, 1) @@ -7800,7 +7800,7 @@ def test_downsample_in_time_summing_correlator_mode_totally_flagged(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # save some values for later init_wf = uv_object.get_data(0, 1) @@ -7847,7 +7847,7 @@ def test_downsample_in_time_summing_correlator_mode_uneven_samples(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # save some values for later init_wf = uv_object.get_data(0, 1) @@ -7900,7 +7900,7 @@ def test_downsample_in_time_summing_correlator_mode_uneven_samples_drop_ragged( uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # save some values for later init_wf = uv_object.get_data(0, 1) @@ -7947,7 +7947,7 @@ def test_partial_downsample_in_time(hera_uvh5): uv_object.integration_time[bl_inds] = uv_object.integration_time[0] * 2.0 # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline") + uv_object.reorder_blts("baseline") # save some values for later init_wf_01 = uv_object.get_data(0, 1) @@ -7994,7 +7994,7 @@ def test_downsample_in_time_drift(hera_uvh5): uv_object = hera_uvh5 # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") uv_object2 = uv_object.copy() # save some values for later @@ -8062,7 +8062,7 @@ def test_downsample_in_time_drift_no_phasing(hera_uvh5, driftscan, partial_phase ) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") uv_object2 = uv_object.copy() # save some values for later @@ -8116,7 +8116,7 @@ def test_downsample_in_time_nsample_precision(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # save some values for later init_wf = uv_object.get_data(0, 1) original_int_time = np.amax(uv_object.integration_time) @@ -8170,7 +8170,7 @@ def test_downsample_in_time_errors(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # raise an error if set neither min_int_time and n_times_to_avg with pytest.raises( @@ -8202,7 +8202,7 @@ def test_downsample_in_time_errors(hera_uvh5): # raise an error if phase centers change within an downsampling window uv_object2 = uv_object.copy() - uv_object2.reorder_blts(order="time") + uv_object2.reorder_blts("time") mask = np.full(uv_object2.Nblts, False) mask[: uv_object2.Nblts // 3] = True uv_object2.phase(ra=0, dec=0, phase_frame="icrs", select_mask=mask, cat_name="foo") @@ -8280,7 +8280,7 @@ def test_downsample_in_time_int_time_mismatch_warning(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # save some values for later init_data_size = uv_object.data_array.size @@ -8324,7 +8324,7 @@ def test_downsample_in_time_varying_integration_time(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # save some values for later init_wf = uv_object.get_data(0, 1) @@ -8381,7 +8381,7 @@ def test_downsample_in_time_varying_int_time_partial_flags(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # downselect to 14 times and one baseline uv_object.select(times=np.unique(uv_object.time_array)[:14]) @@ -8430,7 +8430,7 @@ def test_downsample_in_time_varying_integration_time_warning(hera_uvh5): uv_object = hera_uvh5 uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") # save some values for later init_wf = uv_object.get_data(0, 1) @@ -8475,7 +8475,7 @@ def test_upsample_downsample_in_time(hera_uvh5): uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") uv_object2 = uv_object.copy() max_integration_time = np.amin(uv_object.integration_time) / 2.0 @@ -8566,7 +8566,7 @@ def test_upsample_downsample_in_time_odd_resample(hera_uvh5, future_shapes): uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") uv_object2 = uv_object.copy() # try again with a resampling factor of 3 (test odd numbers) @@ -8613,7 +8613,7 @@ def test_upsample_downsample_in_time_metadata_only(hera_uvh5): uv_object.phase_to_time(Time(uv_object.time_array[0], format="jd")) # reorder to make sure we get the right value later - uv_object.reorder_blts(order="baseline", minor_order="time") + uv_object.reorder_blts("baseline", minor_order="time") uv_object2 = uv_object.copy() max_integration_time = np.amin(uv_object.integration_time) / 2.0 @@ -12001,9 +12001,9 @@ def test_add_pol_sorting_bl(casa_uvfits, add_type, sort_type, future_shapes): ) if sort_type == "blt": - uv1.reorder_blts(order="time", minor_order="ant1") - uv2.reorder_blts(order="time", minor_order="ant2") - casa_uvfits.reorder_blts(order="bda") + uv1.reorder_blts("time", minor_order="ant1") + uv2.reorder_blts("time", minor_order="ant2") + casa_uvfits.reorder_blts("bda") order_check = uv1.ant_1_array == uv2.ant_1_array elif sort_type == "freq": uv1.reorder_freqs(channel_order="freq") @@ -12011,9 +12011,9 @@ def test_add_pol_sorting_bl(casa_uvfits, add_type, sort_type, future_shapes): casa_uvfits.reorder_freqs(spw_order="freq") order_check = uv1.freq_array == uv2.freq_array elif sort_type == "pol": - uv1.reorder_pols(order="AIPS") - uv2.reorder_pols(order="CASA") - casa_uvfits.reorder_pols(order="CASA") + uv1.reorder_pols("AIPS") + uv2.reorder_pols("CASA") + casa_uvfits.reorder_pols("CASA") order_check = uv1.polarization_array == uv2.polarization_array # Make sure that the order has actually been scrambled @@ -12023,11 +12023,11 @@ def test_add_pol_sorting_bl(casa_uvfits, add_type, sort_type, future_shapes): uv3 = uv1 + uv2 if sort_type == "blt": - uv3.reorder_blts(order="bda") + uv3.reorder_blts("bda") elif sort_type == "freq": uv3.reorder_freqs(channel_order="freq") elif sort_type == "pol": - uv3.reorder_pols(order="CASA") + uv3.reorder_pols("CASA") # Deal with the history separately, since it will be different assert str.startswith(uv3.history, casa_uvfits.history) @@ -12651,7 +12651,7 @@ def test_setting_time_axis_wrongly(casa_uvfits): with pytest.raises(ValueError, match="time_axis_faster_than_bls is True but"): casa_uvfits.check() - casa_uvfits.reorder_blts(order="time", minor_order="baseline") + casa_uvfits.reorder_blts("time", minor_order="baseline") casa_uvfits.blts_are_rectangular = True casa_uvfits.time_axis_faster_than_bls = True with pytest.raises( @@ -12659,7 +12659,7 @@ def test_setting_time_axis_wrongly(casa_uvfits): ): casa_uvfits.check() - casa_uvfits.reorder_blts(order="baseline", minor_order="time") + casa_uvfits.reorder_blts("baseline", minor_order="time") assert not casa_uvfits.time_axis_faster_than_bls casa_uvfits.blts_are_rectangular = True assert not casa_uvfits.time_axis_faster_than_bls @@ -12676,12 +12676,12 @@ def test_set_rectangularity(casa_uvfits, hera_uvh5): assert casa_uvfits.blts_are_rectangular is False assert casa_uvfits.time_axis_faster_than_bls is False - hera_uvh5.reorder_blts(order="time", minor_order="baseline") + hera_uvh5.reorder_blts("time", minor_order="baseline") hera_uvh5.set_rectangularity(force=True) assert hera_uvh5.blts_are_rectangular is True assert hera_uvh5.time_axis_faster_than_bls is False - hera_uvh5.reorder_blts(order=np.random.permutation(hera_uvh5.Nblts)) + hera_uvh5.reorder_blts(np.random.permutation(hera_uvh5.Nblts)) hera_uvh5.set_rectangularity(force=True) assert hera_uvh5.blts_are_rectangular is False assert hera_uvh5.time_axis_faster_than_bls is False diff --git a/pyuvdata/uvdata/tests/test_uvh5.py b/pyuvdata/uvdata/tests/test_uvh5.py index 4e20164ef..bfef79cd4 100644 --- a/pyuvdata/uvdata/tests/test_uvh5.py +++ b/pyuvdata/uvdata/tests/test_uvh5.py @@ -351,7 +351,7 @@ def test_uvh5_optional_parameters(casa_uvfits, tmp_path): assert uv_in == uv_out # test with blt_order = bda as well (single entry in tuple) - uv_in.reorder_blts(order="bda") + uv_in.reorder_blts("bda") uv_in.write_uvh5(testfile, clobber=True) uv_out.read(testfile, use_future_array_shapes=True) @@ -3621,7 +3621,7 @@ def setup_class(self): meta = uvh5.FastUVH5Meta(self.fl) uvd = meta.to_uvdata() - uvd.reorder_blts(order="baseline", minor_order="time") + uvd.reorder_blts("baseline", minor_order="time") self.fltime_axis_faster_than_bls = os.path.join( self.tmp_path.name, "time_axis_faster_than_bls.uvh5" ) @@ -3728,7 +3728,7 @@ def test_getting_lsts(self): # Now test a different ordering. uvd = meta.to_uvdata() - uvd.reorder_blts(order="baseline", minor_order="time") + uvd.reorder_blts("baseline", minor_order="time") uvd.initialize_uvh5_file( os.path.join(self.tmp_path.name, "time_axis_faster_than_bls.uvh5"), clobber=True, diff --git a/pyuvdata/uvdata/uvdata.py b/pyuvdata/uvdata/uvdata.py index 889ebd28d..0f2c1129d 100644 --- a/pyuvdata/uvdata/uvdata.py +++ b/pyuvdata/uvdata/uvdata.py @@ -4782,8 +4782,8 @@ def conjugate_bls(self, convention="ant1 None: def reorder_blts( self, - *, order="time", + *, minor_order=None, autos_first=False, conj_convention=None, @@ -6702,7 +6702,7 @@ def __add__( this_pol_ind[other_argsort] ] - this.reorder_pols(order=temp_ind) + this.reorder_pols(temp_ind) # Pad out self to accommodate new data blt_order = None