def test_corrected_col(self): '''hanningsmooth: Apply smoothing in CORRECTED column''' self.outputms = 'hanncorr.ms' # check correct flagging before (just for one row as a sample) flag_col = th.getVarCol(self.msfile, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [False]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][3838] == [False]) self.assertTrue(flag_col['r1'][0][3839] == [False]) # input column data_col = th.getVarCol(self.msfile, 'CORRECTED_DATA') hanningsmooth(vis=self.msfile, outputvis=self.outputms, datacolumn='corrected') # output smoothed column corr_col = th.getVarCol(self.outputms, 'DATA') nrows = len(corr_col) # check correct flagging after (just for one row as a sample) flag_col = th.getVarCol(self.outputms, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [True]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][3838] == [False]) self.assertTrue(flag_col['r1'][0][3839] == [True]) # Loop over every 2nd row,pol and get the data for each channel max = 1e-04 for i in range(1, nrows, 2): row = 'r%s' % i # polarization is 0-1 for pol in range(0, 2): # array's channels is 0-3840 for chan in range(1, 3839): # channels must start from second and end before the last data = data_col[row][pol][chan] dataB = data_col[row][pol][chan - 1] dataA = data_col[row][pol][chan + 1] Smoothed = th.calculateHanning(dataB, data, dataA) CorData = corr_col[row][pol][chan] # Check the difference self.assertTrue( abs(CorData - Smoothed) < max, 'CorData=%s Smoothed=%s in row=%s pol=%s chan=%s' % (CorData, Smoothed, row, pol, chan))
def test_corrected_col(self): """hanningsmooth: Apply smoothing in CORRECTED column""" self.outputms = "hanncorr.ms" # check correct flagging before (just for one row as a sample) flag_col = th.getVarCol(self.msfile, "FLAG") self.assertTrue(flag_col["r1"][0][0] == [False]) self.assertTrue(flag_col["r1"][0][1] == [False]) self.assertTrue(flag_col["r1"][0][3838] == [False]) self.assertTrue(flag_col["r1"][0][3839] == [False]) # input column data_col = th.getVarCol(self.msfile, "CORRECTED_DATA") hanningsmooth(vis=self.msfile, outputvis=self.outputms, datacolumn="corrected") # output smoothed column corr_col = th.getVarCol(self.outputms, "DATA") nrows = len(corr_col) # check correct flagging after (just for one row as a sample) flag_col = th.getVarCol(self.outputms, "FLAG") self.assertTrue(flag_col["r1"][0][0] == [True]) self.assertTrue(flag_col["r1"][0][1] == [False]) self.assertTrue(flag_col["r1"][0][3838] == [False]) self.assertTrue(flag_col["r1"][0][3839] == [True]) # Loop over every 2nd row,pol and get the data for each channel max = 1e-04 for i in range(1, nrows, 2): row = "r%s" % i # polarization is 0-1 for pol in range(0, 2): # array's channels is 0-3840 for chan in range(1, 3839): # channels must start from second and end before the last data = data_col[row][pol][chan] dataB = data_col[row][pol][chan - 1] dataA = data_col[row][pol][chan + 1] Smoothed = th.calculateHanning(dataB, data, dataA) CorData = corr_col[row][pol][chan] # Check the difference self.assertTrue( abs(CorData - Smoothed) < max, "CorData=%s Smoothed=%s in row=%s pol=%s chan=%s" % (CorData, Smoothed, row, pol, chan), )
def test3(self): '''hanningsmooth - Test 3: Check theoretical and calculated values on non-existing CORRECTED column''' self.outputms = 'hann3.ms' # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.msfile, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [False]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [False]) # It should fall-back and use the input DATA column hanningsmooth(vis=self.msfile, outputvis=self.outputms, datacolumn='corrected') # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.outputms, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [True]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [True]) data_col = th.getVarCol(self.msfile, 'DATA') corr_col = th.getVarCol(self.outputms, 'DATA') nrows = len(corr_col) # Loop over every 2nd row,pol and get the data for each channel max = 1e-05 for i in range(1, nrows, 2): row = 'r%s' % i # polarization is 0-1 for pol in range(0, 2): # array's channels is 0-63 for chan in range(1, 62): # channels must start from second and end before the last data = data_col[row][pol][chan] dataB = data_col[row][pol][chan - 1] dataA = data_col[row][pol][chan + 1] Smoothed = th.calculateHanning(dataB, data, dataA) CorData = corr_col[row][pol][chan] # Check the difference self.assertTrue(abs(CorData - Smoothed) < max)
def test3(self): '''Test 3: Theoretical and calculated values should be the same with datacolumn==CORRECTED''' # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.msfile, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [False]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [False]) self.res = hanningsmooth(vis=self.msfile, datacolumn='corrected') # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.msfile, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [True]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [True]) cd = th.getColDesc(self.msfile, 'CORRECTED_DATA') self.assertTrue(len(cd)) data_col = th.getVarCol(self.msfile, 'DATA') corr_col = th.getVarCol(self.msfile, 'CORRECTED_DATA') nrows = len(corr_col) # Loop over every 2nd row,pol and get the data for each channel max = 1e-05 for i in range(1,nrows,2) : row = 'r%s'%i # polarization is 0-1 for pol in range(0,2) : # array's channels is 0-63 for chan in range(1,62) : # channels must start from second and end before the last data = data_col[row][pol][chan] dataB = data_col[row][pol][chan-1] dataA = data_col[row][pol][chan+1] Smoothed = th.calculateHanning(dataB,data,dataA) CorData = corr_col[row][pol][chan] # Check the difference self.assertTrue(abs(CorData-Smoothed) < max )
def test3(self): '''hanningsmooth2 - Test 3: Check theoretical and calculated values on non-existing CORRECTED column''' self.outputms = 'hann3.ms' # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.msfile, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [False]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [False]) # It should fall-back and use the input DATA column hanningsmooth2(vis=self.msfile, outputvis=self.outputms, datacolumn='corrected') # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.outputms, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [True]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [True]) data_col = th.getVarCol(self.msfile, 'DATA') corr_col = th.getVarCol(self.outputms, 'DATA') nrows = len(corr_col) # Loop over every 2nd row,pol and get the data for each channel max = 1e-05 for i in range(1,nrows,2) : row = 'r%s'%i # polarization is 0-1 for pol in range(0,2) : # array's channels is 0-63 for chan in range(1,62) : # channels must start from second and end before the last data = data_col[row][pol][chan] dataB = data_col[row][pol][chan-1] dataA = data_col[row][pol][chan+1] Smoothed = th.calculateHanning(dataB,data,dataA) CorData = corr_col[row][pol][chan] # Check the difference self.assertTrue(abs(CorData-Smoothed) < max )
def test3(self): '''Test 3: Theoretical and calculated values should be the same with datacolumn==CORRECTED''' # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.msfile, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [False]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [False]) self.res = oldhanningsmooth(vis=self.msfile, datacolumn='corrected') # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.msfile, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [True]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [True]) cd = th.getColDesc(self.msfile, 'CORRECTED_DATA') self.assertTrue(len(cd)) data_col = th.getVarCol(self.msfile, 'DATA') corr_col = th.getVarCol(self.msfile, 'CORRECTED_DATA') nrows = len(corr_col) # Loop over every 2nd row,pol and get the data for each channel max = 1e-05 for i in range(1, nrows, 2): row = 'r%s' % i # polarization is 0-1 for pol in range(0, 2): # array's channels is 0-63 for chan in range(1, 62): # channels must start from second and end before the last data = data_col[row][pol][chan] dataB = data_col[row][pol][chan - 1] dataA = data_col[row][pol][chan + 1] Smoothed = th.calculateHanning(dataB, data, dataA) CorData = corr_col[row][pol][chan] # Check the difference self.assertTrue(abs(CorData - Smoothed) < max)
def test4(self): '''hanningsmooth - Test 4: Theoretical and calculated values should be the same for MMS-case''' # Split the input to decrease the running time split(self.msfile, outputvis='splithan.ms', scan='1,2', datacolumn='data') self.msfile = 'splithan.ms' # create a test MMS. It creates self.testmms self.createMMS(self.msfile) self.outputms = 'hann4.mms' # check correct flagging (just for one row as a sample) mslocal = mstool() mslocal.open(self.msfile) mslocal.sort('sorted.ms', [ 'OBSERVATION_ID', 'ARRAY_ID', 'SCAN_NUMBER', 'FIELD_ID', 'DATA_DESC_ID', 'ANTENNA1', 'ANTENNA2', 'TIME' ]) mslocal.close() self.msfile = 'sorted.ms' flag_col = th.getVarCol(self.msfile, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [False]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [False]) data_col = th.getVarCol(self.msfile, 'DATA') hanningsmooth(vis=self.testmms, outputvis=self.outputms, datacolumn='data', keepmms=True) self.assertTrue(ParallelDataHelper.isParallelMS(self.outputms), 'Output should be an MMS') # Sort the MMS mslocal.open(self.outputms) mslocal.sort('sorted.mms', [ 'OBSERVATION_ID', 'ARRAY_ID', 'SCAN_NUMBER', 'FIELD_ID', 'DATA_DESC_ID', 'ANTENNA1', 'ANTENNA2', 'TIME' ]) mslocal.close() self.outputms = 'sorted.mms' corr_col = th.getVarCol(self.outputms, 'DATA') nrows = len(corr_col) # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.outputms, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [True]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [True]) # Loop over every 2nd row,pol and get the data for each channel max = 1e-05 for i in range(1, nrows, 2): row = 'r%s' % i # polarization is 0-1 for pol in range(0, 2): # array's channels is 0-63 for chan in range(1, 62): # channels must start from second and end before the last data = data_col[row][pol][chan] dataB = data_col[row][pol][chan - 1] dataA = data_col[row][pol][chan + 1] Smoothed = th.calculateHanning(dataB, data, dataA) CorData = corr_col[row][pol][chan] # Check the difference self.assertTrue(abs(CorData - Smoothed) < max)
def test4(self): '''hanningsmooth2 - Test 4: Theoretical and calculated values should be the same for MMS-case''' # Split the input to decrease the running time split2(self.msfile, outputvis='splithan.ms',scan='1,2',datacolumn='data') self.msfile = 'splithan.ms' # create a test MMS. It creates self.testmms self.createMMS(self.msfile) self.outputms = 'hann4.mms' # check correct flagging (just for one row as a sample) mslocal = mstool() mslocal.open(self.msfile) mslocal.sort('sorted.ms',['OBSERVATION_ID','ARRAY_ID','SCAN_NUMBER','FIELD_ID','DATA_DESC_ID','ANTENNA1','ANTENNA2','TIME']) mslocal.close() self.msfile = 'sorted.ms' flag_col = th.getVarCol(self.msfile, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [False]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [False]) data_col = th.getVarCol(self.msfile, 'DATA') hanningsmooth2(vis=self.testmms, outputvis=self.outputms, datacolumn='data', keepmms=True) self.assertTrue(ParallelDataHelper.isParallelMS(self.outputms), 'Output should be an MMS') # Sort the MMS mslocal.open(self.outputms) mslocal.sort('sorted.mms',['OBSERVATION_ID','ARRAY_ID','SCAN_NUMBER','FIELD_ID','DATA_DESC_ID','ANTENNA1','ANTENNA2','TIME']) mslocal.close() self.outputms = 'sorted.mms' corr_col = th.getVarCol(self.outputms, 'DATA') nrows = len(corr_col) # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.outputms, 'FLAG') self.assertTrue(flag_col['r1'][0][0] == [True]) self.assertTrue(flag_col['r1'][0][1] == [False]) self.assertTrue(flag_col['r1'][0][61] == [False]) self.assertTrue(flag_col['r1'][0][62] == [True]) # Loop over every 2nd row,pol and get the data for each channel max = 1e-05 for i in range(1,nrows,2) : row = 'r%s'%i # polarization is 0-1 for pol in range(0,2) : # array's channels is 0-63 for chan in range(1,62) : # channels must start from second and end before the last data = data_col[row][pol][chan] dataB = data_col[row][pol][chan-1] dataA = data_col[row][pol][chan+1] Smoothed = th.calculateHanning(dataB,data,dataA) CorData = corr_col[row][pol][chan] # Check the difference self.assertTrue(abs(CorData-Smoothed) < max )
def test4(self): """hanningsmooth - Test 4: Theoretical and calculated values should be the same for MMS-case""" # Split the input to decrease the running time split(self.msfile, outputvis="splithan.ms", scan="1,2", datacolumn="data") self.msfile = "splithan.ms" # create a test MMS. It creates self.testmms self.createMMS(self.msfile) self.outputms = "hann4.mms" # check correct flagging (just for one row as a sample) mslocal = mstool() mslocal.open(self.msfile) mslocal.sort( "sorted.ms", ["OBSERVATION_ID", "ARRAY_ID", "SCAN_NUMBER", "FIELD_ID", "DATA_DESC_ID", "ANTENNA1", "ANTENNA2", "TIME"], ) mslocal.close() self.msfile = "sorted.ms" flag_col = th.getVarCol(self.msfile, "FLAG") self.assertTrue(flag_col["r1"][0][0] == [False]) self.assertTrue(flag_col["r1"][0][1] == [False]) self.assertTrue(flag_col["r1"][0][61] == [False]) self.assertTrue(flag_col["r1"][0][62] == [False]) data_col = th.getVarCol(self.msfile, "DATA") hanningsmooth(vis=self.testmms, outputvis=self.outputms, datacolumn="data", keepmms=True) self.assertTrue(ParallelDataHelper.isParallelMS(self.outputms), "Output should be an MMS") # Sort the MMS mslocal.open(self.outputms) mslocal.sort( "sorted.mms", ["OBSERVATION_ID", "ARRAY_ID", "SCAN_NUMBER", "FIELD_ID", "DATA_DESC_ID", "ANTENNA1", "ANTENNA2", "TIME"], ) mslocal.close() self.outputms = "sorted.mms" corr_col = th.getVarCol(self.outputms, "DATA") nrows = len(corr_col) # check correct flagging (just for one row as a sample) flag_col = th.getVarCol(self.outputms, "FLAG") self.assertTrue(flag_col["r1"][0][0] == [True]) self.assertTrue(flag_col["r1"][0][1] == [False]) self.assertTrue(flag_col["r1"][0][61] == [False]) self.assertTrue(flag_col["r1"][0][62] == [True]) # Loop over every 2nd row,pol and get the data for each channel max = 1e-05 for i in range(1, nrows, 2): row = "r%s" % i # polarization is 0-1 for pol in range(0, 2): # array's channels is 0-63 for chan in range(1, 62): # channels must start from second and end before the last data = data_col[row][pol][chan] dataB = data_col[row][pol][chan - 1] dataA = data_col[row][pol][chan + 1] Smoothed = th.calculateHanning(dataB, data, dataA) CorData = corr_col[row][pol][chan] # Check the difference self.assertTrue(abs(CorData - Smoothed) < max)