Creating a Model for a Resolved Bandpass Calibrator: Difference between revisions

From CASA Guides
Jump to navigationJump to search
(Created page with "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 proced...")
 
No edit summary
Line 1: Line 1:
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]].
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]]. That model can be added to the data using {{setjy}}.
 
First, I define variables used in the calibration.


<source lang='python'>
<source lang='python'>
Line 19: Line 21:


mybpassimage = myprefix+'_bpasscal'
mybpassimage = myprefix+'_bpasscal'
#mybpassmod = [myprefix+'_bpasscal.model.tt0',myprefix+'_bpasscal.model.tt1']
mybpassmod = [myprefix+'_bpasscal.model.tt0',myprefix+'_bpasscal.model.tt1']
mybpasscell='1.0arcsec'
mybpasscell='1.0arcsec'
mybpassimsize = [512,512]
mybpassimsize = [512,512]
Line 26: Line 28:
mybpassmask = 'bpasscal_cont_if1.mask'  
mybpassmask = 'bpasscal_cont_if1.mask'  
mynterms = 2
mynterms = 2
myphasecal = '3'
mysource = '4'


myspw = '0~7'
myspw = '0~7'
Line 36: Line 34:


</source>
</source>
Now I use setjy to get the model for the flux calibrator.


<source lang='python'>
<source lang='python'>
Line 48: Line 48:
       standard='Perley-Butler 2010',
       standard='Perley-Butler 2010',
       scalebychan=True)
       scalebychan=True)
</source>
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}}.
<source lang='python>


# Calibrating the Bandpass Calibrator
# Calibrating the Bandpass Calibrator
Line 91: Line 97:
         gaintable=[myfluxbpphasetable,myfluxbpamptable],
         gaintable=[myfluxbpphasetable,myfluxbpamptable],
         gaincurve=True)
         gaincurve=True)
</source>
Now we continue with the calibration and get the phases and amplitudes for the flux and bandpass calibrators after applying the initial bandpass calibration.
<source lang='python'>




Line 124: Line 137:
         gaincurve=T)
         gaincurve=T)


</source>
Now we determine the flux of the bandpass calibration from the flux calibrator.
<source lang='python'>


# Flux calibration
# Flux calibration
Line 135: Line 154:
           reference=myfluxcal,
           reference=myfluxcal,
           transfer=mybpasscal)
           transfer=mybpasscal)
</source>
Finally, we apply the initial calibration to the flux and bandpass calibrators.
<source lang='python'>


# Applying calibration
# Applying calibration
Line 157: Line 182:
         calwt=F,
         calwt=F,
         flagbackup=False)
         flagbackup=False)
</source>
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!
<source lang='python'>


# Calculating the Slope of the Bandpass Calibrator
# Calculating the Slope of the Bandpass Calibrator
Line 162: Line 193:


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)
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)
</source>
If you wanted to use the model elsewhere, you need to fill the model for the bandpass calibrator. An example of this would be using the model of the bandpass calibrator from broad band continuum spectral windows to calibrate narrower spectral windows.
<source lang='python'>


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


# not necessary because clean fills in the model column
# Not always necessary. See above.


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


</source>
</source>

Revision as of 14:59, 24 April 2012

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. 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'
#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

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!

# 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. 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)