def test_copy(): uvf = UVFlag(test_f_file) uvf2 = uvf.copy() nt.assert_true(uvf == uvf2) # Make sure it's a copy and not just pointing to same object uvf.to_waterfall() nt.assert_false(uvf == uvf2)
def test_antenna_to_antenna(): uvc = UVCal() uvc.read_calfits(test_c_file) uvf = UVFlag(uvc) uvf2 = uvf.copy() uvf.to_antenna(uvc) nt.assert_equal(uvf, uvf2)
def test_baseline_to_baseline(): uv = UVData() uv.read_miriad(test_d_file) uvf = UVFlag(uv) uvf2 = uvf.copy() uvf.to_baseline(uv) nt.assert_equal(uvf, uvf2)
def test_or_add_history(): uvf = UVFlag(test_f_file) uvf.to_flag() uvf2 = uvf.copy() uvf2.history = 'Different history' uvf3 = uvf | uvf2 nt.assert_true(uvf.history in uvf3.history) nt.assert_true(uvf2.history in uvf3.history) nt.assert_true("Flags OR'd with:" in uvf3.history)
def test_not_equal(): uvf1 = UVFlag(test_f_file) # different class nt.assert_false(uvf1.__eq__(5)) # different mode uvf2 = uvf1.copy() uvf2.mode = 'flag' nt.assert_false(uvf1.__eq__(uvf2)) # different type uvf2 = uvf1.copy() uvf2.type = 'antenna' nt.assert_false(uvf1.__eq__(uvf2)) # array different uvf2 = uvf1.copy() uvf2.freq_array += 1 nt.assert_false(uvf1.__eq__(uvf2)) # history different uvf2 = uvf1.copy() uvf2.history += 'hello' nt.assert_false(uvf1.__eq__(uvf2, check_history=True))
def test_ior(): uvf = UVFlag(test_f_file) uvf.to_flag() uvf2 = uvf.copy() uvf2.flag_array = np.ones_like(uvf2.flag_array) uvf.flag_array[0] = True uvf2.flag_array[0] = False uvf2.flag_array[1] = False uvf |= uvf2 nt.assert_true(np.all(uvf.flag_array[0])) nt.assert_false(np.any(uvf.flag_array[1])) nt.assert_true(np.all(uvf.flag_array[2:]))
def test_to_waterfall_bl_multi_pol(): uvf = UVFlag(test_f_file) uvf.weights_array = np.ones_like(uvf.weights_array) uvf2 = uvf.copy() uvf2.polarization_array[0] = -4 uvf.__add__(uvf2, inplace=True, axis='pol') # Concatenate to form multi-pol object uvf2 = uvf.copy() # Keep a copy to run with keep_pol=False uvf.to_waterfall() nt.assert_true(uvf.type == 'waterfall') nt.assert_true(uvf.metric_array.shape == (len(uvf.time_array), len(uvf.freq_array), len(uvf.polarization_array))) nt.assert_true(uvf.weights_array.shape == uvf.metric_array.shape) nt.assert_true(len(uvf.polarization_array) == 2) # Repeat with keep_pol=False uvf2.to_waterfall(keep_pol=False) nt.assert_true(uvf2.type == 'waterfall') nt.assert_true(uvf2.metric_array.shape == (len(uvf2.time_array), len(uvf.freq_array), 1)) nt.assert_true(uvf2.weights_array.shape == uvf2.metric_array.shape) nt.assert_true(len(uvf2.polarization_array) == 1) nt.assert_true(uvf2.polarization_array[0] == ','.join( map(str, uvf.polarization_array)))
def test_to_antenna_flags_match_uvflag(): uvc = UVCal() uvc.read_calfits(test_c_file) uvf = UVFlag(uvc) uvf2 = uvf.copy() uvf.to_waterfall() uvf.to_flag() uvf.flag_array[0, 10, 0] = True # Flag time0, chan10 uvf.flag_array[1, 15, 0] = True # Flag time1, chan15 uvf.to_antenna(uvf2) nt.assert_true(np.all(uvf.ant_array == uvc.ant_array)) nt.assert_true(np.all(uvf.time_array == uvc.time_array)) nt.assert_true(np.all(uvf.flag_array[:, 0, 10, 0, 0])) nt.assert_true(np.all(uvf.flag_array[:, 0, 15, 1, 0])) nt.assert_true(uvf.flag_array.mean() == 2. * uvc.Nants_data / uvf.flag_array.size)
def test_metric_to_metric(): uvf = UVFlag(test_f_file) uvf2 = uvf.copy() uvf.to_metric() nt.assert_equal(uvf, uvf2)
def test_flag_to_flag(): uvf = UVFlag(test_f_file) uvf.to_flag() uvf2 = uvf.copy() uvf2.to_flag() nt.assert_equal(uvf, uvf2)
def test_or_error(): uvf = UVFlag(test_f_file) uvf2 = uvf.copy() uvf.to_flag() nt.assert_raises(ValueError, uvf.__or__, uvf2)