Source
3814
3814
self.run_apply_test()
3815
3815
3816
3816
def test052(self):
3817
3817
# blmode='apply', spw to flag channels 4500-6499
3818
3818
self.params['spw'] = self.spw
3819
3819
self.run_apply_test()
3820
3820
3821
3821
def run_clipping_test(self):
3822
3822
# set artificial spectra (flat+outlier) in input MS
3823
3823
with table_manager(self.infile, nomodify=False) as tb:
3824
-
spec = tb.getcell('FLOAT_DATA', 0) # row 0
3825
-
for ipol in range(2):
3826
-
for i in range(len(spec[0])):
3827
-
spec[ipol][i] = 1.0 if i % 2 == 0 else -1.0 # mean=0, sigma=1
3828
-
# an outlier
3829
-
spec[ipol][4000] = 100000000.0
3824
+
spec = tb.getcell('FLOAT_DATA', 0) # row 0, shape = (npol, nchan)
3825
+
# flat spectrum with (mean, sigma) = (0, 1)
3826
+
spec[:, 0::2] = 1.0
3827
+
spec[:, 1::2] = -1.0
3828
+
# an outlier
3829
+
spec[:, 4000] = 100000000.0
3830
3830
tb.putcell('FLOAT_DATA', 0, spec)
3831
3831
3832
3832
flag = tb.getcell('FLAG', 0) # row 0
3833
3833
flag.fill(False)
3834
3834
tb.putcell('FLAG', 0, flag)
3835
3835
3836
3836
# compute the reference weight value
3837
3837
for ipol in range(2):
3838
3838
flag[ipol][4000] = True
3839
3839
mdata = np.ma.masked_array(spec, mask=flag)
3900
3900
self.outdata = {}
3901
3901
self.outmask = {}
3902
3902
3903
3903
def tearDown(self):
3904
3904
remove_files_dirs(self.infile)
3905
3905
remove_files_dirs(self.outroot)
3906
3906
3907
3907
def _setup_input_data(self, spikes):
3908
3908
with table_manager(self.infile, nomodify=False) as tb:
3909
3909
data = tb.getcell('FLOAT_DATA', 0)
3910
-
for ipol in range(len(data)):
3911
-
# base data by repeating 1 and -1 - this has mean=5, sigma=1
3912
-
for ichan in range(len(data[0])):
3913
-
data[ipol][ichan] = 5.0 + (1.0 if ichan % 2 == 0 else -1.0)
3914
-
# add spike data
3915
-
for chan, value in spikes:
3916
-
data[ipol][chan] = value
3910
+
# flat spectrum with (mean, sigma) = (5, 1)
3911
+
data[:, 0::2] = 6.0
3912
+
data[:, 1::2] = 4.0
3913
+
# outliers
3914
+
for chan, value in spikes:
3915
+
data[:, chan] = value
3917
3916
tb.putcell('FLOAT_DATA', 0, data)
3918
3917
3919
3918
def _set_params(self, blfunc, outbl, clipniter, thres):
3920
3919
self.params['blfunc'] = blfunc
3921
3920
self.params['blformat'] = 'csv' if outbl else ''
3922
3921
self.params['clipniter'] = clipniter
3923
3922
self.params['clipthresh'] = thres
3924
3923
3925
3924
def _get_data_name(self, outbl, clipniter):
3926
3925
name_bl = 'bl' if outbl else 'nobl'