Go to the documentation of this file.00001
00002
00003
00004 import os, time
00005
00006
00007
00008
00009 startTime = time.time()
00010 startProc = time.clock()
00011
00012 print '--Running simdata of test cube--'
00013
00014 l=locals()
00015 if not l.has_key("repodir"):
00016 repodir=os.getenv("CASAPATH").split(' ')[0]
00017
00018 print 'I think the data repository is at '+repodir
00019 datadir=repodir+"/data/regression/simdata/"
00020 cfgdir=repodir+"/data/alma/simmos/"
00021 importfits(fitsimage=datadir+"testcube.fits",imagename="testcube2")
00022
00023
00024
00025
00026
00027
00028 default("simobserve")
00029 project="tc2"
00030
00031 skymodel="testcube2"
00032 inbright=".1"
00033 indirection="J2000 19h00m00s -40d00m00s"
00034 incell="0.2arcsec"
00035 incenter="350GHz"
00036 inwidth="0.5MHz"
00037
00038 setpointings=False
00039 ptgfile=datadir+"testcube.ptg.txt"
00040
00041 obsmode="int"
00042 antennalist=cfgdir+"alma.out01.cfg"
00043 refdate="2012/06/21/03:25:00"
00044 totaltime="7200s"
00045
00046 thermalnoise=""
00047 verbose=True
00048 overwrite=False
00049
00050 if not l.has_key('interactive'): interactive=False
00051 if interactive:
00052 graphics="both"
00053 else:
00054 graphics="file"
00055
00056 inp()
00057 go()
00058
00059 endTime = time.time()
00060 endProc = time.clock()
00061
00062
00063
00064 test_name = """simdata observation of test cube"""
00065 ms.open(project+"/"+project+".alma.out01.ms")
00066 newdata= ms.getdata(items="data")['data']
00067 ms.close()
00068
00069 refshape=[2,10,882000]
00070
00071 refstats = { 'max': 2.05e-01 + 7.52e-03j,
00072 'min':-1.90e-01 + 4.33e-02j,
00073 'sum': 1.72e+04 + -1.53e+03j,
00074 'std': 5.53e-02 }
00075
00076
00077 reftol = {'max': 5e-3,
00078 'min': 5e-3,
00079 'sum': 5e-3,
00080 'std': 5e-3}
00081
00082 import datetime
00083 datestring = datetime.datetime.isoformat(datetime.datetime.today())
00084 outfile = project+"/"+project + '.' + datestring + '.log'
00085 logfile = open(outfile, 'w')
00086
00087 print 'Writing regression output to ' + outfile + "\n"
00088
00089 loghdr = """
00090 ********** Regression *****************
00091 """
00092
00093
00094
00095 print >> logfile, loghdr
00096
00097 regstate = True
00098
00099 if max(abs(newdata.shape-pl.array(refshape)))<=0:
00100 print >> logfile, "* Passed shape test with shape "+str(newdata.shape)
00101 else:
00102 print >> logfile, "* FAILED shape test, expecting %s, got %s" % (str(refshape),str(newdata.shape))
00103 regstate = False
00104
00105 cube_stats={'max':newdata.max(),
00106 'min':newdata.min(),
00107 'sum':newdata.sum(),
00108 'std':newdata.std()}
00109
00110 regstate=True
00111 rskes = refstats.keys()
00112 rskes.sort()
00113 for ke in rskes:
00114 adiff=abs(cube_stats[ke] - refstats[ke])/abs(refstats[ke])
00115 if adiff < reftol[ke]:
00116 status="* Passed "
00117 else:
00118 status="* FAILED "
00119 regstate = False
00120 status=status+" %3s test, got " % ke
00121 if type(refstats[ke])==complex:
00122 status=status+"%9.2e + %9.2ej , expected %9.2e + %9.2ej." % (cube_stats[ke].real, cube_stats[ke].imag, refstats[ke].real, refstats[ke].imag)
00123 else:
00124 status=status+"%9.2e , expected %9.2e." % (cube_stats[ke], refstats[ke])
00125 print >> logfile, status
00126
00127
00128
00129
00130 print >> logfile,'---'
00131 if regstate:
00132 print >> logfile, 'Passed',
00133 print ''
00134 print 'Regression PASSED'
00135 print ''
00136 else:
00137 print >> logfile, 'FAILED',
00138 print ''
00139 print 'Regression FAILED'
00140 print ''
00141
00142 print >> logfile, 'regression test for simdata of test cube.'
00143 print >>logfile,'---'
00144 print >>logfile,'*********************************'
00145
00146 print >>logfile,''
00147 print >>logfile,'********** Benchmarking **************'
00148 print >>logfile,''
00149 print >>logfile,'Total wall clock time was: %8.3f s.' % (endTime - startTime)
00150 print >>logfile,'Total CPU time was: %8.3f s.' % (endProc - startProc)
00151 print >>logfile,'Wall processing rate was: %8.3f MB/s.' % (17896.0 /
00152 (endTime - startTime))
00153 print >>logfile,'*************************************'
00154
00155 logfile.close()
00156
00157 print '--Finished simdata of test cube regression--'