Source
1
1
import contextlib
2
+
import copy
2
3
import csv
3
4
import filecmp
4
5
import glob
5
6
import os
6
7
import shutil
7
8
import unittest
8
9
9
10
import numpy as np
10
11
from casatasks import casalog, sdbaseline
11
12
from casatasks.private.sdutil import table_manager
3603
3604
test051 : blmode='apply', channels 4500~6500 flagged in input data
3604
3605
test052 : blmode='apply', spw to flag channels 4500-6499
3605
3606
test060 : confirm that the clipping result (mask) is correctly used to compute weights
3606
3607
"""
3607
3608
3608
3609
datapath = ctsys_resolve('unittest/sdbaseline/')
3609
3610
infile = 'analytic_order3_withoffset.ms'
3610
3611
outroot = sdbaseline_unittest_base.taskname + '_updateweighttest'
3611
3612
outfile = outroot + '.ms'
3612
3613
spw = '*:0~4499;6500~8191'
3614
+
"""
3613
3615
params = {'infile': infile, 'outfile': outfile,
3614
3616
'intent': 'OBSERVE_TARGET#ON_SOURCE',
3615
3617
'datacolumn': 'float_data'}
3618
+
"""
3619
+
params_base = {'infile': infile,
3620
+
'outfile': outfile,
3621
+
'intent': 'OBSERVE_TARGET#ON_SOURCE',
3622
+
'datacolumn': 'float_data',
3623
+
'updateweight': True}
3616
3624
3617
3625
def setUp(self):
3618
-
self.init_params()
3619
3626
remove_files_dirs(self.infile)
3620
3627
shutil.copytree(os.path.join(self.datapath, self.infile), self.infile)
3628
+
self.params = copy.deepcopy(self.params_base)
3621
3629
3622
3630
def tearDown(self):
3623
3631
remove_files_dirs(self.infile)
3624
3632
remove_files_dirs(self.outroot)
3625
3633
3626
-
def init_params(self):
3627
-
self.params['updateweight'] = True
3628
-
for key in ['sigmavalue', 'spw',
3629
-
'blmode', 'blformat', 'bloutput',
3630
-
'bltable', 'blfunc', 'blparam']:
3631
-
if key in self.params:
3632
-
del self.params[key]
3633
-
3634
3634
def _check_weight_identical(self):
3635
3635
with table_manager(self.infile) as tb:
3636
3636
wgt_in = tb.getcol('WEIGHT')
3637
3637
with table_manager(self.outfile) as tb:
3638
3638
wgt_out = tb.getcol('WEIGHT')
3639
3639
self.assertTrue(np.array_equal(wgt_in, wgt_out),
3640
3640
msg='WEIGHT column is unexpectedly updated!')
3641
3641
3642
3642
def _check_weight_values(self, sigmavalue='stddev'):
3643
3643
"""