Cross‐calibration - eakadams/ihow-hi GitHub Wiki
This page goes through the cross-calibration of the dataset. You may start with this step of the tutorial by downloading the data manually flagged by the instructor in the google drive ao215_54681.ms.tar. You will need to untar this file.
Set up model for flux calibrator
The primary calibrator is 1331+305, or 3C286. Find the models by running setjy with listmodels=True. Once you have identified the right model, set it. Make sure to specify the field that is of the primary (bandpass and flux) calibrator.
setjy(vis='ao215_54681.ms',field='0',model='3C286_L.im')
You should see output with something like:
{'0': {'0': {'fluxd': array([14.98683834, 0. , 0. , 0. ])},
'fieldName': '1331+305'},
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}
Choose a reference antenna
Throughout the calibration, will need a reference antenna. The shortest baselines are the most susceptible to errors as they see the large-scale sky structure (e.g., least likely to be a point source response for calibrator). Thus, choose an antenna that is near of the one ends of the three arms, to have preferentially longer baselines. And choose an antenna with a low number - those are easier to see the baselines for / plot because of how data is ordered. Looking at previous plotant output, EA04 looks like a good choice; this is id 2 based on listobs. Note this is an upgrade antenna; this shouldn't matter.
Delay calibration
Do the delay calibration:
gaincal(vis='ao215_54681.ms',caltable='delays.cal',field='0',refant='2',gaintype='K')
Do bandpass calibration
Phase solution over time
First, want to solve for phases with time, in case they vary over the course of the bandpass scan. This is normally a small effect at low frequency. Pick a small range of channels to use, since want to avoid bandpass effects (still have to solve for).
gaincal(vis='ao215_54681.ms',caltable='bpphase.gcal',field='0',spw='0:140~150',refant='2',solint='int',calmode='p',minsnr=2.0,gaintable=['delays.cal'])
Check the solutions by plotting them:
plotms(vis='bpphase.gcal', coloraxis='corr', iteraxis='antenna', yaxis='phase')
Solutions generally seem reasonable, with small, smooth variations over time.
Full bandpass solution
bandpass(vis='ao215_54681.ms',caltable='bandpass.bcal',field='0',refant='2',solint='inf',solnorm=True,gaintable=['delays.cal','bpphase.gcal'])
Note that some edge channels are missing solutions, but we will discard those channels due to suppressed bandpass response anyway, so don't need to worry:
1 of 46 solutions flagged due to SNR < 3 in spw=0 (chan=3) at 2008/08/03/18:30:43.0
20 of 46 solutions flagged due to SNR < 3 in spw=0 (chan=2) at 2008/08/03/18:30:43.0
40 of 46 solutions flagged due to SNR < 3 in spw=0 (chan=1) at 2008/08/03/18:30:43.0
42 of 46 solutions flagged due to SNR < 3 in spw=0 (chan=0) at 2008/08/03/18:30:43.0
Plot the solutions to inspect them:
plotms(vis='bandpass.bcal', coloraxis='corr', iteraxis='antenna')
Bandpass solutions generally look good, except for ea08 which has an odd shape in one polarization; keep an eye on this. But if it calibrates out, it calibrates out.
Note that roughly channels ~20-225 have high throughput; will focus on those for rest of calibration.
Gain calibration
The gain calibration also relies on the phase calibrator, 0943-083. Check the VLA calibrator manual to see if there are any uvlimits. There are none, so don't have to worry about that.
Do the calibration:
gaincal(vis='ao215_54681.ms',caltable='amp.gcal',field='0,1',spw='0:20~225',refant='2',solint='inf',calmode='ap',minsnr=2.0,gaintable=['delays.cal','bandpass.bcal'])
And check the solutions. First check the phases:
plotms(vis='amp.gcal',xaxis='time',yaxis='phase',iteraxis='antenna',gridrows=3,gridcols=3,plotrange=[0,0,-180,180],coloraxis='corr')

Phases generally look well-behaved in time.
plotms(vis='amp.gcal',xaxis='time',yaxis='amp',iteraxis='antenna',gridrows=3,gridcols=3,coloraxis='corr')
Amplitude solutions generally looked well-behaved. There is a clear offset between flux and phase, as expected, and generally the phase calibrator ampltidue solution is stable across the two scans.
Set the flux scale
fluxscale(vis='ao215_54681.ms',caltable='amp.gcal',fluxtable='flux.cal',reference='0',incremental=True)
Terminal output:
Out[63]:
{'1': {'0': {'fluxd': array([2.79256079, 0. , 0. , 0. ]),
'fluxdErr': array([0.02011029, 0. , 0. , 0. ]),
'numSol': array([46., 0., 0., 0.])},
'covarMat': array([], shape=(0, 0), dtype=float64),
'fieldName': '0943-083',
'fitFluxd': 2.792560793589569,
'fitFluxdErr': 0.0,
'fitRefFreq': 1418862534.1796873,
'spidx': array([0., 0.]),
'spidxerr': array([0., 0.])},
'freq': array([1.41886253e+09]),
'spwID': array([0]),
'spwName': array(['255*6.1 kHz channels @ 1.42 GHz (TOPO)'], dtype='<U39')}
A flux of 2.79256 Jy is returned for 0943-083. Check this against the VLA calibrator manual which has 2.7 Jy. This is easily within typical variability, so to first order flux scale / calibration is good.
Apply calibration solutions
Apply solutions to the primary (flux/bandpass) calibrator:
applycal(vis='ao215_54681.ms',field='0',gaintable=['delays.cal','bandpass.bcal','amp.gcal','flux.cal'], gainfield=['0','0','0','0'],calwt=False)
Apply solutions to the gain calibrator
applycal(vis='ao215_54681.ms',field='1',gaintable=['delays.cal','bandpass.bcal','amp.gcal','flux.cal'], gainfield=['0','0','1','1'],calwt=False)
Apply solutions to the source
applycal(vis='ao215_54681.ms',field='2',gaintable=['delays.cal','bandpass.bcal','amp.gcal','flux.cal'], gainfield=['0','0','1','1'],calwt=False)
Inspect calibrated data
Look at the data in plotms. Calibrator sources should be point sources, thus when the data is calibrated, points should cluster in phase-amp space.
Amplitude vs phases for the primary calibrator, plotting corrected data. Values cluster as expected around zero phase and the flux of the calibrator. There is some scatter but no clear offsets, so will be happy with this calibration.
Amplitude vs phases for the secondary calibrator, plotting corrected data. Values cluster as expected around zero phase and the flux of the calibrator.
Split out source data
At this point, calibration is done, so can split out just the source and apply solutions to make life easier. Keep only the channels with good bandpass response for which gain calibration was done.
split(vis='ao215_54681.ms',outputvis='sexb.ms',datacolumn='corrected',spw='0:20~225',field='2')