# blmode='apply', channels 4500~6500 flagged in input data
# blmode='apply', spw to flag channels 4500-6499
self.params['spw'] = self.spw
def run_clipping_test(self):
# set an artificial data (flat+outlier) in input MS
# set artificial spectra (flat+outlier) in input MS
with table_manager(self.infile, nomodify=False) as tb:
spec = tb.getcell('FLOAT_DATA', 0) # row 0
for i in range(len(spec[0])):
spec[ipol][i] = 1.0 if i % 2 == 0 else -1.0 # mean=0, sigma=1
spec[ipol][4000] = 100000000.0
tb.putcell('FLOAT_DATA', 0, spec)
flag = tb.getcell('FLAG', 0) # row 0
for i in range(len(flag[0])):
tb.putcell('FLAG', 0, flag)
# compute the reference value of weight
# compute the reference weight value
mdata = np.ma.masked_array(spec, mask=flag)
weight_ref = 1.0 / np.var(mdata, axis=1)
sdbaseline(**self.params)
# the weight values in the output MS should be close to 1
# if the outlier channel is correctly eliminated.
# if clipping result is not considered in computing weights,
# if the outlier channel is correctly eliminated by iterative clipping.
# if clipping result is not taken into account when computing weights,
# the weight should be a very small value (~ 8 * 10^-13)
with table_manager(self.outfile) as tb:
np.allclose(tb.getcell('WEIGHT', 0), weight_ref)
# confirm that the clipping result (mask) is correctly used to compute weights
self.params['clipniter'] = 5
self.params['clipthresh'] = 3.0
self.params['updateweight'] = True
self.params['blmode'] = 'fit'