Combining Bandpasses: Difference between revisions

From CASA Guides
Jump to navigationJump to search
Jott (talk | contribs)
No edit summary
Jott (talk | contribs)
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Using CASA Hints Tips Tricks}}
{{Using CASA Hints Tips Tricks}}
'''CASA 5.6 and later'''


Sometimes the bandpass calibrator at the required frequency is contaminated with line absorption or emission. In particular, this is notorious for observations close to the rest frequency of HI where Galactic HI is observed along almost any sightline.  
Sometimes the bandpass calibrator at the required frequency is contaminated with line absorption or emission. In particular, this is notorious for observations close to the rest frequency of HI where Galactic HI is observed along almost any sightline.  
Line 113: Line 115:
gaintable          = 'corr.gcal,bp12.bpcal'    #  Gain calibration table(s) to apply on the fly
gaintable          = 'corr.gcal,bp12.bpcal'    #  Gain calibration table(s) to apply on the fly
gainfield          =      ['']        #  Select a subset of calibrators from gaintable(s)
gainfield          =      ['']        #  Select a subset of calibrators from gaintable(s)
interp              = ['linear']        #  Temporal Interpolation type.  default=linear
interp              = ['linear,linearrel']        #  Interpolation parameters for each gaintable, as a list
spwmap              = [1]               #  Spectral windows combinations to form for
spwmap              = [[1],[]]          #  Spectral windows combinations to form for
                                         #  gaintables(s)
                                         #  gaintables(s)
gaincurve          =      False        #  Apply internal VLA antenna gain curve correction
gaincurve          =      False        #  Apply internal VLA antenna gain curve correction
Line 129: Line 131:


<pre>
<pre>
spwmap              = [1]   
spwmap              = [[1],[]]   
</pre>
</pre>
here, spw 0 will receive the solution from spw 1, the nominal spw that was assigned when spws 1 and 2 were combined for a solution.


In this case, the spw 1 solution (see above, in this case the combined spw 1 and 2) is mapped to spw 0, as the number "1" is at the 0th position of the spwmap list (in this case the list contains only one element; type "help par.spwmap" in CASA for additional info on more complex cases.  
In the interpolation instructions
<pre>
interp              = ['linear,linearrel']
</pre>
the first parameter sets the temporal interpolation and the second the frequency interpolation. The 'rel' appendix will do a relative interpolation, ie shift the frequency of the combined bandpass calibration solution that is nominally assigned to spw=1 to spw=0, the central spw.  


And don't forget to apply *both* the gain and the bandpass calibration table to your science data.  
And don't forget to apply *both* the gain and the bandpass calibration table to your science data.  


Now you should have applied the average bandpass from the two offset frequencies in spws 1 and 2 to the central spw 0 and your spectrum shines in perfection.  
Now you should have applied the average bandpass from the two offset frequencies in spws 1 and 2 to the central spw 0 and your spectrum shines in perfection.  




--[[User:jott|Juergen Ott]] 23 March 2010
--[[User:jott|Juergen Ott]] 10 March 2021

Latest revision as of 19:47, 11 March 2021

Hints, Tips, and Tricks

CASA 5.6 and later

Sometimes the bandpass calibrator at the required frequency is contaminated with line absorption or emission. In particular, this is notorious for observations close to the rest frequency of HI where Galactic HI is observed along almost any sightline.

However, it is still possible to obtain a usable bandpass solution. An option is to observe frequencies offset to the main frequency, and apply the bandpasses to the observing frequency. The offset frequencies should be chosen clean from any line contamination, but with as little frequency offset as possible. Ideally it is advisable to observe two offset frequencies, symmetric to the main observing frequency, and to combine them.

In the following we explain how to combine these offset frequencies for a common bandpass and how to apply it to the central frequency.

As an example, we describe a Galactic HI observation ('data.ms'). At the HI frequency, all calibrators will have emission and/or absorption. Thus any bandpass at the HI frequency will be contaminated. A solution is to observe 3 frequencies: The central, HI frequency for the target (and maybe for the gain/phase), a frequency +4MHz offset and one with a -4MHz offset. In this example, the spectral windows (spw), are 0, 1, and 2, respectively. For this example we use the bandpass calibrator 3c286 and the source is called 'galaxy'. The +/-4MHz frequency offsets are chosen to be clear of any possible contamination. But the offset maybe reduced depending on the Galactic HI profile at the bandpass calibrator sightline.


Three steps are needed:

1) gaincal: Typically, the offset frequencies have different phases and gains. Since the bandpass is obtained by vector averaging the data, one needs to correct for the phase/gain offsets. The best way to do this is to derive and apply a complex gain solution (phases and gains) for all spw.

In CASA use the task gaincal. In our example, the inputs are:

#  gaincal :: Determine temporal gains from calibrator observations
vis                 = 'data.ms'         #  Name of input visibility
                                        #   file
caltable            = 'corr.gcal'       #  Name of output gain calibration table
field               =     '3c286'       #  Select field using field id(s) or field name(s)
spw                 =         ''        #  Select spectral window/channels
selectdata          =      False        #  Other data selection parameters
solint              =      'inf'        #  Solution interval: egs. 'inf', '60s' (see help)
combine             =         ''        #  Data axes which to combine for solve (scan, spw,
                                        #   and/or field)
preavg              =       -1.0        #  Pre-averaging interval (sec) (rarely needed)
refant              =         ''        #  Reference antenna name.  ' '= '0'
minblperant         =          4        #  Minimum baselines _per antenna_ required for solve
minsnr              =        0.0        #  Reject solutions below this SNR
solnorm             =      False        #  Normalize average solution amplitudes to 1.0 (G, T
                                        #   only)
gaintype            =        'G'        #  Type of gain solution (G, T, or GSPLINE)
calmode             =       'ap'        #  Type of solution" ('ap', 'p', 'a')
append              =      False        #  Append solutions to the (existing) table
gaintable           =       ['']        #  Gain calibration table(s) to apply on the fly
gainfield           =       ['']        #  Select a subset of calibrators from gaintable(s)
interp              =       ['']        #  Temporal interpolation for each gaintable (=linear)
spwmap              =         []        #  Spectral windows combinations to form for
                                        #   gaintables(s)
gaincurve           =      False        #  Apply internal VLA antenna gain curve correction
opacity             =        0.0        #  Opacity correction to apply on the fly (nepers)
parang              =      False        #  Apply parallactic angle correction on the fly
async               =      False        #  If true the taskname must be started using
                                        #   gaincal(...)

This will create a calibration table 'corr.gcal' solving for the gains and phase offsets at all frequencies/spws. After this step, the data can be vector averaged.

2) bandpass: now we combine the two offset frequency observations into a single bandpass solution by averaging. The CASA task is bandpass and the inputs are:

#  bandpass :: Calculates a bandpass calibration solution
vis                 = 'data.ms'         #  Name of input visibility
                                        #   file
caltable            = 'bp12.bcal'       #  Name of output gain calibration table
field               =     '3c286'       #  Select field using field id(s) or field name(s)
spw                 =       '1,2'       #  Select spectral window/channels
selectdata          =      False        #  Other data selection parameters
solint              =      'inf'        #  Solution interval
combine             = 'spw,scan'        #  Data axes which to combine for solve (scan, spw,
                                        #   and/or field)
refant              =         ''        #  Reference antenna name
minblperant         =          4        #  Minimum baselines _per antenna_ required for solve
solnorm             =       True        #  Normalize average solution amplitudes to 1.0 (G, T
                                        #   only)
bandtype            =        'B'        #  Type of bandpass solution (B or BPOLY)
     fillgaps       =          0        #  Fill flagged solution channels by interpolation

append              =      False        #  Append solutions to the (existing) table
gaintable           = ['corr.gcal']     #  Gain calibration table(s) to apply on the fly
gainfield           =       ['']        #  Select a subset of calibrators from gaintable(s)
interp              = ['linear']        #  Interpolation mode (in time) to use for each
                                        #   gaintable
spwmap              = []                #  Spectral windows combinations to form for
                                        #   gaintables(s)
gaincurve           =      False        #  Apply internal VLA antenna gain curve correction
opacity             =        0.0        #  Opacity correction to apply (nepers)
parang              =      False        #  Apply parallactic angle correction
async               =      False        #  If true the taskname must be started using
                                        #   bandpass(...)

The combination of frequencies is done in the

combine             = 'spw,scans'

keyword. And note that the gain calibration table 'corr.gcal' from step 1 is applied in the

gaintable           = ['corr.gcal']

parameter. The resulting bandpass is in the 'bp12.bcal' table, which, however refers to the 'corr.gcal' table. So both tables need to be carried on in the process, step 3.

Note that the combined bandpass of spw 1 and 2 will, by convention, inherit the frequency label of the first spw. This will be shown in the logger as

2010-03-18 01:48:56     INFO    bandpass::::    Combining spws: [1, 2] -> 1

3) applycal: The third step is to apply the bandpass to the source. In the same step, the combined bandpass is mapped to the spw 0. The CASA task is applycal but there are other tasks such as bandpass, accum etc that take on similar input (in fact every task that features the spwmap parameter):

#  applycal :: Apply calibrations solutions(s) to data
vis                 =   'data.ms'       #  Name of input visibility
                                        #   file
field               =   'galaxy'        #  Select field using field id(s) or field name(s)
spw                 =        '0'        #  Select spectral window/channels
selectdata          =      False        #  Other data selection parameters
gaintable           = 'corr.gcal,bp12.bpcal'     #  Gain calibration table(s) to apply on the fly
gainfield           =       ['']        #  Select a subset of calibrators from gaintable(s)
interp              = ['linear,linearrel']        #  Interpolation parameters for each gaintable, as a list 
spwmap              = [[1],[]]          #  Spectral windows combinations to form for
                                        #   gaintables(s)
gaincurve           =      False        #  Apply internal VLA antenna gain curve correction
opacity             =        0.0        #  Opacity correction to apply (nepers)
parang              =      False        #  Apply parallactic angle correction
calwt               =       True        #  Calibrate data weights from all relevant
                                        #   calibrations
async               =      False        #  If true the taskname must be started using
                                        #   applycal(...)


The spw mapping is performed by the spwmap parameter:

spwmap              = [[1],[]]  

here, spw 0 will receive the solution from spw 1, the nominal spw that was assigned when spws 1 and 2 were combined for a solution.

In the interpolation instructions

interp              = ['linear,linearrel']

the first parameter sets the temporal interpolation and the second the frequency interpolation. The 'rel' appendix will do a relative interpolation, ie shift the frequency of the combined bandpass calibration solution that is nominally assigned to spw=1 to spw=0, the central spw.

And don't forget to apply *both* the gain and the bandpass calibration table to your science data.

Now you should have applied the average bandpass from the two offset frequencies in spws 1 and 2 to the central spw 0 and your spectrum shines in perfection.


--Juergen Ott 10 March 2021