Exemplo n.º 1
0
def test_to_flag():
    uvf = UVFlag(test_f_file)
    uvf.to_flag()
    nt.assert_true(hasattr(uvf, 'flag_array'))
    nt.assert_false(hasattr(uvf, 'metric_array'))
    nt.assert_true(uvf.mode == 'flag')
    nt.assert_true('Converted to mode "flag"' in uvf.history)
Exemplo n.º 2
0
def test_to_waterfall_bl_flags_or():
    uvf = UVFlag(test_f_file)
    uvf.to_flag()
    uvf.weights_array = np.ones_like(uvf.weights_array)
    uvf.to_waterfall(method='or')
    nt.assert_true(uvf.type == 'waterfall')
    nt.assert_true(uvf.mode == 'flag')
    nt.assert_true(uvf.flag_array.shape == (len(uvf.time_array),
                                            len(uvf.freq_array),
                                            len(uvf.polarization_array)))
    nt.assert_true(
        np.array_equal(uvf.weights_array, np.ones_like(uvf.flag_array,
                                                       np.float)))
    uvf = UVFlag(test_f_file)
    uvf.to_flag()
    uvf.weights_array = np.ones_like(uvf.weights_array)
    uvf.weights_array[0, 0, 0, 0] = 0.2
    uvtest.checkWarnings(uvf.to_waterfall, [], {'method': 'or'},
                         nwarnings=1,
                         message='Currently weights are')
    nt.assert_true(uvf.type == 'waterfall')
    nt.assert_true(uvf.mode == 'flag')
    nt.assert_true(uvf.flag_array.shape == (len(uvf.time_array),
                                            len(uvf.freq_array),
                                            len(uvf.polarization_array)))
    nt.assert_true(
        np.array_equal(uvf.weights_array, np.ones_like(uvf.flag_array,
                                                       np.float)))
Exemplo n.º 3
0
 def test_uvflag(self):
     uvf = UVFlag(test_f_file)
     uvf.to_flag()
     xant = uvf.ant_1_array[0]
     xrfi.flag_xants(uvf, xant)
     nt.assert_true(np.all(uvf.flag_array[uvf.ant_1_array == xant, :, :, :]))
     nt.assert_true(np.all(uvf.flag_array[uvf.ant_2_array == xant, :, :, :]))
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
def test_to_waterfall_bl_flags():
    uvf = UVFlag(test_f_file)
    uvf.to_flag()
    uvf.weights_array = np.ones_like(uvf.weights_array)
    uvf.to_waterfall()
    nt.assert_true(uvf.type == 'waterfall')
    nt.assert_true(uvf.mode == 'metric')
    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)
Exemplo n.º 6
0
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:]))
Exemplo n.º 7
0
def test_to_antenna_flags():
    uvc = UVCal()
    uvc.read_calfits(test_c_file)
    uvf = UVFlag(uvc)
    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(uvc)
    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)
Exemplo n.º 8
0
def test_to_antenna_force_pol():
    uvc = UVCal()
    uvc.read_calfits(test_c_file)
    uvc.select(jones=-5)
    uvf = UVFlag(uvc)
    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.polarization_array[0] = -4  # Change pol, but force pol anyway
    uvf.to_antenna(uvc, force_pol=True)
    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.array_equal(uvf.polarization_array, uvc.jones_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)
Exemplo n.º 9
0
def test_to_baseline_flags():
    uv = UVData()
    uv.read_miriad(test_d_file)
    uvf = UVFlag(uv)
    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_baseline(uv)
    nt.assert_true(np.all(uvf.baseline_array == uv.baseline_array))
    nt.assert_true(np.all(uvf.time_array == uv.time_array))
    times = np.unique(uvf.time_array)
    ntrue = 0.0
    ind = np.where(uvf.time_array == times[0])[0]
    ntrue += len(ind)
    nt.assert_true(np.all(uvf.flag_array[ind, 0, 10, 0]))
    ind = np.where(uvf.time_array == times[1])[0]
    ntrue += len(ind)
    nt.assert_true(np.all(uvf.flag_array[ind, 0, 15, 0]))
    nt.assert_true(uvf.flag_array.mean() == ntrue / uvf.flag_array.size)
Exemplo n.º 10
0
def test_to_baseline_force_pol():
    uv = UVData()
    uv.read_miriad(test_d_file)
    uvf = UVFlag(uv)
    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.polarization_array[0] = -4  # Change pol, but force pol anyway
    uvf.to_baseline(uv, force_pol=True)
    nt.assert_true(np.all(uvf.baseline_array == uv.baseline_array))
    nt.assert_true(np.all(uvf.time_array == uv.time_array))
    nt.assert_true(
        np.array_equal(uvf.polarization_array, uv.polarization_array))
    times = np.unique(uvf.time_array)
    ntrue = 0.0
    ind = np.where(uvf.time_array == times[0])[0]
    ntrue += len(ind)
    nt.assert_true(np.all(uvf.flag_array[ind, 0, 10, 0]))
    ind = np.where(uvf.time_array == times[1])[0]
    ntrue += len(ind)
    nt.assert_true(np.all(uvf.flag_array[ind, 0, 15, 0]))
    nt.assert_true(uvf.flag_array.mean() == ntrue / uvf.flag_array.size)
Exemplo n.º 11
0
def test_flag_to_flag():
    uvf = UVFlag(test_f_file)
    uvf.to_flag()
    uvf2 = uvf.copy()
    uvf2.to_flag()
    nt.assert_equal(uvf, uvf2)
Exemplo n.º 12
0
def test_or_error():
    uvf = UVFlag(test_f_file)
    uvf2 = uvf.copy()
    uvf.to_flag()
    nt.assert_raises(ValueError, uvf.__or__, uvf2)
Exemplo n.º 13
0
 def test_uvflag_waterfall_error(self):
     uvf = UVFlag(test_f_file)
     uvf.to_waterfall()
     uvf.to_flag()
     nt.assert_raises(ValueError, xrfi.flag_xants, uvf, 0)