def test_mms_spw_selection3(self): '''mstransform: Create MMS and select three spws with numsubms=2''' self.outputms = '3cspw012.mms' mstransform(vis=self.vis, outputvis=self.outputms, datacolumn='data', spw='0,1,2', createmms=True, separationaxis='spw', numsubms=2) # Verify the input versus the output msmdt = msmdtool() msmdt.open(self.outputms) out_dds = msmdt.datadescids() out_nrow = msmdt.nrows() msmdt.done() self.assertTrue(out_nrow,5200) ref = [0,1,2,3] for i in out_dds: self.assertEqual(out_dds[i], ref[i]) # Verify that DATA_DESCRIPTION table is properly re-indexed. spw_col = th.getVarCol(self.outputms+'/DATA_DESCRIPTION', 'SPECTRAL_WINDOW_ID') self.assertEqual(spw_col.keys().__len__(), 4, 'Wrong number of rows in DD table') self.assertEqual(spw_col['r1'][0], 0,'Error re-indexing SPECTRAL_WINDOW_ID of DATA_DESCRIPTION table') self.assertEqual(spw_col['r2'][0], 0,'Error re-indexing SPECTRAL_WINDOW_ID of DATA_DESCRIPTION table') self.assertEqual(spw_col['r3'][0], 1,'Error re-indexing SPECTRAL_WINDOW_ID of DATA_DESCRIPTION table') self.assertEqual(spw_col['r4'][0], 2,'Error re-indexing SPECTRAL_WINDOW_ID of DATA_DESCRIPTION table') in_feed_tb = th.getVarCol(self.vis+'/FEED', 'SPECTRAL_WINDOW_ID') out_feed_tb = th.getVarCol(self.outputms+'/FEED', 'SPECTRAL_WINDOW_ID') # Check the FEED table th.compTables(self.vis+'/FEED', self.outputms+'/FEED', ['FOCUS_LENGTH'])
def test1_uvcont_single_spw(self): """Test 1: Extract continuum from one single SPW using uvcontsub""" uvcontsub(vis=self.vis,field = 'N5921*',fitspw='0:4~6;50~59',spw = '0',solint = 'int',fitorder = 0,want_cont = True) compare_cont = testhelper.compTables(self.ref[0],self.vis+".cont",['FLAG_CATEGORY','WEIGHT','SIGMA']) self.assertTrue(compare_cont) compare_contsub = testhelper.compTables(self.ref[1],self.vis+".contsub",['FLAG_CATEGORY','WEIGHT','SIGMA']) self.assertTrue(compare_contsub)
def test16(self): '''Test 16: Test the maxdistm and minnumants parameters''' myvis = self.vis_f os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf '+self.out) rvaldict = wvrgcal(vis="myinput.ms",caltable=self.out, wvrflag=['0', '1'], toffset=0., maxdistm=40., minnumants=2) if self.makeref: os.system('rm -rf newref/'+self.ref[18]) os.system('cp -R '+self.out+' newref/'+self.ref[18]) print rvaldict self.rval = rvaldict['success'] if(self.rval): self.rval = th.compTables(self.ref[18], self.out, ['WEIGHT', 'CPARAM'] # ignore WEIGHT because it is empty ) if(self.rval): tb.open(self.out) a = tb.getcol('ANTENNA1') c = tb.getcol('CPARAM')[0][0] tb.close() i = 1 for i in range(len(a)): if (a[i]==1 and not (c[i]==(1+0j))): self.rval=False print "CPARAM for antenna 1 has value ", c[i], " expected (1+0j)." break self.assertTrue(self.rval)
def test5(self): '''Test 5: wvrgcal4quasar_10s.ms, smooth, segsource False''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf ' + self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, smooth='3s', segsource=False, toffset=0.) print rvaldict self.rval = rvaldict['success'] self.assertTrue(os.path.exists(self.out)) self.assertTrue(os.path.exists(self.out + '_unsmoothed')) smoothcal(vis="myinput.ms", tablein=self.out + '_unsmoothed', caltable=self.out + '_ref', smoothtype='mean', smoothtime=3.) if (self.rval): self.rval = th.compTables( self.out + '_ref', self.out, ['WEIGHT'], # ignore WEIGHT because it is empty 0.01 ) # tolerance 1 % to accomodate differences between Linux and Mac OSX self.assertTrue(self.rval)
def test8(self): '''Test 8: wvrgcal4quasar_10s.ms, tie two times two sources''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf ' + self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, tie=['0,3', '1,2'], toffset=0.) if self.makeref: os.system('rm -rf newref/' + self.ref[12]) os.system('cp -R ' + self.out + ' newref/' + self.ref[12]) print rvaldict self.rval = rvaldict['success'] if (self.rval): self.rval = th.compTables( self.ref[12], self.out, ['WEIGHT'], 0.01) # ignore WEIGHT because it is empty, # increase tolerance to 1 % to temporarily # overcome difference between 32bit and 64bit output self.assertTrue(self.rval)
def test19(self): '''Test 19: wvrgcal4quasar_10s.ms, PM02 partially flagged in main table, DV41 with wvrflag, PM02 necessary for interpol of DV41''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf ' + self.out) flagdata(vis='myinput.ms', mode='manual', antenna='PM02&&*', scan='3') rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, wvrflag='DA41', toffset=-1., mingoodfrac=0.2) if self.makeref: os.system('rm -rf newref/' + self.ref[19]) os.system('cp -R ' + self.out + ' newref/' + self.ref[19]) print rvaldict self.rval = rvaldict['success'] if (self.rval): self.rval = th.compTables( self.ref[19], self.out, ['WEIGHT']) # ignore WEIGHT because it is empty self.assertTrue(self.rval)
def test_default(self): '''Partition: create an MMS with default values''' partition(vis=self.msfile, outputvis=self.mmsfile) time.sleep(10) self.assertTrue(os.path.exists(self.mmsfile), 'MMS was not created for this test') # Take the dictionary and compare with original MS thisdict = listpartition(vis=self.mmsfile, createdict=True) # Compare nrows of all scans slist = ph.getMMSScans(thisdict) for s in slist: mmsN = ph.getMMSScanNrows(thisdict, s) msN = ph.getScanNrows(self.msfile, s) self.assertEqual( mmsN, msN, 'Nrows in scan=%s differs: mms_nrows=%s <--> ms_nrows=%s' % (s, mmsN, msN)) # Compare spw IDs for s in slist: mms_spw = ph.getSpwIds(self.mmsfile, s) ms_spw = ph.getSpwIds(self.msfile, s) self.assertEqual(mms_spw, ms_spw, 'list of spws in scan=%s differs: '\ 'mms_spw=%s <--> ms_spw=%s' %(s, mmsN, msN)) # TO DO: Compare both table using compTables when sorting in partition is fixed self.assertTrue( th.compTables(self.msfile, self.mmsfile, [ 'FLAG', 'FLAG_CATEGORY', 'TIME_CENTROID', 'WEIGHT_SPECTRUM', 'DATA' ]))
def test_nomms(self): '''Partition: Create a normal MS with createmms=False''' partition(vis=self.msfile, outputvis=self.mmsfile, createmms=False) self.assertTrue(os.path.exists(self.mmsfile), 'MMS was not created for this test') # Sort the output MSs so that they can be compared myms = mstool() myms.open(self.msfile) myms.sort('ms_sorted.ms', [ 'OBSERVATION_ID', 'ARRAY_ID', 'SCAN_NUMBER', 'FIELD_ID', 'DATA_DESC_ID', 'ANTENNA1', 'ANTENNA2', 'TIME' ]) myms.done() myms.open(self.mmsfile) myms.sort('mms_sorted.ms', [ 'OBSERVATION_ID', 'ARRAY_ID', 'SCAN_NUMBER', 'FIELD_ID', 'DATA_DESC_ID', 'ANTENNA1', 'ANTENNA2', 'TIME' ]) myms.done() # Compare both tables. Ignore the DATA column and compare it in next line self.assertTrue( th.compTables( 'ms_sorted.ms', 'mms_sorted.ms', ['FLAG_CATEGORY', 'FLAG', 'WEIGHT_SPECTRUM', 'DATA'])) # Compare the DATA column self.assertTrue( th.compVarColTables('ms_sorted.ms', 'mms_sorted.ms', 'DATA'))
def test2(self): '''Test 2: Testing with a multi-source dataset''' myvis = self.vis_f os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf '+self.out) rvaldict = wvrgcal(vis="myinput.ms",caltable=self.out, wvrflag=['0', '1'], toffset=0.) if self.makeref: os.system('rm -rf newref/'+self.ref[1]) os.system('cp -R '+self.out+' newref/'+self.ref[1]) print rvaldict self.rval = rvaldict['success'] if(self.rval): self.rval = th.compTables(self.ref[1], self.out, ['WEIGHT'] # ignore WEIGHT because it is empty ## ['TIME', ## 'FIELD_ID', ## 'SPECTRAL_WINDOW_ID', ## 'ANTENNA1', ## 'ANTENNA2', ## 'INTERVAL', ## 'SCAN_NUMBER', ## 'CPARAM', ## 'PARAMERR', ## 'FLAG', ## 'SNR', ## 'WEIGHT'] ) self.assertTrue(self.rval)
def test_default(self): '''Partition: create an MMS with default values''' partition(vis=self.msfile, outputvis=self.mmsfile) time.sleep(10) self.assertTrue(os.path.exists(self.mmsfile), 'MMS was not created for this test') # Take the dictionary and compare with original MS thisdict = listpartition(vis=self.mmsfile, createdict=True) # Compare nrows of all scans slist = ph.getMMSScans(thisdict) for s in slist: mmsN = ph.getMMSScanNrows(thisdict, s) msN = ph.getScanNrows(self.msfile, s) self.assertEqual(mmsN, msN, 'Nrows in scan=%s differs: mms_nrows=%s <--> ms_nrows=%s' %(s, mmsN, msN)) # Compare spw IDs for s in slist: mms_spw = ph.getSpwIds(self.mmsfile, s) ms_spw = ph.getSpwIds(self.msfile, s) self.assertEqual(mms_spw, ms_spw, 'list of spws in scan=%s differs: '\ 'mms_spw=%s <--> ms_spw=%s' %(s, mmsN, msN)) # TO DO: Compare both table using compTables when sorting in partition is fixed self.assertTrue(th.compTables(self.msfile, self.mmsfile, ['FLAG','FLAG_CATEGORY','TIME_CENTROID', 'WEIGHT_SPECTRUM','DATA']))
def test_nomms(self): """Partition: Create a normal MS with createmms=False""" partition(vis=self.msfile, outputvis=self.mmsfile, createmms=False) self.assertTrue(os.path.exists(self.mmsfile), "MMS was not created for this test") # Sort the output MSs so that they can be compared myms = mstool() myms.open(self.msfile) myms.sort( "ms_sorted.ms", ["OBSERVATION_ID", "ARRAY_ID", "SCAN_NUMBER", "FIELD_ID", "DATA_DESC_ID", "ANTENNA1", "ANTENNA2", "TIME"], ) myms.done() myms.open(self.mmsfile) myms.sort( "mms_sorted.ms", ["OBSERVATION_ID", "ARRAY_ID", "SCAN_NUMBER", "FIELD_ID", "DATA_DESC_ID", "ANTENNA1", "ANTENNA2", "TIME"], ) myms.done() # Compare both tables. Ignore the DATA column and compare it in next line self.assertTrue( th.compTables("ms_sorted.ms", "mms_sorted.ms", ["FLAG_CATEGORY", "FLAG", "WEIGHT_SPECTRUM", "DATA"]) ) # Compare the DATA column self.assertTrue(th.compVarColTables("ms_sorted.ms", "mms_sorted.ms", "DATA"))
def tmp_disabled_test_antpos_auto_web_srv_REST_alma(self): """ gencal: auto gencal using data from TCMDB Positions service (ALMA) """ import urllib2 out_caltable = 'ant_pos_web_srv.cal' try: # This will import the required libraries, urllib2, suds, etc. # Coul also use additional parameters: antenna='', parameter='' gencal(vis=self.ALMA_MS, caltable=out_caltable, caltype=self.CAL_TYPE) except urllib2.URLError: print('Connection/network error while querying the ALMA TCMDB Positions web' 'service') raise self.assertTrue(os.path.exists(out_caltable), "The output cal table should have been created: {0}". format(out_caltable)) # Compare against ref file self.assertTrue(th.compTables(out_caltable, self.REF_CALTABLE_AUTO, self.IGNORE_COLS)) self.remove_caltable(out_caltable)
def test_antpos_auto_evla(self): """ gencal: test automated antenna position correction """ # check if the URL is reachable import urllib2 # current EVLA baseline correction URL evlabslncorrURL="http://www.vla.nrao.edu/cgi-bin/evlais_blines.cgi?Year=" try: urlaccess=urllib2.urlopen(evlabslncorrURL+"2010", timeout=30.0) gencal(vis=self.msfile, caltable=self.caltable, caltype='antpos', antenna='', parameter='') self.assertTrue(os.path.exists(self.caltable)) # ToDo: check for generated caltable # Compare with reference file from the repository reference = self.reffile2 self.assertTrue(th.compTables(self.caltable, reference, ['WEIGHT','OBSERVATION_ID'])) except urllib2.URLError, err: print "Cannot access %s , skip this test" % evlabslncorrURL self.res=True
def test_MMS1(self): '''mstransform: input MMS should be the same as output MMS''' # Create an MMS in the setup self.createMMS(self.vis, axis='scan', spws='0,1') # Create another MS and compare. They should be the same self.outputms = 'thesame.mms' mstransform(vis=self.testmms, outputvis=self.outputms, datacolumn='data') self.assertTrue(ParallelDataHelper.isParallelMS(self.outputms),'Output is not an MMS') # Sort the MSs so that they can be compared myms = mstool() myms.open(self.testmms) myms.sort('input_sorted.ms',['OBSERVATION_ID','ARRAY_ID','SCAN_NUMBER','FIELD_ID','DATA_DESC_ID','ANTENNA1','ANTENNA2','TIME']) myms.done() myms.open(self.outputms) myms.sort('output_sorted.ms',['OBSERVATION_ID','ARRAY_ID','SCAN_NUMBER','FIELD_ID','DATA_DESC_ID','ANTENNA1','ANTENNA2','TIME']) myms.done() # Compare both tables. Ignore the DATA column and compare it in next line self.assertTrue(th.compTables('input_sorted.ms','output_sorted.ms', ['FLAG_CATEGORY','FLAG','WEIGHT_SPECTRUM','SIGMA_SPECTRUM','DATA'])) # Compare the DATA column self.assertTrue(th.compVarColTables('input_sorted.ms','output_sorted.ms','DATA')) # The separation axis should be copied to the output MMS in_sepaxis = ph.axisType(self.testmms) out_sepaxis = ph.axisType(self.outputms) self.assertEqual(in_sepaxis, out_sepaxis, 'AxisTypes from input and output MMS do not match')
def test_antpos_auto(self): """ gencal: test automated antenna position correction """ # check if the URL is reachable import urllib2 # current EVLA baseline correction URL evlabslncorrURL="http://www.vla.nrao.edu/cgi-bin/evlais_blines.cgi?Year=" try: urlaccess=urllib2.urlopen(evlabslncorrURL+"2010") gencal(vis=self.msfile, caltable=self.caltable, caltype='antpos', antenna='', parameter='') self.assertTrue(os.path.exists(self.caltable)) # ToDo: check for generated caltable # Compare with reference file from the repository reference = self.reffile2 self.assertTrue(th.compTables(self.caltable, reference, ['WEIGHT','OBSERVATION_ID'])) except urllib2.URLError, err: print "Cannot access %s , skip this test" % evlabslncorrURL self.res=True
def test1_applycal_fluxscale_gcal_bcal(self): """Test 1: Apply calibration using fluxscal gcal and bcal tables""" # Repository caltables are pre-v4.1, and we # must update them _before_ applycal to avoid contention casalog.post("Updating pre-v4.1 caltables: %s" % str(self.aux),"WARN","test1_applycal_fluxscale_gcal_bcal") cblocal = cbtool() for oldct in self.aux: cblocal.updatecaltable(oldct) casalog.post("Pre-v4.1 caltables updated","INFO","test1_applycal_fluxscale_gcal_bcal") # Run applycal in MS mode applycal(vis=self.ref,field='',spw='',selectdata=False,gaintable=self.aux, gainfield=['nearest','nearest','0'], interp=['linear', 'linear','nearest'],spwmap=[]) # Run applycal in MMS mode applycal(vis=self.vis,field='',spw='',selectdata=False,gaintable=self.aux, gainfield=['nearest','nearest','0'], interp=['linear', 'linear','nearest'],spwmap=[]) # Sort file to properly match rows for comparison casalog.post("Sorting vis file: %s" % str(self.vis),"INFO","test1_applycal_fluxscale_gcal_bcal") sortFile(self.vis,self.vis_sorted) casalog.post("Sorting ref file: %s" % str(self.ref),"INFO","test1_applycal_fluxscale_gcal_bcal") sortFile(self.ref,self.ref_sorted) # Compare files compare = testhelper.compTables(self.ref_sorted,self.vis_sorted,['FLAG_CATEGORY']) self.assertTrue(compare)
def test1a(self): '''Gaincal 1a: Default values to create a gain table''' msgcal = self.msfile + '.gcal' reference = self.reffile + '.ref1a.gcal' gaincal(vis=self.msfile, caltable=msgcal) self.assertTrue(os.path.exists(msgcal)) # Compare the calibration table with a reference self.assertTrue(th.compTables(msgcal, reference, ['WEIGHT']))
def test_default_scan(self): '''Partition: create an MMS with default values and axis=scan''' partition(vis=self.msfile, outputvis=self.mmsfile, separationaxis='scan') self.assertTrue(os.path.exists(self.mmsfile), 'MMS was not created for this test') # Take the dictionary and compare with original MS thisdict = listpartition(vis=self.mmsfile, createdict=True) # Compare nrows of all scans slist = ph.getMMSScans(thisdict) for s in slist: mmsN = ph.getMMSScanNrows(thisdict, s) msN = ph.getScanNrows(self.msfile, s) self.assertEqual( mmsN, msN, 'Nrows in scan=%s differs: mms_nrows=%s <--> ms_nrows=%s' % (s, mmsN, msN)) # Compare spw IDs for s in slist: mms_spw = ph.getSpwIds(self.mmsfile, s) ms_spw = ph.getSpwIds(self.msfile, s) self.assertEqual(mms_spw, ms_spw, 'list of spws in scan=%s differs: '\ 'mms_spw=%s <--> ms_spw=%s' %(s, mmsN, msN)) # Sort the output MSs so that they can be compared myms = mstool() myms.open(self.msfile) myms.sort('ms_sorted.ms', [ 'OBSERVATION_ID', 'ARRAY_ID', 'SCAN_NUMBER', 'FIELD_ID', 'DATA_DESC_ID', 'ANTENNA1', 'ANTENNA2', 'TIME' ]) myms.done() myms.open(self.mmsfile) myms.sort('mms_sorted.ms', [ 'OBSERVATION_ID', 'ARRAY_ID', 'SCAN_NUMBER', 'FIELD_ID', 'DATA_DESC_ID', 'ANTENNA1', 'ANTENNA2', 'TIME' ]) myms.done() self.assertTrue( th.compTables('ms_sorted.ms', 'mms_sorted.ms', [ 'FLAG', 'FLAG_CATEGORY', 'TIME_CENTROID', 'WEIGHT_SPECTRUM', 'DATA' ])) # Compare the DATA column self.assertTrue( th.compVarColTables('ms_sorted.ms', 'mms_sorted.ms', 'DATA'))
def test2(self): '''Test 2: Testing with a WVR caltable''' os.system('rm -rf '+self.out) self.rval = caltabconvert(vis=self.vis_f, caltabold=self.ref, ptype='complex', caltabnew=self.out) if(self.rval): self.rval = th.compTables(self.ref2, self.out,['WEIGHT','SCAN_NUMBER','PARAMERR']) # WEIGHT column is empty self.rval = self.rval and th.compTables(self.ref2+'/ANTENNA', self.out+'/ANTENNA', []) self.rval = self.rval and th.compTables(self.ref2+'/FIELD', self.out+'/FIELD', []) self.rval = self.rval and th.compTables(self.ref2+'/SPECTRAL_WINDOW', self.out+'/SPECTRAL_WINDOW', ['CHAN_FREQ']) self.assertTrue(self.rval)
def test1a(self): '''Bandpass 1a: Create bandpass table using field=0''' msbcal = self.msfile + '.bcal' reference = self.reffile + '.ref1a.bcal' bandpass(vis=self.msfile, caltable=msbcal, field='0',bandtype='B', solint='inf',combine='scan',refant='VA15') self.assertTrue(os.path.exists(msbcal)) # Compare the calibration tables self.assertTrue(th.compTables(msbcal, reference, ['WEIGHT']))
def test1b(self): '''Bandpass 1b: Create cal tables for the MS and MMS split by spws''' msbcal = self.msfile + '.bcal' reference = self.reffile + '.ref1b.bcal' bandpass(vis=self.msfile, caltable=msbcal, field='0',spw='0',bandtype='B', solint='inf',combine='scan',refant='ANT5') self.assertTrue(os.path.exists(msbcal)) # Compare the calibration tables self.assertTrue(th.compTables(msbcal, reference, ['WEIGHT']))
def test1b(self): '''Gaincal 1b: Create a gain table for an MS with many spws''' msgcal = self.msfile + '.gcal' reference = self.reffile + '.ref1b.gcal' gaincal(vis=self.msfile, caltable=msgcal, field='0,1',spw='0', gaintype='G',minsnr=2.0, refant='ANT5', solint='inf',combine='') self.assertTrue(os.path.exists(msgcal)) # Compare the calibration tables self.assertTrue(th.compTables(msgcal, reference, ['WEIGHT']))
def test2a(self): '''Gaincal 2a: Create a gain table using field selection''' msgcal = self.msfile + '.field0.gcal' reference = self.reffile + '.ref2a.gcal' gaincal(vis=self.msfile, caltable=msgcal, field='0', gaintype='G',solint='int', combine='',refant='VA02') self.assertTrue(os.path.exists(msgcal)) # Compare the calibration tables self.assertTrue(th.compTables(msgcal, reference, ['WEIGHT']))
def test_flaggedref2(self): '''Fluxscale test3: Ref field 3 in caltable is partially flagged''' # Input gtable = self.gtable2 # Output outtable = self.prefix + '.flagPartFld3.fcal' # torelance for value test tol = 1.e-5 thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1,3,4', transfer='2') self.assertTrue(os.path.exists(outtable)) # File to compare with reference = self.reffile2 # Compare the calibration table with a reference self.assertTrue(th.compTables(outtable, reference, ['WEIGHT'])) # compare some determined values returned in the dict (tested on RHEL6) refdict = { 'freq': np.array([1.41825202e+09]), '2': { 'fitRefFreq': 0.0, 'spidxerr': np.array([0., 0., 0.]), 'spidx': np.array([0., 0., 0.]), '0': { 'fluxdErr': np.array([0.0022236, 0., 0., 0.]), 'numSol': np.array([54., 0., 0., 0.]), 'fluxd': np.array([3.19455455, 0., 0., 0.]) }, 'fitFluxd': 0.0, 'fieldName': '0841+708', 'fitFluxdErr': 0.0 }, 'spwName': np.array(['127*24.4 kHz channels @ 1.42 GHz (BARY)'], dtype='|S40'), 'spwID': np.array([0], dtype=np.int32) } diff_fluxd = abs(refdict['2']['0']['fluxd'][0] - thisdict['2']['0'] ['fluxd'][0]) / refdict['2']['0']['fluxd'][0] self.assertTrue(diff_fluxd < tol)
def test_default(self): '''Fluxscale test 1.1: Create a flux table using field=0 as reference''' # Input gtable = self.gtable # Output outtable = self.msfile + '.fcal' thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*', transfer='1445*') self.assertTrue(os.path.exists(outtable)) # File to compare with reference = self.reffile # Compare the calibration table with a reference self.assertTrue(th.compTables(outtable, reference, ['WEIGHT'])) # compare some determined values returned in the dict #refdict={'1': {'spidxerr': np.array([ 0., 0., 0.]), 'spidx': np.array([ 0., 0., 0.]), \ # 'fluxdErr': np.array([0.00055571]), \ # 'fieldName': '1445+09900002_0', 'numSol': np.array([54]), \ #'fluxd': np.array([0.16825763])}, \ # flux density seems changed a bit. Updated - 2013.01.29 TT # for linux on current trunk 22670 # for OSX 10.6 got the previous value # 'fluxd': np.array([0.16825765])}, \ # 'freq': np.array([1.41266507e+09]), \ # 'spwName': np.array(['none'], dtype='|S5'), \ # 'spwID': np.array([0])} # new returned dictionary (2013.09.12 TT) refdict={'1': {'fitRefFreq': 0.0, 'spidxerr': np.array([ 0., 0., 0.]), 'spidx': np.array([ 0., 0., 0.]), '0': {'fluxdErr': np.array([ 0.00055574, 0. , 0. , 0. ]), 'numSol': np.array([ 54., 0., 0., 0.]), 'fluxd': np.array([ 0.16825768, 0. , 0. , 0. ])}, 'fitFluxd': 0.0, 'fieldName': '1445+09900002_0', 'fitFluxdErr': 0.0}, 'freq': np.array([ 1.41266507e+09]), 'spwName': np.array(['none'],dtype='|S5'), 'spwID': np.array([0], dtype=np.int32)} diff_fluxd=abs(refdict['1']['0']['fluxd'][0]-thisdict['1']['0']['fluxd'][0])/refdict['1']['0']['fluxd'][0] #self.assertTrue(diff_fluxd<1.5e-8) # increase the tolerance level self.assertTrue(diff_fluxd<1e-5)
def test_nomms(self): '''Partition: Create a normal MS with createmms=False''' partition(vis=self.msfile, outputvis=self.mmsfile, createmms=False) time.sleep(10) self.assertTrue(os.path.exists(self.mmsfile), 'MMS was not created for this test') # Compare both tables. Ignore the DATA column and compare it in next line self.assertTrue(th.compTables(self.msfile, self.mmsfile, ['FLAG_CATEGORY','FLAG','WEIGHT_SPECTRUM','DATA'])) # Compare the DATA column self.assertTrue(th.compVarColTables(self.msfile,self.mmsfile,'DATA'))
def test_default_scan(self): """Partition: create an MMS with default values and axis=scan""" partition(vis=self.msfile, outputvis=self.mmsfile, separationaxis="scan") self.assertTrue(os.path.exists(self.mmsfile), "MMS was not created for this test") # Take the dictionary and compare with original MS thisdict = listpartition(vis=self.mmsfile, createdict=True) # Compare nrows of all scans slist = ph.getMMSScans(thisdict) for s in slist: mmsN = ph.getMMSScanNrows(thisdict, s) msN = ph.getScanNrows(self.msfile, s) self.assertEqual(mmsN, msN, "Nrows in scan=%s differs: mms_nrows=%s <--> ms_nrows=%s" % (s, mmsN, msN)) # Compare spw IDs for s in slist: mms_spw = ph.getSpwIds(self.mmsfile, s) ms_spw = ph.getSpwIds(self.msfile, s) self.assertEqual( mms_spw, ms_spw, "list of spws in scan=%s differs: " "mms_spw=%s <--> ms_spw=%s" % (s, mmsN, msN) ) # Sort the output MSs so that they can be compared myms = mstool() myms.open(self.msfile) myms.sort( "ms_sorted.ms", ["OBSERVATION_ID", "ARRAY_ID", "SCAN_NUMBER", "FIELD_ID", "DATA_DESC_ID", "ANTENNA1", "ANTENNA2", "TIME"], ) myms.done() myms.open(self.mmsfile) myms.sort( "mms_sorted.ms", ["OBSERVATION_ID", "ARRAY_ID", "SCAN_NUMBER", "FIELD_ID", "DATA_DESC_ID", "ANTENNA1", "ANTENNA2", "TIME"], ) myms.done() self.assertTrue( th.compTables( "ms_sorted.ms", "mms_sorted.ms", ["FLAG", "FLAG_CATEGORY", "TIME_CENTROID", "WEIGHT_SPECTRUM", "DATA"] ) ) # Compare the DATA column self.assertTrue(th.compVarColTables("ms_sorted.ms", "mms_sorted.ms", "DATA"))
def test2(self): '''Test 2: Testing with a WVR caltable''' os.system('rm -rf ' + self.out) self.rval = caltabconvert(vis=self.vis_f, caltabold=self.ref, ptype='complex', caltabnew=self.out) if (self.rval): self.rval = th.compTables(self.ref2, self.out, ['WEIGHT', 'SCAN_NUMBER', 'PARAMERR' ]) # WEIGHT column is empty self.rval = self.rval and th.compTables(self.ref2 + '/ANTENNA', self.out + '/ANTENNA', []) self.rval = self.rval and th.compTables(self.ref2 + '/FIELD', self.out + '/FIELD', []) self.rval = self.rval and th.compTables( self.ref2 + '/SPECTRAL_WINDOW', self.out + '/SPECTRAL_WINDOW', ['CHAN_FREQ']) self.assertTrue(self.rval)
def test_nomms(self): '''Partition: Create a normal MS with createmms=False''' partition(vis=self.msfile, outputvis=self.mmsfile, createmms=False) time.sleep(10) self.assertTrue(os.path.exists(self.mmsfile), 'MMS was not created for this test') # Compare both tables. Ignore the DATA column and compare it in next line self.assertTrue( th.compTables( self.msfile, self.mmsfile, ['FLAG_CATEGORY', 'FLAG', 'WEIGHT_SPECTRUM', 'DATA'])) # Compare the DATA column self.assertTrue(th.compVarColTables(self.msfile, self.mmsfile, 'DATA'))
def test_antpos_manual(self): """ gencal: test manual antenna position correction """ gencal(vis=self.msfile, caltable=self.caltable, caltype='antpos', antenna='ea12,ea22', parameter=[-0.0072,0.0045,-0.0017, -0.0220,0.0040,-0.0190]) self.assertTrue(os.path.exists(self.caltable)) # ToDo:check generated caltable. Wait for new caltable # Compare with reference file from the repository reference = self.reffile1 self.assertTrue(th.compTables(self.caltable, reference, ['WEIGHT','OBSERVATION_ID']))
def test_incremental(self): '''Fluxscale test 1.2: Create an incremental flux table using field=0 as reference''' # Input gtable = self.gtable # Output outtable = self.msfile + '.inc.fcal' thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1331*', transfer='1445*', incremental=True) self.assertTrue(os.path.exists(outtable)) # File to compare with reference = self.reffile2 # Compare the calibration table with a reference self.assertTrue(th.compTables(outtable, reference, ['WEIGHT']))
def test12(self): '''Test 12: wvrgcal4quasar_10s.ms, disperse''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf '+self.out) rvaldict = wvrgcal(vis="myinput.ms",caltable=self.out, disperse=True, toffset=-1.) if self.makeref: os.system('rm -rf newref/'+self.ref[17]) os.system('cp -R '+self.out+' newref/'+self.ref[17]) print rvaldict self.rval = rvaldict['success'] if(self.rval): self.rval = th.compTables(self.ref[17], self.out, ['WEIGHT']) # ignore WEIGHT because it is empty self.assertTrue(self.rval)
def test9(self): '''Test 9: wvrgcal4quasar_10s.ms, sourceflag two sources''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf '+self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, sourceflag=['0455-462','0132-169'], toffset=0.) if self.makeref: os.system('rm -rf newref/'+self.ref[14]) os.system('cp -R '+self.out+' newref/'+self.ref[14]) print rvaldict self.rval = rvaldict['success'] if(self.rval): self.rval = th.compTables(self.ref[14], self.out, ['WEIGHT']) # ignore WEIGHT because it is empty self.assertTrue(self.rval)
def test10(self): '''Test 10: wvrgcal4quasar_10s.ms, statsource, segsource=False''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf '+self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, segsource=False, statsource='0455-462', toffset=0.) if self.makeref: os.system('rm -rf newref/'+self.ref[15]) os.system('cp -R '+self.out+' newref/'+self.ref[15]) print rvaldict self.rval = rvaldict['success'] if(self.rval): self.rval = th.compTables(self.ref[15], self.out, ['WEIGHT']) # ignore WEIGHT because it is empty self.assertTrue(self.rval)
def test7(self): '''Test 7: wvrgcal4quasar_10s.ms, tie three sources''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf '+self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, tie=['0,1,2'], toffset=0.) if self.makeref: os.system('rm -rf newref/'+self.ref[11]) os.system('cp -R '+self.out+' newref/'+self.ref[11]) print rvaldict self.rval = rvaldict['success'] if(self.rval): self.rval = th.compTables(self.ref[11], self.out, ['WEIGHT']) # ignore WEIGHT because it is empty self.assertTrue(self.rval)
def test_default_scan(self): '''Partition: create an MMS with default values and axis=scan''' partition(vis=self.msfile, outputvis=self.mmsfile, separationaxis='scan') self.assertTrue(os.path.exists(self.mmsfile), 'MMS was not created for this test') # Take the dictionary and compare with original MS thisdict = listpartition(vis=self.mmsfile, createdict=True) # Compare nrows of all scans slist = ph.getMMSScans(thisdict) for s in slist: mmsN = ph.getMMSScanNrows(thisdict, s) msN = ph.getScanNrows(self.msfile, s) self.assertEqual(mmsN, msN, 'Nrows in scan=%s differs: mms_nrows=%s <--> ms_nrows=%s' %(s, mmsN, msN)) # Compare spw IDs for s in slist: mms_spw = ph.getSpwIds(self.mmsfile, s) ms_spw = ph.getSpwIds(self.msfile, s) self.assertEqual(mms_spw, ms_spw, 'list of spws in scan=%s differs: '\ 'mms_spw=%s <--> ms_spw=%s' %(s, mmsN, msN)) # Sort the output MSs so that they can be compared myms = mstool() myms.open(self.msfile) myms.sort('ms_sorted.ms',['OBSERVATION_ID','ARRAY_ID','SCAN_NUMBER','FIELD_ID','DATA_DESC_ID','ANTENNA1','ANTENNA2','TIME']) myms.done() myms.open(self.mmsfile) myms.sort('mms_sorted.ms',['OBSERVATION_ID','ARRAY_ID','SCAN_NUMBER','FIELD_ID','DATA_DESC_ID','ANTENNA1','ANTENNA2','TIME']) myms.done() self.assertTrue(th.compTables('ms_sorted.ms', 'mms_sorted.ms', ['FLAG','FLAG_CATEGORY','TIME_CENTROID', 'WEIGHT_SPECTRUM','DATA'])) # Compare the DATA column self.assertTrue(th.compVarColTables('ms_sorted.ms','mms_sorted.ms','DATA'))
def test8(self): '''Test 8: wvrgcal4quasar_10s.ms, tie two times two sources''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf '+self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, tie=['0,3', '1,2'], toffset=0.) if self.makeref: os.system('rm -rf newref/'+self.ref[12]) os.system('cp -R '+self.out+' newref/'+self.ref[12]) print rvaldict self.rval = rvaldict['success'] if(self.rval): self.rval = th.compTables(self.ref[12], self.out, ['WEIGHT'], 0.01) # ignore WEIGHT because it is empty, # increase tolerance to 1 % to temporarily # overcome difference between 32bit and 64bit output self.assertTrue(self.rval)
def test_antpos_alma_manual(self): """ gencal: manual antenna position correction on ALMA table """ out_caltable = 'ant_pos_man.cal' gencal(vis=self.ALMA_MS, caltable=out_caltable, caltype=self.CAL_TYPE, antenna='DV07,DV10,DV11', parameter=[-0.0072,0.0045,-0.0017, -0.0220,0.0040,-0.0190]) self.assertTrue(os.path.exists(out_caltable), "The output cal table should have been created") # Compare against ref file self.assertTrue(th.compTables(out_caltable, self.REF_CALTABLE_MANUAL, self.IGNORE_COLS)) self.remove_caltable(out_caltable)
def test16(self): '''Test 16: Test the maxdistm and minnumants parameters''' myvis = self.vis_f os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf ' + self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, wvrflag=['0', '1'], toffset=0., maxdistm=40., minnumants=2) if self.makeref: os.system('rm -rf newref/' + self.ref[18]) os.system('cp -R ' + self.out + ' newref/' + self.ref[18]) print rvaldict self.rval = rvaldict['success'] if (self.rval): self.rval = th.compTables( self.ref[18], self.out, ['WEIGHT', 'CPARAM'] # ignore WEIGHT because it is empty ) if (self.rval): tb.open(self.out) a = tb.getcol('ANTENNA1') c = tb.getcol('CPARAM')[0][0] tb.close() i = 1 for i in range(len(a)): if (a[i] == 1 and not (c[i] == (1 + 0j))): self.rval = False print "CPARAM for antenna 1 has value ", c[ i], " expected (1+0j)." break self.assertTrue(self.rval)
def test1_applycal_fluxscale_gcal_bcal(self): """Test 1: Apply calibration using fluxscal gcal and bcal tables""" # Run applycal in MS mode applycal(vis=self.ref,field='',spw='',selectdata=False,gaintable=self.aux, gainfield=['nearest','nearest','0'], interp=['linear', 'linear','nearest'],spwmap=[]) # Run applycal in MMS mode applycal(vis=self.vis,field='',spw='',selectdata=False,gaintable=self.aux, gainfield=['nearest','nearest','0'], interp=['linear', 'linear','nearest'],spwmap=[]) # Sort file to properly match rows for comparison casalog.post("Sorting vis file: %s" % str(self.vis),"INFO","test1_applycal_fluxscale_gcal_bcal") sortFile(self.vis,self.vis_sorted) casalog.post("Sorting ref file: %s" % str(self.ref),"INFO","test1_applycal_fluxscale_gcal_bcal") sortFile(self.ref,self.ref_sorted) # Compare files compare = testhelper.compTables(self.ref_sorted,self.vis_sorted,['FLAG_CATEGORY']) self.assertTrue(compare)
def test19(self): '''Test 19: wvrgcal4quasar_10s.ms, PM02 partially flagged in main table, DV41 with wvrflag, PM02 necessary for interpol of DV41''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf '+self.out) flagdata(vis='myinput.ms', mode='manual', antenna='PM02&&*', scan='3') rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, wvrflag='DA41', toffset=-1., mingoodfrac=0.2) if self.makeref: os.system('rm -rf newref/'+self.ref[19]) os.system('cp -R '+self.out+' newref/'+self.ref[19]) print rvaldict self.rval = rvaldict['success'] if(self.rval): self.rval = th.compTables(self.ref[19], self.out, ['WEIGHT']) # ignore WEIGHT because it is empty self.assertTrue(self.rval)
def test5(self): '''Test 5: wvrgcal4quasar_10s.ms, smooth, segsource False''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf '+self.out) rvaldict = wvrgcal(vis="myinput.ms",caltable=self.out, smooth='3s', segsource=False, toffset=0.) print rvaldict self.rval = rvaldict['success'] self.assertTrue(os.path.exists(self.out)) self.assertTrue(os.path.exists(self.out+'_unsmoothed')) smoothcal(vis = "myinput.ms", tablein = self.out+'_unsmoothed', caltable = self.out+'_ref', smoothtype = 'mean', smoothtime = 3.) if(self.rval): self.rval = th.compTables(self.out+'_ref', self.out, ['WEIGHT'], # ignore WEIGHT because it is empty 0.01) # tolerance 1 % to accomodate differences between Linux and Mac OSX self.assertTrue(self.rval)
def test2(self): '''Test 2: Testing with a multi-source dataset''' myvis = self.vis_f os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf ' + self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, wvrflag=['0', '1'], toffset=0.) if self.makeref: os.system('rm -rf newref/' + self.ref[1]) os.system('cp -R ' + self.out + ' newref/' + self.ref[1]) print rvaldict self.rval = rvaldict['success'] if (self.rval): self.rval = th.compTables( self.ref[1], self.out, ['WEIGHT'] # ignore WEIGHT because it is empty ## ['TIME', ## 'FIELD_ID', ## 'SPECTRAL_WINDOW_ID', ## 'ANTENNA1', ## 'ANTENNA2', ## 'INTERVAL', ## 'SCAN_NUMBER', ## 'CPARAM', ## 'PARAMERR', ## 'FLAG', ## 'SNR', ## 'WEIGHT'] ) self.assertTrue(self.rval)
def test7(self): '''Test 7: wvrgcal4quasar_10s.ms, tie three sources''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf ' + self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, tie=['0,1,2'], toffset=0.) if self.makeref: os.system('rm -rf newref/' + self.ref[11]) os.system('cp -R ' + self.out + ' newref/' + self.ref[11]) print rvaldict self.rval = rvaldict['success'] if (self.rval): self.rval = th.compTables( self.ref[11], self.out, ['WEIGHT']) # ignore WEIGHT because it is empty self.assertTrue(self.rval)
def test_nomms(self): '''Partition: Create a normal MS with createmms=False''' partition(vis=self.msfile, outputvis=self.mmsfile, createmms=False) self.assertTrue(os.path.exists(self.mmsfile), 'MMS was not created for this test') # Sort the output MSs so that they can be compared myms = mstool() myms.open(self.msfile) myms.sort('ms_sorted.ms',['OBSERVATION_ID','ARRAY_ID','SCAN_NUMBER','FIELD_ID','DATA_DESC_ID','ANTENNA1','ANTENNA2','TIME']) myms.done() myms.open(self.mmsfile) myms.sort('mms_sorted.ms',['OBSERVATION_ID','ARRAY_ID','SCAN_NUMBER','FIELD_ID','DATA_DESC_ID','ANTENNA1','ANTENNA2','TIME']) myms.done() # Compare both tables. Ignore the DATA column and compare it in next line self.assertTrue(th.compTables('ms_sorted.ms','mms_sorted.ms', ['FLAG_CATEGORY','FLAG','WEIGHT_SPECTRUM','DATA'])) # Compare the DATA column self.assertTrue(th.compVarColTables('ms_sorted.ms','mms_sorted.ms','DATA'))
def test9(self): '''Test 9: wvrgcal4quasar_10s.ms, sourceflag two sources''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf ' + self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, sourceflag=['0455-462', '0132-169'], toffset=0.) if self.makeref: os.system('rm -rf newref/' + self.ref[14]) os.system('cp -R ' + self.out + ' newref/' + self.ref[14]) print rvaldict self.rval = rvaldict['success'] if (self.rval): self.rval = th.compTables( self.ref[14], self.out, ['WEIGHT']) # ignore WEIGHT because it is empty self.assertTrue(self.rval)
def test12(self): '''Test 12: wvrgcal4quasar_10s.ms, disperse''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf ' + self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, disperse=True, toffset=-1.) if self.makeref: os.system('rm -rf newref/' + self.ref[17]) os.system('cp -R ' + self.out + ' newref/' + self.ref[17]) print rvaldict self.rval = rvaldict['success'] if (self.rval): self.rval = th.compTables( self.ref[17], self.out, ['WEIGHT']) # ignore WEIGHT because it is empty self.assertTrue(self.rval)
def test_flaggedref2(self): '''Fluxscale test3: Ref field 3 in caltable is partially flagged''' # Input gtable = self.gtable2 # Output outtable = self.prefix + '.flagPartFld3.fcal' # torelance for value test tol = 1.e-5 thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='1,3,4', transfer='2') self.assertTrue(os.path.exists(outtable)) # File to compare with reference = self.reffile2 # Compare the calibration table with a reference self.assertTrue(th.compTables(outtable, reference, ['WEIGHT'])) # compare some determined values returned in the dict (tested on RHEL6) refdict={'freq': np.array([ 1.41825202e+09]), '2': {'fitRefFreq': 0.0, 'spidxerr': np.array([ 0., 0., 0.]), 'spidx': np.array([ 0., 0., 0.]), '0': {'fluxdErr': np.array([ 0.0022236, 0., 0., 0.]), 'numSol': np.array([ 54., 0., 0., 0.]), 'fluxd': np.array([ 3.19455455, 0., 0., 0.])}, 'fitFluxd': 0.0, 'fieldName': '0841+708', 'fitFluxdErr': 0.0}, 'spwName': np.array(['127*24.4 kHz channels @ 1.42 GHz (BARY)'], dtype='|S40'), 'spwID': np.array([0], dtype=np.int32)} diff_fluxd=abs(refdict['2']['0']['fluxd'][0]-thisdict['2']['0']['fluxd'][0])/refdict['2']['0']['fluxd'][0] self.assertTrue(diff_fluxd<tol)
def test10(self): '''Test 10: wvrgcal4quasar_10s.ms, statsource, segsource=False''' myvis = self.vis_g os.system('cp -R ' + myvis + ' myinput.ms') os.system('rm -rf ' + self.out) rvaldict = wvrgcal(vis="myinput.ms", caltable=self.out, segsource=False, statsource='0455-462', toffset=0.) if self.makeref: os.system('rm -rf newref/' + self.ref[15]) os.system('cp -R ' + self.out + ' newref/' + self.ref[15]) print rvaldict self.rval = rvaldict['success'] if (self.rval): self.rval = th.compTables( self.ref[15], self.out, ['WEIGHT']) # ignore WEIGHT because it is empty self.assertTrue(self.rval)
def test_spws(self): '''Fluxscale 2: Create a fluxscale table for an MS with many spws''' # Input gtable = self.gtable # Output outtable = self.msfile + '.fcal' # torelance for value tests tol = 1.e-5 thisdict = fluxscale(vis=self.msfile, caltable=gtable, fluxtable=outtable, reference='3C273-F0', transfer=['1310+323-F0'],refspwmap=[0,0]) self.assertTrue(os.path.exists(outtable)) # File to compare with reference = self.reffile # Compare the calibration table with a reference self.assertTrue(th.compTables(outtable, reference, ['WEIGHT'])) # compare some determined values returned in the dict #refdict={'1': {'spidxerr': np.array([ 0., 0., 0.]), 'spidx': np.array([ 0., 0., 0.]), \ # 'fluxdErr': np.array([-1. , 0.04080052, -1. , -1. , -1. , -1. ]), \ # 'fieldName': '1310+323-F0', 'numSol': np.array([-1, 8, -1, -1, -1, -1], dtype=np.int32), \ # 'fluxd': np.array([-1. , 1.44578847, -1. , -1. , -1. , -1. ])}, \ # 'freq': np.array([ 1.15138579e+11, 1.15217017e+11, -1.00000000e+00, -1.00000000e+00, -1.00000000e+00, \ # -1.00000000e+00]), 'spwName': np.array(['', '', '', '', '', ''], dtype='|S1'), \ # 'spwID': np.array([0, 1, 2, 3, 4, 5], dtype=np.int32)} # updated for new returned dictionary format (2013.09.12 TT) refdict= {'1': {'fitRefFreq': 0.0, 'spidxerr': np.array([ 0., 0., 0.]), 'fitFluxd': 0.0, 'spidx': np.array([ 0., 0., 0.]), '1': {'fluxdErr': np.array([ 0.04080052, 0. , 0. , 0. ]), 'numSol': np.array([ 8., 0., 0., 0.]), 'fluxd': np.array([ 1.44578847, 0. , 0. , 0. ])}, '0': {'fluxdErr': np.array([-1., -1., -1., -1.]), 'numSol': np.array([-1., -1., -1., -1.]), 'fluxd': np.array([-1., -1., -1., -1.])}, '3': {'fluxdErr': np.array([-1., -1., -1., -1.]), 'numSol': np.array([-1., -1., -1., -1.]), 'fluxd': np.array([-1., -1., -1., -1.])}, '2': {'fluxdErr': np.array([-1., -1., -1., -1.]), 'numSol': np.array([-1., -1., -1., -1.]), 'fluxd': np.array([-1., -1., -1., -1.])}, '5': {'fluxdErr': np.array([-1., -1., -1., -1.]), 'numSol': np.array([-1., -1., -1., -1.]), 'fluxd': np.array([-1., -1., -1., -1.])}, '4': {'fluxdErr': np.array([-1., -1., -1., -1.]), 'numSol': np.array([-1., -1., -1., -1.]), 'fluxd': np.array([-1., -1., -1., -1.])}, 'fieldName': '1310+323-F0', 'fitFluxdErr': 0.0}, 'freq': np.array([ 1.15138579e+11, 1.15217017e+11, -1.00000000e+00, -1.00000000e+00, -1.00000000e+00, -1.00000000e+00]), 'spwName': np.array(['', '', '', '', '', ''], dtype='|S1'), 'spwID': np.array([0, 1, 2, 3, 4, 5], dtype=np.int32)} diff_fluxd=abs(refdict['1']['1']['fluxd'][0]-thisdict['1']['1']['fluxd'][0])/refdict['1']['1']['fluxd'][0] self.assertTrue(diff_fluxd<tol)