Creating a Model for a Resolved Bandpass Calibrator
From CASA Guides
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 this procedure. 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.
# Setting parameters
#--------------------
myprefix ='ic342_cband_cont_if1_cal'
myinput = 'ic342_cband_cont_if1.ms'
#myantpostable = '11B-121_1_if1_antpos.cal'
myflagtable = 'precalibration_flags_2'
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
myphasecal = '3'
mysource = '4'
myspw = '0~7'
myspwapcal = '0~7:20~100'
myspwpcal = '0~7:40~90'
# Setting up Model for Flux calibration
#--------------------------------------
setjy(vis=myinput,
field=myfluxcal,
spw=myspw,
modimage=myfluxmod,
standard='Perley-Butler 2010',
scalebychan=True)
# 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)
# 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)
# Flux calibration
# ----------------
myfluxtable = myprefix + '_flux_flux.cal'
fluxscale(vis=myinput,
caltable=myamptable,
fluxtable=myfluxtable,
reference=myfluxcal,
transfer=mybpasscal)
# 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)
# 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)
# Putting in a model of the bandpass calibrator
# ---------------------------------------------
# not necessary because clean fills in the model column
# This assumes an image
#ft(vis=myinput,
# field=mybpasscal,
# model=mybpassmod,
# nterms=mynterms)