Source
3196
3196
shutil.rmtree(self.infile)
3197
3197
shutil.copytree(os.path.join(self.datapath, self.infile), self.infile)
3198
3198
default(sdbaseline)
3199
3199
3200
3200
def tearDown(self):
3201
3201
remove_single_file_dir(self.infile)
3202
3202
remove_files_dirs(self.outroot)
3203
3203
3204
3204
def flag(self, infile, edge=None, rowidx=None):
3205
3205
rowflag = True if edge is None else False
3206
-
if type(rowidx) == int:
3206
+
if isinstance(rowidx, int):
3207
3207
rowidx = [rowidx]
3208
-
tb.open(infile, nomodify=False)
3209
-
if rowidx is None:
3210
-
rowidx = range(tb.nrows())
3211
-
try:
3208
+
3209
+
with table_manager(infile, nomodify=False) as tb:
3210
+
if rowidx is None:
3211
+
rowidx = range(tb.nrows())
3212
3212
for idx in rowidx:
3213
3213
specs = tb.getcell("FLAG", idx)
3214
3214
if rowflag:
3215
3215
specs = True
3216
3216
else:
3217
3217
specs[:, :edge[0]] = True
3218
3218
if edge[1] > 0:
3219
3219
specs[:, -edge[1]:] = True
3220
3220
tb.putcell('FLAG', idx, specs)
3221
-
finally:
3222
-
tb.close()
3223
3221
3224
3222
def run_test(self, refstat, **kwargs):
3225
3223
task_param = self.base_param.copy()
3226
3224
for key, val in kwargs.items():
3227
3225
task_param[key] = val
3228
3226
sdbaseline(**task_param)
3229
3227
outfile = task_param['outfile']
3230
3228
polid = 0 if task_param['pol'] in ['RR', 'LL'] else None
3231
3229
currstat = self._getStats(outfile, spw='0', pol=polid,
3232
3230
colname=task_param['datacolumn'].upper(),
3596
3594
test022 --- updateweight=True, sigmavalue='stddev', spw to flag channels 4500-6499
3597
3595
test030 --- updateweight=True, sigmavalue='rms'
3598
3596
test031 --- updateweight=True, sigmavalue='rms', channels 4500~6500 flagged in input data
3599
3597
test032 --- updateweight=True, sigmavalue='rms', spw to flag channels 4500-6499
3600
3598
test040 --- blfunc='variable'
3601
3599
test041 --- blfunc='variable', channels 4500~6500 flagged in input data
3602
3600
test042 --- blfunc='variable', spw to flag channels 4500-6499
3603
3601
test050 --- blmode='apply'
3604
3602
test051 --- blmode='apply', channels 4500~6500 flagged in input data
3605
3603
test052 --- blmode='apply', spw to flag channels 4500-6499
3606
-
3607
3604
test060 --- confirm that the clipping result (mask) is correctly used to compute weights
3608
3605
"""
3609
3606
3610
3607
datapath = ctsys_resolve('unittest/sdbaseline/')
3611
3608
infile = 'analytic_order3_withoffset.ms'
3612
3609
outroot = sdbaseline_unittest_base.taskname + '_updateweighttest'
3613
3610
outfile = outroot + '.ms'
3614
3611
spw = '*:0~4499;6500~8191'
3615
3612
params = {'infile': infile, 'outfile': outfile,
3616
3613
'intent': 'OBSERVE_TARGET#ON_SOURCE',