# Baseline-based calibration of N1333 calibrater # VLA baseline 3-17 02-May-2003 # MeasurementSet Name: B0319_0317.ms MS Version 2 # # Observer: AW602 Project: #Observation: VLA #Data records: 62 Total integration time = 609.999 seconds # Observed from 02-May-2003/20:09:40 to 02-May-2003/20:19:50 # # ObservationID = 1 ArrayID = 1 # Date Timerange Scan FldId FieldName DataDescIds # 02-May-2003/20:09:40.0 - 20:19:50.0 49 1 0319+415_1 [1] #Fields: 1 # ID Name Right Ascension Declination Epoch # 1 0319+415_1 03:19:48.16 +41.30.42.10 J2000 #Data descriptions: 1 (1 spectral windows and 1 polarization setups) # ID #Chans Frame Ch1(MHz) Resoln(kHz) TotBW(kHz) Ref(MHz) Corrs # 1 63 LSRK 43416.2392 97.65625 6250 43419.2666 RR LL #Feeds: 29: printing first row only # Antenna Spectral Window # Receptors Polarizations # 1 -1 2 [ R, L] #Antennas: 2: # ID Name Station Diam. Long. Lat. # 3 3 VLA:E2 25.0 m -107.37.04.4 +33.54.01.1 # 17 17 VLA:E3 25.0 m -107.37.02.8 +33.54.00.5 # Examine observed data os.system('rm -r B0319.K B0319.M B0319.MF casapy.log B0319*.png') mp.open('B0319_0317.ms') # Load data into mp (msplot tool) mp.plotoptions(plotsymbol='bo') # Make antennas blue circles mp.array() # look at antenna locations - currently missing labels! pl.savefig('B0319_array.png') mp.plotoptions(plotsymbol='r,') # Make visibilities points mp.uvcoverage() # look at uv coverage on source pl.savefig('B0319_uvcoverage.png') mp.uvdist() # look at amplitude versus uv distance (default) pl.savefig('B0319_uvdista.png') mp.uvdist(what='phase') # look at phase versus uv distance pl.savefig('B0319_uvdistp.png') mp.vistime() # look at amplitude versus time (default) pl.savefig('B0319_vistimea.png') mp.vistime(what='phase') # look at phase versus time pl.savefig('B0319_vistimep.png') mp.vischannel() # look at amplitude versus channel (default) # Example data flagging #mp.markflags() # do this interactively # draw as many boxes as necessary #mp.flagdata() # view flags; not saved until diskwrite=1 mp.markflags(region=[58,65,0.0,2.]) # flag some data with specific region mp.markflags(region=[0,3,0.0,2.]) mp.flagdata(true) # view data with region flagged # pl.savefig('B0319_vischannela.png') mp.vischannel(what='phase') # look at phase versus channel pl.savefig('B0319_vischannelp.png') # Example spectral averaging # mp.setspectral? for information mp.setspectral(nchan=3, # Set up 3 channels with start=0,width=20) # a width of 20 channels and starting at channel 1 mp.vistime() # view averaged data versus time mp.uvdist() # view averaged data versus uv distance mp.close() # Calibrate data cb.open('B0319_0317.ms') # Load data into cb (calibrater tool) cb.initcalset() # initialize the calibration for the dataset cb.reset() # and reset (safety) cb.setsolve(type='M', # Solve for baseline-based gain solutions t=3, # use small time to get solution per integration # this can be varied to explore best interval table='B0319.M') # write solutions to table=B0319.M cb.state() # view state of calibrater cb.solve() # solve for M cb.reset() # reset state of calibrater for next solving cb.setapply(type='M', # apply baseline-based gain table='B0319.M') cb.setsolve(type='MF', # solve for baseline-based bandpass t=30000, # use large time to get a single solution for each channel table='B0319.MF') # write solutions to table=B0319.MF cb.state() # view state to make sure all is set properly cb.solve() # solve for MF cb.reset() # reset state of calibrater for application of calibration cb.setapply(type='M', # apply M table='B0319.M') cb.setapply(type='MF', # apply MF table='B0319.MF') cb.state() # review what we will be doing cb.correct() # apply M, MF to data cb.close() # unload data from calibrater tool # Compare observed 'data' and 'corrected' data mp.open('B0319_0317.ms') # Load data into mp mp.plotoptions(subplot=121) # First plot (left of two panels) mp.uvdist() # Plot observed 'data' versus uv distance (default) mp.plotoptions(subplot=121,overplot=true,plotsymbol='b+') # Overplot # Overplot using blue '+' symbol mp.uvdist('corrected') # corrected data mp.plotoptions(subplot=122) # Second plot (right of two panels) mp.setspectral(1,5,50) # Take spectral average of channels 6-56 mp.uvdist('data') # Plot observed 'data' mp.plotoptions(subplot=122,overplot=true,plotsymbol='b+') # Overplot using blue '+' symbol mp.setdata() # Clear data selection # NOTE: This is needed when switching between # data columns; this also clears the spectral # selection so it should be reset mp.setspectral(1,5,50) # Take spectral average of channels 6-56 mp.uvdist('corrected') # Plot 'corrected' data pl.ylim(0.,1.5) # Extend y-axis plot limits to make room for legend pl.legend(('obs-RR','obs-LL','corr-RR','corr-LL'),numpoints=1,shadow=True) # Plot legend (using only one point per type) # Put a shadow around the box pl.text(44.60,1.4,'Spectral average: 1 channel=channels 6-56',fontsize=8) # Put a text note at the specified data x,y coordinates pl.savefig('B0319_obsvscorr.png') mp.close() # unload the data pl.clf() # clear the plotter # Compare M,MF with K mp.open('B0319_0317.ms') # Load data into mp (msplot tool) mp.setspectral(1,5,50) # Average the data into a single channel mp.plotoptions(plotsymbol='ro') # use red circles for observed data mp.vistime('data','phase') # plot the phase mp.plotoptions(true,plotsymbol='bo') # overplot the corrected data (blue circles) mp.setdata() # clear the data selection (to enable plotting the corrected column) mp.setspectral(1,5,50) # Average the data into a single channel (as before) mp.vistime('corrected','phase') # plot the corrected phase mp.close() # unload data from mp tool # derive K solution cb.open('B0319_0317.ms') # load data into the cb (calibrater tool) cb.setdata() cb.setsolve(type='K',table='B0319.K',t=0) # solve for a baseline-based fringe fit calibration cb.solve() # obtain K calibration solutions cb.reset() # reset state of cb tool cb.setapply(type='K',table='B0319.K') # apply the K solutions cb.correct() # correct the data with the K solutions cb.close() # unload data from the cb tool # now overplot K results mp.open('B0319_0317.ms') # load data into mp (msplot tool) mp.setspectral(1,5,50) # average the data into a single channel mp.plotoptions(overplot=true,plotsymbol='go') # overplot with green circles mp.vistime('corrected','phase') # plot the corrected phase from the K solution pl.savefig('B0319_calcompare.png') mp.close() # unload data from the tool #M,MF is better in this case - re-correct the data cb.open('B0319_0317.ms') # Load data into cb (calibrater tool) cb.initcalset() # initialize the calibration for the dataset cb.reset() # and reset (safety) cb.setsolve(type='M', # Solve for baseline-based gain solutions t=3, # use small time to get solution per integration # this can be varied to explore best interval table='B0319.M') # write solutions to table=B0319.M cb.state() # view state of calibrater cb.solve() # solve for M cb.reset() # reset state of calibrater for next solving cb.setapply(type='M', # apply baseline-based gain table='B0319.M') cb.setsolve(type='MF', # solve for baseline-based bandpass t=30000, # use large time to get a single solution for each channel table='B0319.MF') # write solutions to table=B0319.MF cb.state() # view state to make sure all is set properly cb.solve() # solve for MF cb.reset() # reset state of calibrater for application of calibration cb.setapply(type='M', # apply M table='B0319.M') cb.setapply(type='MF', # apply MF table='B0319.MF') cb.state() # review what we will be doing cb.correct() # apply M, MF to data cb.close() # unload data from calibrater tool # Examine calibration solutions cp.open('B0319.M') # Load B0319.M into cp (calplot tool) cp.plot() # Examine baseline-based gain solutions (phase) pl.savefig('B0319.Mp.png') cp.setdata() # Set data to amplitude (default) cp.plot('amp') # Examine amplitude versus time pl.savefig('B0319.Ma.png') cp.close() # Unload data cp.open('B0319.MF') # Load B0319.MF into cp (calplot tool) cp.plot() # Examine baseline-based bandpass (phase) pl.savefig('B0319.MFp.png') cp.setdata() # Set data to amplitude (default) cp.plot('amp') # Examine amplitude versus time pl.savefig('B0319.MFa.png') cp.close() # Unload data cp.open('B0319.K') # Load B0319.K into cp cp.plot('delay') # plot delay pl.savefig('B0319.K.png') cp.plot('delayrate') # plot delay rate pl.savefig('B0319.Krate.png') cp.close() # Examine corrected data mp.open('B0319_0317.ms') # Load data into mp (msplot tool) mp.uvdist(column='corrected') # Examine corrected data amplitude mp.uvdist(column='corrected', # Examine corrected data phase what='phase') mp.vistime(column='corrected') # Examine corrected data amplitude mp.vistime(column='corrected', # Examine corrected data phase what='phase') mp.vischannel(column='corrected') # Examine corrected data amplitude mp.vischannel(column='corrected', # Examine corrected data phase what='phase') # Also view the average channel plots for vistime, uvdist if desired mp.close() # unload data from mp (msplot tool) # uv model fit the data cb.open('B0319_0317.ms') # load the data into cb (calibrater tool) cb.modelfit(niter=5, # Set the initial values to this=no iterations compshape='P', # P=Point source, G=Gaussian, D=Disk par=[0.5,.1,.1], # Source parameters; for a point source: file='test.cl') # [flux, long offset, lat offset] # specify the file to write the component list cb.close() # unload data from calibrater # Now use component list to generate model data im.open('B0319_0317.ms') # load data into imager tool im.ft(complist='test.cl') # Fourier transform the component list - # this writes it into the MODEL_DATA column # of the MS im.close() # unload data from imager mp.open('B0319_0317.ms') # load data into msplot tool mp.setspectral(1,5,50) mp.uvdist(column='corrected') # plot corrected data mp.plotoptions(overplot=true, # specify overplot plotsymbol='ro') # specify red circles for model data mp.uvdist(column='model') # plot model data pl.savefig('B0319_modelfit.png') mp.close