def test_get_cal_product_missing_parts(self): cache = create_sensor_cache() product = create_product(create_bandpass) n_chans_per_part = CAL_N_CHANS // BANDPASS_PARTS # Remove parts of multi-part cal product one by one for n in range(BANDPASS_PARTS - 1): del cache[CAL_STREAM + '_product_B' + str(n)] product_sensor = get_cal_product(cache, CAL_STREAM, 'B') part = slice(n * n_chans_per_part, (n + 1) * n_chans_per_part) product[part] = INVALID_GAIN assert_array_equal(product_sensor[12], product) # Recalculate on the next pass del cache[f'Calibration/Products/{CAL_STREAM}/B'] # All parts gone triggers a KeyError del cache[CAL_STREAM + '_product_B' + str(BANDPASS_PARTS - 1)] with assert_raises(KeyError): get_cal_product(cache, CAL_STREAM, 'B')
def test_calc_delay_correction(self): product_sensor = get_cal_product(self.cache, CAL_STREAM, 'K') constant_bandpass = np.ones(N_CHANS, dtype='complex64') for n in range(len(ANTS)): for m in range(len(POLS)): sensor = calc_delay_correction(product_sensor, (m, n), FREQS) assert_array_equal(sensor[n], constant_bandpass) assert_array_equal(sensor[10 + n], delay_corrections(m, n))
def test_calc_selfcal_gain_correction(self): product_sensor = get_cal_product(self.cache, CAL_STREAM, 'GPHASE') target_sensor = self.cache.get('Observation/target') for n in range(len(ANTS)): for m in range(len(POLS)): sensor = calc_gain_correction(product_sensor, (m, n), target_sensor) assert_array_equal(sensor[:], gain_corrections( m, n, multi_channel=True, targets=True))
def test_calc_bandpass_correction(self): product_sensor = get_cal_product(self.cache, CAL_STREAM, 'B') constant_bandpass = np.ones(N_CHANS, dtype='complex64') constant_bandpass[FREQS < CAL_FREQS[0]] = INVALID_GAIN constant_bandpass[FREQS > CAL_FREQS[-1]] = INVALID_GAIN for n in range(len(ANTS)): for m in range(len(POLS)): sensor = calc_bandpass_correction(product_sensor, (m, n), FREQS, CAL_FREQS) assert_array_equal(sensor[n], constant_bandpass) assert_array_equal(sensor[12 + n], bandpass_corrections(m, n))
def test_calc_gain_correction(self): product_sensor = get_cal_product(self.cache, CAL_STREAM, 'G') for n in range(len(ANTS)): for m in range(len(POLS)): sensor = calc_gain_correction(product_sensor, (m, n)) assert_array_equal(sensor[:], gain_corrections(m, n))
def test_get_cal_product_selfcal_gain(self): product_sensor = get_cal_product(self.cache, CAL_STREAM, 'GPHASE') product = create_product( partial(create_gain, multi_channel=True, targets=True)) assert_array_equal(product_sensor[GAIN_EVENTS], product)
def test_get_cal_product_gain(self): product_sensor = get_cal_product(self.cache, CAL_STREAM, 'G') product = create_product(create_gain) assert_array_equal(product_sensor[GAIN_EVENTS], product)
def test_get_cal_product_single_multipart(self): product_sensor = get_cal_product(self.cache, CAL_STREAM, 'B') product = create_product(create_bandpass) assert_array_equal(product_sensor[0], np.ones_like(product)) assert_array_equal(product_sensor[12], product)
def test_get_cal_product_basic(self): product_sensor = get_cal_product(self.cache, CAL_STREAM, 'K') product = create_product(create_delay) assert_array_equal(product_sensor[0], np.zeros_like(product)) assert_array_equal(product_sensor[10], product)