Combining Bandpasses: Difference between revisions

From CASA Guides
Jump to navigationJump to search
No edit summary
No edit summary
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
''Under construction''
{{Using CASA Hints Tips Tricks}}


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


A technique to still obtain a usable bandpass solution is to observe frequencies offset to the main frequency. These offset frequencies should be chosen clean from any line contamination. Ideally it is advisable to observe two offset frequencies, symmetric to the main observing frequency.  
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.
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, a frequency +4MHz offset and on -4MHz offset. In this example, the spectral windows (spw), are 0, 1, and 2, respectively. Bandpass calibrator in the example below is 3c286 and the source 'galaxy'.
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:
Three steps are needed:


'''1) gaincal:''' the offset frequencies typically also have different phases. Since the bandpass is obtained by 'vector averaging' the data, one needs to correct for the phase offsets. The best way to do this is to derive and apply a complex gain solution for all spw.  
'''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:


<pre>
<pre>
Line 48: Line 50:
</pre>  
</pre>  


This will create a calibration table 'corr.gcal' solving for the gains and phase offests of all frequencies. After this step, the data can be vector averaged.
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.
'''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:


<pre>
<pre>
Line 58: Line 60:
caltable            = 'bp12.bcal'      #  Name of output gain calibration table
caltable            = 'bp12.bcal'      #  Name of output gain calibration table
field              =    '3c286'      #  Select field using field id(s) or field name(s)
field              =    '3c286'      #  Select field using field id(s) or field name(s)
spw                =      '1,2'       #  Select spectral window/channels
spw                =      '1,2'       #  Select spectral window/channels
selectdata          =      False        #  Other data selection parameters
selectdata          =      False        #  Other data selection parameters
solint              =      'inf'        #  Solution interval
solint              =      'inf'        #  Solution interval
combine            = 'spw,scan'       #  Data axes which to combine for solve (scan, spw,
combine            = 'spw,scan'       #  Data axes which to combine for solve (scan, spw,
                                         #  and/or field)
                                         #  and/or field)
refant              =        ''        #  Reference antenna name
refant              =        ''        #  Reference antenna name
Line 94: Line 96:
gaintable          = ['corr.gcal']
gaintable          = ['corr.gcal']
</pre>
</pre>
parameter. The resulting bandpass is in the 'bp12.bcal', which, however refers to the 'corr.gcal' table. So both of the tables need to be carried further in the process, step 3.  
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


'''3) applycal:''' The combined bandpass will, by definition, be based on the frequency of the first input spw. The third step is map this solution to the central spw.
<pre>
2010-03-18 01:48:56    INFO    bandpass::::    Combining spws: [1, 2] -> 1
</pre>
 
'''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):


<pre>
<pre>
#  applycal :: Apply calibrations solutions(s) to data
#  applycal :: Apply calibrations solutions(s) to data
vis                = '9_4_sb1190721_1_000.55268.03407332176.ms' #  Name of input visibility
vis                =   'data.ms'       #  Name of input visibility
                                         #  file
                                         #  file
field              =         ''        #  Select field using field id(s) or field name(s)
field              =   'galaxy'        #  Select field using field id(s) or field name(s)
spw                =        '0'        #  Select spectral window/channels
spw                =        '0'        #  Select spectral window/channels
selectdata          =      False        #  Other data selection parameters
selectdata          =      False        #  Other data selection parameters
gaintable          = '34on0.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              = [0, 0, 0, 0, 0, 0, 0, 0, 0] #  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 121: Line 128:




The spw mapping is performed by the ''spwmap'' parameter:


#  bandpass :: Calculates a bandpass calibration solution
<pre>
vis                = '9_4_sb1190721_1_000.55268.03407332176.ms' # Name of input visibility
spwmap              = [[1],[]]  
                                        #  file
</pre>
caltable            = 'gainbp34on0.cal' #  Name of output gain calibration table
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.  
field              =        ''        #  Select field using field id(s) or field name(s)
 
spw                =        '0'        #  Select spectral window/channels
In the interpolation instructions
selectdata          =      False        #  Other data selection parameters
<pre>
solint             =     'inf'       #  Solution interval
interp             = ['linear,linearrel']
combine            =        ''        #  Data axes which to combine for solve (scan, spw,
</pre>
                                        #  and/or field)
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.
refant              =        ''       #  Reference antenna name
 
minblperant        =          4        #  Minimum baselines _per antenna_ required for solve
And don't forget to apply *both* the gain and the bandpass calibration table to your science data.
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
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.  
gaintable          = ['gainbp34.cal']  #  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              = [3, 3, 3, 3, 3, 3] #  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(...)




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

Latest revision as of 15: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