Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 import time
00015 import os
00016
00017
00018
00019
00020
00021
00022
00023 scriptmode = True
00024
00025
00026
00027
00028
00029
00030
00031 prefix = 'jupiter6cm.demo'
00032
00033 msfile = prefix + '.ms'
00034
00035
00036
00037
00038
00039
00040 calprefix = prefix + '.cal'
00041
00042
00043 os.system('rm -rf '+calprefix+'*')
00044
00045
00046
00047
00048
00049
00050 usespw = ''
00051 usespwlist = ['0','1']
00052
00053
00054 usegaincurve = True
00055 gainopacity = 0.0
00056
00057
00058 calrefant = '11'
00059
00060 gtable = calprefix + '.gcal'
00061 ftable = calprefix + '.fluxscale'
00062 atable = calprefix + '.accum'
00063
00064
00065
00066
00067
00068 dopolcal = True
00069
00070 ptable = calprefix + '.pcal'
00071 xtable = calprefix + '.polx'
00072
00073
00074 poldfield = '0137+331'
00075
00076
00077 polxfield = '1331+305'
00078
00079
00080 polxfpol = 0.112
00081 polxrlpd_deg = 66.0
00082
00083 polxipol = {'0' : 7.462,
00084 '1' : 7.510}
00085
00086
00087 polxiquv = {}
00088 for spw in ['0','1']:
00089 ipol = polxipol[spw]
00090 fpol = polxfpol
00091 ppol = ipol*fpol
00092 rlpd = polxrlpd_deg*pi/180.0
00093 qpol = ppol*cos(rlpd)
00094 upol = ppol*sin(rlpd)
00095 polxiquv[spw] = [ipol,qpol,upol,0.0]
00096
00097
00098
00099
00100 srcname = 'JUPITER'
00101 srcsplitms = calprefix + '.' + srcname + '.split.ms'
00102 calname = '0137+331'
00103 calsplitms = calprefix + '.' + calname + '.split.ms'
00104
00105
00106
00107
00108
00109
00110
00111
00112 print '--Clearcal--'
00113 default('clearcal')
00114
00115 vis = msfile
00116
00117 clearcal()
00118
00119 print "Reset calibration for MS "+vis
00120 print ""
00121
00122
00123
00124
00125
00126
00127
00128 print '--Setjy--'
00129 default('setjy')
00130
00131 print "Use setjy to set flux of 1331+305 (3C286)"
00132
00133 vis = msfile
00134
00135
00136
00137 field = '1331+305'
00138
00139
00140
00141 setjy()
00142
00143
00144
00145
00146
00147
00148
00149
00150 print "Look in logger for the fluxes (should be 7.462 and 7.510 Jy)"
00151
00152
00153
00154
00155
00156
00157 print '--Gaincal--'
00158 default('gaincal')
00159
00160 print "Solve for antenna gains on 1331+305 and 0137+331"
00161 print "We have 2 single-channel continuum spw"
00162 print "Do not want bandpass calibration"
00163
00164 vis = msfile
00165
00166
00167 caltable = gtable
00168
00169 print "Output gain cal table will be "+gtable
00170
00171
00172
00173
00174
00175 field = '1331+305,0137+331'
00176 spw = ''
00177
00178
00179 gaincurve = usegaincurve
00180 opacity = gainopacity
00181
00182
00183 gaintype = 'G'
00184 calmode = 'ap'
00185
00186
00187 solint = 'inf'
00188 combine = ''
00189
00190
00191 parang = False
00192
00193
00194 refant = calrefant
00195
00196
00197 minsnr = 3
00198
00199 gaincal()
00200
00201
00202
00203
00204
00205
00206 print '--Fluxscale--'
00207 default('fluxscale')
00208
00209 print "Use fluxscale to rescale gain table to make new one"
00210
00211 vis = msfile
00212
00213
00214 fluxtable = ftable
00215
00216 print "Output scaled gain cal table is "+ftable
00217
00218
00219 caltable = gtable
00220
00221
00222
00223 reference = '1331+305'
00224
00225
00226
00227 transfer = '0137+331'
00228
00229 fluxscale()
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 print '--PlotCal--'
00242 default('plotcal')
00243
00244 showgui = True
00245
00246 caltable = ftable
00247 multiplot = True
00248 yaxis = 'amp'
00249
00250 showgui = True
00251
00252 plotcal()
00253
00254 print ""
00255 print "-------------------------------------------------"
00256 print "Plotcal"
00257 print "Looking at amplitude in cal-table "+caltable
00258
00259
00260 if scriptmode:
00261 user_check=raw_input('Return to continue script\n')
00262
00263
00264
00265
00266 showgui = False
00267
00268 yaxis = 'amp'
00269
00270 figfile = caltable + '.plotcal.amp.png'
00271 print "Plotting calibration to file "+figfile
00272
00273 plotcal()
00274
00275 yaxis = 'phase'
00276
00277 figfile = caltable + '.plotcal.phase.png'
00278 print "Plotting calibration to file "+figfile
00279
00280 plotcal()
00281
00282
00283
00284
00285
00286
00287 if (dopolcal):
00288 print '--Polcal (D)--'
00289 default('polcal')
00290
00291 print "Solve for polarization leakage on 0137+331"
00292 print "Pretend it has unknown polarization"
00293
00294 vis = msfile
00295
00296
00297 gaintable = gtable
00298
00299
00300 gaincurve = usegaincurve
00301 opacity = gainopacity
00302
00303
00304 caltable = ptable
00305
00306
00307 field = '0137+331'
00308 spw = ''
00309
00310
00311 selectdata=False
00312
00313
00314 poltype = 'D+QU'
00315
00316
00317 solint = 'inf'
00318 combine = 'scan'
00319
00320
00321 refant = calrefant
00322
00323
00324 minsnr = 3
00325
00326
00327 polcal()
00328
00329
00330
00331
00332
00333 print '--Listcal (PolD)--'
00334
00335 listfile = caltable + '.list'
00336
00337 print "Listing calibration to file "+listfile
00338
00339 listcal()
00340
00341
00342
00343
00344
00345 print '--Plotcal (PolD)--'
00346
00347 iteration = ''
00348 showgui = False
00349
00350 xaxis = 'real'
00351 yaxis = 'imag'
00352 figfile = caltable + '.plotcal.reim.png'
00353 print "Plotting calibration to file "+figfile
00354
00355 plotcal()
00356
00357 xaxis = 'antenna'
00358 yaxis = 'amp'
00359 figfile = caltable + '.plotcal.antamp.png'
00360 print "Plotting calibration to file "+figfile
00361
00362 plotcal()
00363
00364 xaxis = 'antenna'
00365 yaxis = 'phase'
00366 figfile = caltable + '.plotcal.antphase.png'
00367 print "Plotting calibration to file "+figfile
00368
00369 plotcal()
00370
00371 xaxis = 'antenna'
00372 yaxis = 'snr'
00373 figfile = caltable + '.plotcal.antsnr.png'
00374 print "Plotting calibration to file "+figfile
00375
00376 plotcal()
00377
00378
00379
00380
00381
00382 print '--Setjy--'
00383 default('setjy')
00384
00385 vis = msfile
00386
00387 print "Use setjy to set IQU fluxes of "+polxfield
00388 field = polxfield
00389
00390 for spw in usespwlist:
00391 fluxdensity = polxiquv[spw]
00392
00393
00394 setjy()
00395
00396
00397
00398
00399 print '--PolCal (X)--'
00400 default('polcal')
00401
00402 print "Polarization R-L Phase Calibration (linear approx)"
00403
00404 vis = msfile
00405
00406
00407 gaintable = [gtable,ptable]
00408
00409
00410 gaincurve = usegaincurve
00411 opacity = gainopacity
00412
00413
00414 caltable = xtable
00415
00416
00417 field = polxfield
00418 spw = ''
00419
00420 selectdata=False
00421
00422
00423 poltype = 'X'
00424 solint = 'inf'
00425 combine = 'scan'
00426
00427
00428 refant = calrefant
00429
00430
00431 minsnr = 3
00432
00433
00434 polcal()
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467 atable = ftable
00468
00469
00470
00471
00472
00473
00474 print '--ApplyCal--'
00475 default('applycal')
00476
00477 print "This will apply the calibration to the DATA"
00478 print "Fills CORRECTED_DATA"
00479
00480 vis = msfile
00481
00482
00483 gaintable = [atable,ptable,xtable]
00484
00485
00486 gaincurve = usegaincurve
00487 opacity = gainopacity
00488
00489
00490 field = '1331+305,0137+331,JUPITER'
00491 spw = ''
00492 selectdata = False
00493
00494
00495 parang = True
00496
00497
00498
00499 gainfield = ''
00500
00501 applycal()
00502
00503
00504
00505
00506
00507
00508 print '--Split Jupiter--'
00509 default('split')
00510
00511 vis = msfile
00512
00513
00514
00515
00516 field = srcname
00517 spw = ''
00518
00519
00520 datacolumn = 'corrected'
00521
00522
00523 outputvis = srcsplitms
00524
00525 print "Split "+field+" data into new ms "+srcsplitms
00526
00527 split()
00528
00529
00530 field = calname
00531
00532 outputvis = calsplitms
00533
00534 print "Split "+field+" data into new ms "+calsplitms
00535
00536 split()
00537
00538
00539
00540
00541 vis = srcsplitms
00542 clearcal()
00543
00544 vis = calsplitms
00545 clearcal()
00546
00547
00548
00549
00550 print '--Plotxy--'
00551 default('plotxy')
00552
00553 vis = srcsplitms
00554 selectdata = True
00555
00556
00557 correlation = 'RR LL'
00558
00559
00560 xaxis = 'uvdist'
00561 datacolumn = 'data'
00562 multicolor = 'both'
00563
00564 iteration = ''
00565 selectplot = True
00566 interactive = True
00567
00568 field = 'JUPITER'
00569 yaxis = 'amp'
00570
00571 title = field+" "
00572
00573 plotxy()
00574
00575 print ""
00576 print "-----------------------------------------------------"
00577 print "Plotting JUPITER corrected visibilities"
00578 print "Look for outliers"
00579
00580
00581 if scriptmode:
00582 user_check=raw_input('Return to continue script\n')
00583
00584
00585 interactive = False
00586
00587
00588
00589
00590 vis = srcsplitms
00591 field = srcname
00592 yaxis = 'amp'
00593
00594 title = field+" "
00595 figfile = vis + '.plotxy.amp.png'
00596 print "Plotting to file "+figfile
00597
00598
00599 plotxy()
00600
00601 yaxis = 'phase'
00602
00603 figfile = vis + '.plotxy.phase.png'
00604 print "Plotting to file "+figfile
00605
00606
00607 plotxy()
00608
00609
00610
00611
00612 vis = calsplitms
00613 field = calname
00614 yaxis = 'amp'
00615
00616 title = field+" "
00617 figfile = vis + '.plotxy.amp.png'
00618 print "Plotting to file "+figfile
00619
00620
00621 plotxy()
00622
00623 yaxis = 'phase'
00624
00625 figfile = vis + '.plotxy.phase.png'
00626 print "Plotting to file "+figfile
00627
00628
00629 plotxy()
00630
00631
00632
00633
00634
00635 print 'Calibration completed for '+calprefix