casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
testcompsim.py
Go to the documentation of this file.
00001 startTime = time.time()
00002 startProc = time.clock()
00003 
00004 projname="cltest"
00005 
00006 if os.path.exists(projname): shutil.rmtree(projname)
00007 
00008 l=locals() 
00009 if not l.has_key("repodir"): 
00010     repodir=os.getenv("CASAPATH").split(' ')[0]
00011 
00012 print casa['build']
00013 print 'I think the data repository is at '+repodir
00014 datadir=repodir+"/data/regression/simdata/"
00015 if os.path.exists("6334.cl"): shutil.rmtree("6334.cl")
00016 shutil.copytree(datadir+"6334.cl","6334.cl")
00017 
00018 default("simobserve") 
00019 project            =  projname
00020 complist           =  "6334.cl"
00021 compwidth          =  "1.875GHz"
00022 setpointings       =  True
00023 integration        =  "10s"
00024 direction          =  "J2000 17h20m53.2s -35d47m00s"
00025 mapsize            =  "13arcsec"
00026 maptype            =  "ALMA"
00027 pointingspacing    =  ""
00028 #observe            =  True
00029 obsmode            =  "int"
00030 refdate            =  "2014/01/01"
00031 hourangle          =  "transit"
00032 totaltime          =  "7200s"
00033 antennalist        =  "alma.cycle0.extended.cfg"
00034 thermalnoise       =  ""
00035 
00036 if not l.has_key('interactive'): interactive=False
00037 if interactive:
00038     graphics="both"
00039 else:
00040     graphics="file"
00041 
00042 verbose            =  True
00043 overwrite          =  True
00044 
00045 inp()
00046 simobserve()
00047 
00048 
00049 default("simanalyze") 
00050 project            =  projname
00051 image              =  True
00052 vis                =  "default"
00053 imsize             =  300
00054 imdirection        =  direction
00055 cell               = "0.043294054arcsec"
00056 niter              =  500
00057 threshold          =  "0.1mJy"
00058 analyze            =  True
00059 
00060 if not l.has_key('interactive'): interactive=False
00061 if interactive:
00062     graphics="both"
00063 else:
00064     graphics="file"
00065 
00066 verbose            =  True
00067 overwrite          =  True
00068 
00069 go()
00070 
00071 endTime = time.time()
00072 endProc = time.clock()
00073 
00074 ia.open(project+"/"+project + '.alma.cycle0.extended.image')
00075 hii_stats=ia.statistics(verbose=False,list=False)
00076 ia.close()
00077 
00078 reftol   = {'sum':  0.1,
00079             'max':  0.04,
00080             'min':  0.04,
00081             'rms':  0.1}
00082 
00083 refstats = { 'max': 4.986,
00084              'min': -0.1275,
00085              'rms': 0.09621,
00086              'sum': 329.9 }
00087 
00088 import datetime
00089 datestring = datetime.datetime.isoformat(datetime.datetime.today())
00090 outfile    = project+"/"+project + '.' + datestring + '.log'
00091 logfile    = open(outfile, 'w')
00092 
00093 print 'Writing regression output to ' + outfile + "\n"
00094 
00095 print >> logfile,casa['build']
00096 
00097 regstate = True
00098 rskes = refstats.keys()
00099 rskes.sort()
00100 for ke in rskes:
00101     adiff=abs(hii_stats[ke][0] - refstats[ke])/abs(refstats[ke])
00102     if adiff < reftol[ke]:
00103         print >> logfile, "* Passed %-5s image test, got % -11.5g expected % -11.5g." % (ke, hii_stats[ke][0], refstats[ke])
00104     else:
00105         print >> logfile, "* FAILED %-5s image test, got % -11.5g instead of % -11.5g." % (ke, hii_stats[ke][0], refstats[ke])
00106         regstate = False
00107 
00108 print >> logfile,'---'
00109 if regstate:
00110     print >> logfile, 'Passed',
00111     print ''
00112     print 'Regression PASSED'
00113     print ''
00114 else:
00115     print >> logfile, 'FAILED',
00116     print ''
00117     print 'Regression FAILED'
00118     print ''
00119 
00120 print >> logfile, 'regression test for component-only simdata'
00121 print >>logfile,'---'
00122 print >>logfile,'*********************************'
00123     
00124 print >>logfile,''
00125 print >>logfile,'********** Benchmarking **************'
00126 print >>logfile,''
00127 print >>logfile,'Total wall clock time was: %8.3f s.' % (endTime - startTime)
00128 print >>logfile,'Total CPU        time was: %8.3f s.' % (endProc - startProc)
00129 print >>logfile,'Wall processing  rate was: %8.3f MB/s.' % (17896.0 /
00130                                                             (endTime - startTime))
00131 
00132 msfstat = os.stat(project+"/"+project+'.alma.cycle0.extended.ms')
00133 print >>logfile,'* Breakdown:                           *'
00134 print >>logfile,'*  generating visibilities took %8.3fs,' % (msfstat[8] - startTime)
00135 print >>logfile,'*  deconvolution with %d iterations took %8.3fs.' % ( niter,
00136                                                                        endTime - msfstat[8])
00137 print >>logfile,'*************************************'
00138     
00139 logfile.close()
00140 
00141