############################################################################# # # # Test Name: # # Regression/Benchmarking Script for 3c391 polarization imaging # # # # The script is based on EVLA continuum tutorial on 3c391 to test # # polarization imaging. # # o starting from calibrated MS # # o currently only QU imaging with clarkstokes mode is performed # # mainly to test CAS-2219 fix # # o does multiscale clean # # Reference data: # # o if savecurstats is defined and equal to True, image statistics will # # saved on a pickle file (this can be used to store to the data # # repository as a reference data in future regression run. # # o if pickle file with an appropriate name exist in data directory or # # current working directoy it try to use the file as reference # # otherwise use values stored in this script. # # # ############################################################################# import os import time from numpy import * import shutil import regression_utility as tstutl #------------------------------------- # reg test function def difftest(diffval,tol): if diffval>logfile,'' print >>logfile,'' print >>logfile,'********************************* Data Summary *********************************' print >>logfile,'* ' print >>logfile,'Observation: EVLA' print >>logfile,'Data records: 54582 Total integration time = 2085.5 seconds' print >>logfile,'Observed from 24-Apr-2010/08:24:53.0 to 24-Apr-2010/08:59:38.5 (UTC)' print >>logfile,'ObservationID = 0 ArrayID = 0' print >>logfile,'Date Timerange (UTC) Scan FldId FieldName nVis Int(s) SpwIds' print >>logfile,'24-Apr-2010/08:24:53.0 - 08:29:43.0 5 0 3C391 C1 7590 9.83 [0]' print >>logfile,' 08:29:43.0 - 08:34:43.0 6 1 3C391 C2 7821 9.65 [0]' print >>logfile,' 08:34:43.0 - 08:39:43.0 7 2 3C391 C3 7821 9.66 [0]' print >>logfile,' 08:39:43.0 - 08:44:43.0 8 3 3C391 C4 7821 9.61 [0]' print >>logfile,' 08:44:43.0 - 08:49:43.0 9 4 3C391 C5 7843 9.62 [0]' print >>logfile,' 08:49:43.0 - 08:54:43.0 10 5 3C391 C6 7843 9.58 [0]' print >>logfile,' 08:54:43.0 - 08:59:38.5 11 6 3C391 C7 7843 9.58 [0]' print >>logfile,' (nVis = Total number of time/baseline visibilities per scan)' print >>logfile,'Fields: 7' print >>logfile,' ID Code Name RA Decl Epoch SrcId nVis' print >>logfile,' 0 NONE 3C391 C1 18:49:24.2440 -00.55.40.5800 J2000 0 7590' print >>logfile,' 1 NONE 3C391 C2 18:49:29.1490 -00.57.48.0000 J2000 1 7821' print >>logfile,' 2 NONE 3C391 C3 18:49:19.3390 -00.57.48.0000 J2000 2 7821' print >>logfile,' 3 NONE 3C391 C4 18:49:14.4340 -00.55.40.5800 J2000 3 7821' print >>logfile,' 4 NONE 3C391 C5 18:49:19.3390 -00.53.33.1600 J2000 4 7843' print >>logfile,' 5 NONE 3C391 C6 18:49:29.1490 -00.53.33.1600 J2000 5 7843' print >>logfile,' 6 NONE 3C391 C7 18:49:34.0540 -00.55.40.5800 J2000 6 7843' print >>logfile,' (nVis = Total number of time/baseline visibilities per field)' print >>logfile,'Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)' print >>logfile,' SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs' print >>logfile,' 0 64 TOPO 4536 2000 128000 4536 RR RL LR LL ' print >>logfile,'********************************************************************************' print >>logfile,' ' print >>logfile,'******************************** Regression ************************************' print >>logfile,'* *' print >>logfile,'Q image test' print >>logfile,'Peak flux density: %-10.5g (expected: %-10.5g, frac_diff:%-10.5g) %s' \ % (curstats['qim']['max'][0], refstats['qim']['max'][0],\ tests['qmaxdiff'][1], tests['qmaxdiff'][0]) print >>logfile,'(tolerance=%s)' % tol print >>logfile,'Residual sigma: %-10.5g (expected: %-10.5g, frac_diff:%-10.5g) %s ' \ % (curstats['qres']['sigma'][0], refstats['qres']['sigma'][0],\ tests['qsigdiff'][1],tests['qsigdiff'][0]) print >>logfile,'(tolerance=%s)' % tolres print >>logfile,'------------------------------------------------------------' print >>logfile,'U image test ' print >>logfile,'Peak flux density: %-10.5g (expected: %-10.5g, frac_diff:%-10.5g) %s' \ % (curstats['uim']['max'][0], refstats['uim']['max'][0], \ tests['umaxdiff'][1], tests['umaxdiff'][0]) print >>logfile,'(tolerance=%s)' % tol print >>logfile,'Residual sigma: %-10.5g (expected: %-10.5g, frac_diff:%-10.5g) %s ' \ % (curstats['ures']['sigma'][0], refstats['ures']['sigma'][0],\ tests['usigdiff'][1],tests['usigdiff'][0]) print >>logfile,'(tolerance=%s)' % tolres print >>logfile,' ' print >>logfile,' ** reference data used ** ' print >>logfile, refdataused print >>logfile,' ============================================================================== ' print >>logfile,'Regression %s ' % msg print >>logfile,'* *' print >>logfile,'********************************************************************************' print >>logfile,' ' print >>logfile,'******************** Benchmarking **************************' print >>logfile,'* *' print >>logfile,'Total wall clock time was %13.3f: ' % (endTime - startTime) print >>logfile,'Total CPU time was %13.3f: ' % (endProc - startProc) print >>logfile,'Processing rate MB/s was %13.3f: ' % (329./(endTime - startTime)) print >>logfile,'* *' print >>logfile,'************************************************************' if savelog: logfile.close() # save the regression results (statistics) in pickle # for reference data if savecurstats: datestring=datetime.datetime.isoformat(datetime.datetime.today()) pickfile = '3c391polim.regression.'+datestring+'.pickle' f = open(pickfile,'w') casapath=os.environ['CASAPATH'].split() if os.environ.has_key('HOSTNAME'): hostname=os.environ['HOSTNAME'] elif len(casapath) >3: hostname=casapath[3] else: hostname='unknown' # check the environment that the script is running if casapath[1] =='darwin': # darwin # use sw_vers to get OSX version ? os.system('/usr/bin/sw_vers >/tmp/osxverinfo.txt') fver=open('/tmp/osxverinfo.txt') fver.readline() verinfo=fver.readline().split(':')[1].strip() arch="running on %s (Mac OS X %s)" % (hostname, verinfo) elif pathname.find('lib64')>-1: # 64bit linux arch="running on %s (64bit linux)" % hostname else: # assume 32bit linux arch ="running on %s (32bit linux)" % hostname #Pickling cPickle.dump(arch,f) # stats are stored in this order statslist=['qim','qres','uim','ures'] cPickle.dump(statslist,f) for stats in statslist: cPickle.dump(curstats[stats],f) f.close() # just to be informative if savelog: print "Regression %s: " % msg print "log output: %s" % outfile