Creating a Model for a Resolved Bandpass Calibrator

From CASA Guides
Jump to: navigation, search

This guide details how to create a spatial and spectral model of a resolved bandpass calibator.

If your bandpass calibrator is not resolved, you do not need to follow the procedure below. You can derive the spectral shape of the calibrator using the output of fluxscale (needs CASA 3.4 or greater) and the routine Spectralindex in Analysis_Utilities. That model can be added to the data using setjy.

First, I define variables used in the calibration.

# Setting parameters
#--------------------

myprefix ='ic342_cband_cont_if1_cal'
myinput = 'ic342_cband_cont_if1.ms'

myrefant = 'ea16'

myfluxcal = '1'
myfluxmod = '3C48_C.im' # remember to change this

mybpasscal = '2'

mybpassimage = myprefix+'_bpasscal'
mybpassmod = [myprefix+'_bpasscal.model.tt0',myprefix+'_bpasscal.model.tt1']
mybpasscell='1.0arcsec'
mybpassimsize = [512,512]
mybpassniters = 1000
mybpassnoise = '6mJy' 
mybpassmask = 'bpasscal_cont_if1.mask' 
mynterms = 2

myspw = '0~7'
myspwapcal = '0~7:20~100'
myspwpcal = '0~7:40~90'

Now I use setjy to get the model for the flux calibrator.

# Setting up Model for Flux calibration
#--------------------------------------

setjy(vis=myinput,
      field=myfluxcal,
      spw=myspw,
      modimage=myfluxmod,
      standard='Perley-Butler 2010',
      scalebychan=True)

Now I do a bandpass calibration using the flux calibrator. If your flux calibrator is not strong enough for a good bandpass calibration you may need to average the frequency channels in bandpass (feature available in CASA 3.4) or using a BPOLY rather than B solution in bandpass.

# Calibrating the Bandpass Calibrator
# -----------------------------------

# phase calibration
myfluxbpphasetable = myprefix + '_flux_bpphase.gcal'

gaincal(vis=myinput,
        caltable=myfluxbpphasetable,
        field=myfluxcal,
        spw=myspwapcal, 
        refant=myrefant,
        calmode='p',
        solint='int',
        gaintable=[],
        gaincurve=True)

# amplitude calibration
myfluxbpamptable = myprefix + '_flux_bpamp.gcal'

gaincal(vis=myinput,
        caltable=myfluxbpamptable,
        field=myfluxcal,
        spw=myspwapcal, 
        refant=myrefant,
        calmode='a',
        solint='int',
        gaintable=[myfluxbpphasetable],
        gaincurve=True)

# determining the bandpass calibration
myfluxbpasstable = myprefix + '_flux_bandpass.bcal'

bandpass(vis=myinput,
         caltable=myfluxbpasstable,
         field=myfluxcal,
         refant=myrefant,
         solint='inf',
         combine='scan',
         solnorm=False, # for calibration
         bandtype='B',
         gaintable=[myfluxbpphasetable,myfluxbpamptable],
         gaincurve=True)


Now we continue with the calibration and get the phases and amplitudes for the flux and bandpass calibrators after applying the initial bandpass calibration.

# Phase Calibration 
# ------------------

myscanphasetable = myprefix + '_flux_scanphase.gcal'

gaincal(vis=myinput, 
        caltable=myscanphasetable, 
        field=mybpasscal+','+myfluxcal,
        spw=myspwapcal,
        refant=myrefant,
        calmode='p', 
        solint='int',
        gaintable=[myfluxbpasstable],
        gaincurve=T)

# Amplitude Calibration 
# ----------------------


myamptable = myprefix + '_flux_amp.gcal'

gaincal(vis=myinput, 
        caltable=myamptable, 
        field=mybpasscal+','+myfluxcal,
        spw=myspwapcal,
        refant=myrefant,
        calmode='a', 
        solint='int', # or is it 'inf'
        gaintable=[myfluxbpasstable,myscanphasetable],
        gaincurve=T)

Now we determine the flux of the bandpass calibration from the flux calibrator.

# Flux calibration
# ----------------

myfluxtable = myprefix + '_flux_flux.cal'

fluxscale(vis=myinput,
          caltable=myamptable,
          fluxtable=myfluxtable,
          reference=myfluxcal,
          transfer=mybpasscal)

Finally, we apply the initial calibration to the flux and bandpass calibrators.

# Applying calibration
# --------------------


# bandpass calibrator 
applycal(vis=myinput,
         field=mybpasscal, 
         gaintable=[myfluxbpasstable, myscanphasetable, myfluxtable], 
         gainfield=[myfluxcal, mybpasscal, mybpasscal], 
         gaincurve=T, 
         calwt=F,
         flagbackup=False)

# flux calibrator 
applycal(vis=myinput,
         field=myfluxcal, 
         gaintable=[myfluxbpasstable,myscanphasetable,myfluxtable], 
         gainfield=[myfluxcal, myfluxcal, myfluxcal], 
         gaincurve=T, 
         calwt=F,
         flagbackup=False)

We image the bandpass calibrator to create a model. If you are just going to apply that model in the data calibration in the rest of your calibration, you're done! The clean task automatically fills in a model for the source being cleaned.

# Calculating the Slope of the Bandpass Calibrator
# ------------------------------------------------

clean(vis=myinput,imagename=mybpassimage,field=mybpasscal,mode='mfs',nterms=mynterms,cell=mybpasscell,imsize=mybpassimsize,niter=mybpassniters,interactive=False, usescratch=True, mask=mybpassmask,threshold=mybpassnoise)

If you wanted to use the model elsewhere, you need to fill the model for the bandpass calibrator into the measurement set you are calibrating. An example of this would be using the model of the bandpass calibrator from broad band continuum spectral windows to calibrate narrower spectral windows.

# Putting in a model of the bandpass calibrator
# ---------------------------------------------

# Not always necessary. See above.

# This assumes a model exists of the bandpass calibrator.
ft(vis=myinput,
   field=mybpasscal,
   model=mybpassmod,
   nterms=mynterms)

Once you have a model for your bandpass calibrator in the measurement set, you can proceed with your normal calibration, skipping the initial setjy step. However, the bandpass calibrator now plays the role of the flux calibrator in the rest of the calibration.

--Amanda Kepley 12:00, 24 April 2012 (PDT)