00001
00002
00003
00004
00005
00006
00007 import time
00008 import os
00009
00010 os.system('rm -rf B0319_0317.ms B0319.K B0319.Mt B0319.MFt B0319*.png n1333.ms')
00011
00012 pathname=os.environ.get('CASAPATH').split()[0]
00013 datapath = os.environ.get('CASAPATH').split()[0]+'/data/regression/ATST4/B0319/N1333_1.UVFITS'
00014
00015 startTime = time.time()
00016 startProc = time.clock()
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 startTime = time.time()
00057 startProc = time.clock()
00058
00059 print '--Import--'
00060 default('importuvfits')
00061 importuvfits(fitsfile=datapath,vis='n1333.ms',antnamescheme='new')
00062 importtime=time.time()
00063 print '--Split Data--'
00064 default('split')
00065 split(vis='n1333.ms',outputvis='B0319_0317.ms',datacolumn='data',field='14',antenna='VA03 & VA17')
00066 splittime=time.time()
00067
00068 print '--Plot antenna array and uv coverage--'
00069 default('plotxy')
00070 plotxy(vis='B0319_0317.ms',xaxis='x',subplot=121,markersize=8)
00071 plotxy(vis='B0319_0317.ms',xaxis='u',subplot=122,markersize=5)
00072 plotanttime=time.time()
00073
00074 print '--Plot visibility phase/amp versus uv distance--'
00075 default('plotxy')
00076 plotxy(vis='B0319_0317.ms',xaxis='uvdist',yaxis='amp',
00077 datacolumn='data',subplot=211,clearpanel='All')
00078 plotxy(vis='B0319_0317.ms',xaxis='uvdist',yaxis='phase',
00079 datacolumn='data',subplot=212,clearpanel='Auto')
00080 plotuvdisttime=time.time()
00081
00082 default('plotxy')
00083 plotxy(vis='B0319_0317.ms',xaxis='time',yaxis='amp',
00084 datacolumn='data',subplot=211,clearpanel='All')
00085 plotxy(vis='B0319_0317.ms',xaxis='time',yaxis='phase',
00086 datacolumn='data',subplot=212,clearpanel='Auto')
00087 plottimetime=time.time()
00088
00089 default('plotxy')
00090 plotxy(vis='B0319_0317.ms',xaxis='channel',yaxis='amp',
00091 datacolumn='data',subplot=211,clearpanel='All')
00092 plotxy(vis='B0319_0317.ms',xaxis='channel',yaxis='phase',
00093 datacolumn='data',subplot=212,clearpanel='Auto')
00094 plotchanneltime=time.time()
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 plotflagtime=time.time()
00105
00106
00107 default('plotxy')
00108 plotxy(vis='B0319_0317.ms',xaxis='time',yaxis='amp',datacolumn='data',
00109 subplot=111,clearpanel='All')
00110 plotxy(vis='B0319_0317.ms',xaxis='time',yaxis='amp',datacolumn='data',
00111 subplot=111,spw='0~1:0~60^20',overplot=True,
00112 plotsymbol='bo',clearpanel='All')
00113 plotavertime=time.time()
00114
00115
00116 clearcal(vis='B0319_0317.ms')
00117 default('blcal')
00118 blcal(vis='B0319_0317.ms',caltable='B0319.Mt',
00119 solint='3s',combine='',gaincurve=False,opacity=0.0)
00120 default('blcal')
00121 blcal(vis='B0319_0317.ms',caltable='B0319.MFt',
00122 gaintable='B0319.Mt',interp='nearest',
00123 solint='inf',combine='scan',
00124 gaincurve=False,opacity=0.0,freqdep=True)
00125 default('applycal')
00126 applycal(vis='B0319_0317.ms',
00127 gaintable=['B0319.Mt','B0319.MFt'],
00128 gaincurve=False,opacity=0.0)
00129 calibratetime=time.time()
00130
00131
00132 default('plotxy')
00133 plotxy(vis='B0319_0317.ms',xaxis='uvdist',yaxis='amp',datacolumn='data',
00134 plotsymbol=',',plotcolor='blue',subplot=121,clearpanel='All')
00135 plotxy(vis='B0319_0317.ms',xaxis='uvdist',yaxis='amp',datacolumn='corrected',
00136 subplot=121,plotsymbol='+',plotcolor='red',overplot=True,clearpanel='Auto')
00137
00138 default('plotxy')
00139 plotxy(vis='B0319_0317.ms',xaxis='uvdist',yaxis='amp',datacolumn='data',
00140 subplot=122,plotsymbol=',',plotcolor='blue',spw='0~1:5~54^50')
00141 plotxy(vis='B0319_0317.ms',xaxis='uvdist',yaxis='amp',datacolumn='corrected',
00142 subplot=122,plotsymbol='+',plotcolor='red',spw='0~1:5~54^50',
00143 overplot=True)
00144 plotcomparetime=time.time()
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 default('plotcal')
00162 plotcal(caltable='B0319.Mt',yaxis='phase',subplot=121,plotsymbol='bo',clearpanel='All')
00163 plotcal(caltable='B0319.Mt',yaxis='amp',subplot=122,plotsymbol='bo',
00164 overplot=True,clearpanel='Auto')
00165
00166 default('plotcal')
00167 plotcal(caltable='B0319.MFt',yaxis='phase',
00168 subplot=121,plotsymbol='bo',clearpanel='All')
00169 plotcal(caltable='B0319.MFt',yaxis='amp',
00170 subplot=122,plotsymbol='bo',overplot=True,clearpanel='Auto')
00171 plotcaltime=time.time()
00172
00173
00174
00175
00176
00177
00178 default('plotxy')
00179 plotxy(vis='B0319_0317.ms',xaxis='uvdist',yaxis='amp',datacolumn='corrected',
00180 subplot=121,clearpanel='All')
00181 plotxy(vis='B0319_0317.ms',xaxis='uvdist',yaxis='phase',datacolumn='corrected',
00182 subplot=122,clearpanel='Auto')
00183
00184 default('plotxy')
00185 plotxy(vis='B0319_0317.ms',xaxis='time',yaxis='amp',datacolumn='corrected',
00186 subplot=121,clearpanel='All')
00187 plotxy(vis='B0319_0317.ms',xaxis='time',yaxis='phase',datacolumn='corrected',
00188 subplot=122,clearpanel='Auto')
00189
00190 default('plotxy')
00191 plotxy(vis='B0319_0317.ms',xaxis='channel',yaxis='amp',datacolumn='corrected',
00192 subplot=121,clearpanel='All')
00193 plotxy(vis='B0319_0317.ms',xaxis='channel',yaxis='phase',datacolumn='corrected',
00194 subplot=122,clearpanel='Auto')
00195 plotcorrectedtime=time.time()
00196
00197
00198 default('uvmodelfit')
00199 uvmodelfit(vis='B0319_0317.ms',niter=5,comptype='P',
00200 sourcepar=[0.5,.1,.1],outfile='test.cl')
00201 uvmodelfittime=time.time()
00202
00203
00204 default('ft')
00205 ft(vis='B0319_0317.ms',complist='test.cl')
00206 fttime=time.time()
00207
00208
00209 default('plotxy')
00210 plotxy(vis='B0319_0317.ms',xaxis='uvdist',yaxis='amp',datacolumn='corrected',
00211 spw='0~1:5~54^50',plotsymbol='b,',clearpanel='All')
00212 plotxy(vis='B0319_0317.ms',xaxis='uvdist',yaxis='amp',datacolumn='model',
00213 spw='0~1:5~54^50',plotsymbol='ro',overplot=True,clearpanel='Auto')
00214 plotmodeltime=time.time()
00215
00216 endProc = time.clock()
00217 endTime = time.time()
00218
00219
00220
00221
00222
00223
00224
00225 ms.open('B0319_0317.ms')
00226
00227
00228 thistest_mod=pl.mean(ms.range(['model_amplitude']).get('model_amplitude'))
00229
00230
00231 model_amp=1.0
00232
00233 diff_mod=abs((model_amp-thistest_mod)/model_amp)
00234
00235 print '***'
00236 print 'model_amp ',model_amp
00237 print 'thistest_mod ',thistest_mod
00238 print '***'
00239
00240 import datetime
00241 datestring=datetime.datetime.isoformat(datetime.datetime.today())
00242 outfile='B0319.'+datestring+'.log'
00243 logfile=open(outfile,'w')
00244
00245 print >>logfile,' Baseline-based calibration of N1333 calibrater'
00246 print >>logfile,' VLA baseline 3-17 02-May-2003'
00247 print >>logfile,' MeasurementSet Name: B0319_0317.ms MS Version 2'
00248 print >>logfile,''
00249 print >>logfile,' Observer: AW602 Project:'
00250 print >>logfile,'Observation: VLA'
00251 print >>logfile,'Data records: 62 Total integration time = 609.999 seconds'
00252 print >>logfile,' Observed from 02-May-2003/20:09:40 to 02-May-2003/20:19:50'
00253 print >>logfile,''
00254 print >>logfile,' ObservationID = 1 ArrayID = 1'
00255 print >>logfile,' Date Timerange Scan FldId FieldName DataDescIds'
00256 print >>logfile,' 02-May-2003/20:09:40.0 - 20:19:50.0 49 1 0319+415_1 [1]'
00257 print >>logfile,'Fields: 1'
00258 print >>logfile,' ID Name Right Ascension Declination Epoch'
00259 print >>logfile,' 1 0319+415_1 03:19:48.16 +41.30.42.10 J2000'
00260 print >>logfile,'Data descriptions: 1 (1 spectral windows and 1 polarization setups)'
00261 print >>logfile,' ID #Chans Frame Ch1(MHz) Resoln(kHz) TotBW(kHz) Ref(MHz) Corrs'
00262 print >>logfile,' 1 63 LSRK 43416.2392 97.65625 6250 43419.2666 RR LL'
00263 print >>logfile,'Feeds: 29: printing first row only'
00264 print >>logfile,' Antenna Spectral Window # Receptors Polarizations'
00265 print >>logfile,' 1 -1 2 [ R, L]'
00266 print >>logfile,'Antennas: 2:'
00267 print >>logfile,' ID Name Station Diam. Long. Lat.'
00268 print >>logfile,' 3 3 VLA:E2 25.0 m -107.37.04.4 +33.54.01.1'
00269 print >>logfile,' 17 17 VLA:E3 25.0 m -107.37.02.8 +33.54.00.5'
00270 print >>logfile,''
00271 print >>logfile,'********** Regression ***********'
00272 print >>logfile,'* *'
00273 if (diff_mod<0.05): print >>logfile,'* Passed Model data test'
00274 print >>logfile,'* Model data mean'+str(thistest_mod)+','+str(model_amp)
00275
00276 if (diff_mod<0.05):
00277 regstate=True
00278 print >>logfile,'---'
00279 print >>logfile,'Passed Regression test for B0319'
00280 print >>logfile,'---'
00281 else:
00282 regstate=False
00283 print >>logfile,'----FAILED Regression test for B0319'
00284 print >>logfile,'*********************************'
00285
00286 print >>logfile,''
00287 print >>logfile,''
00288 print >>logfile,'********* Benchmarking *****************'
00289 print >>logfile,'* *'
00290 print >>logfile,'Total wall clock time was: '+str(endTime - startTime)
00291 print >>logfile,'Total CPU time was: '+str(endProc - startProc)
00292
00293 print >>logfile,'* Breakdown: *'
00294 print >>logfile,'* import time was: '+str(importtime-startTime)
00295 print >>logfile,'* split time was: '+str(splittime-importtime)
00296 print >>logfile,'* plotant time was: '+str(plotanttime-splittime)
00297 print >>logfile,'* plotuvdist time was: '+str(plotuvdisttime-plotanttime)
00298 print >>logfile,'* plottime time was: '+str(plottimetime-plotuvdisttime)
00299 print >>logfile,'* plotchannel time was: '+str(plotchanneltime-plottimetime)
00300 print >>logfile,'* plotflag time was: '+str(plotflagtime-plotchanneltime)
00301 print >>logfile,'* plotaverage time was: '+str(plotavertime-plotflagtime)
00302 print >>logfile,'* calibrate time was: '+str(calibratetime-plotavertime)
00303 print >>logfile,'* plotcompare time was: '+str(plotcomparetime-calibratetime)
00304 print >>logfile,'* plotcal time was: '+str(plotcaltime-plotcomparetime)
00305 print >>logfile,'* plotcorr time was: '+str(plotcorrectedtime-plotcaltime)
00306 print >>logfile,'* uvmodelfit time was: '+str(uvmodelfittime-plotcorrectedtime)
00307 print >>logfile,'* ft time was: '+str(fttime-uvmodelfittime)
00308 print >>logfile,'* plotmodel time was: '+str(plotmodeltime-fttime)
00309 print >>logfile,'*****************************************'
00310
00311 logfile.close()