Calibrating a Mosaicked Spectral Line Dataset

From CASA Guides
Revision as of 17:19, 30 December 2009 by Mthornle (talk | contribs)
Jump to navigationJump to search


CARMA Tutorials
CASAguides

This page assumes you have converted your data from native MIRIAD format to a CASA measurement set (MS). It also assumes that you have put the filename of the original MS into a global CASA variable, e.g.,

# In CASA
msdir='./'
project='c0xxx'
msfile=msdir+project+'.ms'


Examining your data

The beginning of the output from listobs.
The end of the output from listobs.
plotxy output showing antenna positions.

You'll need some information about the IDs that CASA assigns to your calibrators, sources, and antennas. So if you haven't yet done so,

# In CASA
listobs(vis=msfile)

You will want to look through the listobs output to determine:

  • The Field ID (FldId) of each of your sources and calibrators.
  • The Spectral Window ID (SpwID) of each spectral window you want to calibrate.
  • The Name (or station; the ID number is actually least useful) of your reference antenna.


Near the beginning of the listobs output, you will find the first listing of FldId numbers. In this example, the flux calibrator (NEPTUNE) is assigned FldId=0, the bandpass calibrator (3C454.3) is assigned FldId=1, the phase calibrator (2038+513) is assigned FldId=2, and the mosaicked source fields are assigned FldId 3 through 51 (that's field='3~51' in python).

Near the end of the listobs output, you will find listings of the properties of the observed spectral windows, and the locations of the antennas. In this case, the narrowband windows are assigned to SpwID of 1 and 2, and they each have 63 channels. The reference antenna is Antenna 8, which unfortunately here is named '8'. For unambiguous antenna selection, ideally the Name (which CASA searches first) should have text in it; if it does not, you may want to use the unambiguous Station name of 'ANT8' to ensure that CASA chooses the right antenna.

If you'd prefer a graphical representation of antenna positions in order to choose your reference antenna, you can use plotxy. The following command

# In CASA
plotxy(vis=msfile,xaxis='x')

will display the physical layout of the antennas.You can see antenna 8 near the middle of the CARMA antenna distribution.

Calibrating your data

Before running your calibration, it's a good idea to run the following command:

# In CASA
clearcal(vis=msfile)

If this is the first time you've calibrated, clearcal won't do much, but it will initialize table columns that might be missing from the import step (you may see some output to the log screen to this effect). If you are trying a new calibration, this command ensures your data returns to their original state. So it can't hurt you, and can help.

Calibration in CASA consists of creating calibration tables, and then applying them as needed. Here, we step you through bandpass and amplitude calibration, and then indicate how to apply them to your source data.

Bandpass calibration

The following command (bandpass) will create a bandpass calibration table (caltable=) using the specified bandpass calibrator (field=FldId) and reference antenna (refant), in the same directory as the data are found. No prior gain tables are applied in this step, but they could be if it were necessary (just fill in the appropriate information for gaintable and gainfield).

# In CASA
default('bandpass')
bandpass(vis=msfile,caltable=msdir+project+'.bcal',gaintable='',gainfield='',
         interp='',field='1',spw='',gaincurve=False,
         bandtype='B',solint='inf',refant='ANT8',
         solnorm=True)
plotcal GUI showing the bandpass solutions for some of the antennas.

You can look at the bandpass calibration table you've created using plotcal. This first call will plot the *.bcal table to a GUI for you to look at and interact with--here, you are looking at one of the narrowband spectral windows (spw='1'), and making a 3x2 display of bandpass plots, one for each antenna:

# In CASA
plotcal(caltable=msdir+project+'.bcal',xaxis='chan',yaxis='amp',
        iteration='antenna',subplot=321,spw='1',
        showgui=T)

This second call outputs the same kind of plot to a PNG file (filename specified by 'figfile') without opening the interactive GUI:

# In CASA
plotcal(caltable=msdir+project+'.bcal',xaxis='chan',yaxis='amp',
        iteration='antenna',subplot=321,spw='1',
        showgui=F,figfile='bp_spw0')


Amplitude calibration

Since 3C454.3 is strong enough to serve as both bandpass and flux calibration, we will use it for both in this example. As in AIPS the task setjy is used to provide source information for objects of known flux and distribution. However, 3C454.3 is not currently known by CASA as a flux calibrator, so a source flux density will need to be provided explicitly (e.g., using the CARMA flux calibrator database). For example, if you determine that your calibrator is a point source with a flux density of 6.6 Jy, you would add this information into all spw's in your dataset using the following command:

# In CASA
setjy(vis=msfile, field='1',fluxdensity=[6.6,0.,0.,0.], spw='0~2')

The task gaincal can then be used to determine the appropriate gains to be applied as a function of time. Here, we include both the bandpass calibrator (nice and strong, but not observed often: field='1') and the phase calibrator (weaker, but observed periodically throughout the observations: field='2'). In this example, the wideband data (spw='0') is used for better signal-to-noise, and we have used the station title of the reference antenna (refant='ANT8') to unambiguously identify it.

The bandpass calibration table, specified here by gaintable, is accounted for prior to determining the gain table, so that the two calibrations remain separate. Note: neither the gain or bandpass calibration is actually applied to the source data here; both calibrations will need to be applied after the fact, using applycal (see below).

# In CASA
gaincal(vis=msfile,caltable=msdir+project+'.gcal',gaintable=msdir+project+'.bcal',
        gainfield='1', field='1,2', spw='0', 
        gaintype='G',minsnr=2.0, refant='ANT8', solint='inf', combine='')
plotcal output showing gain calibration for some antennas.

As before with the bandpass calibration table, you can see what the gain calibration table looks like with plotcal (in this example, using the phase calibrator, field='2'):

# In CASA
plotcal(caltable=msdir+proj+'.gcal', yaxis='amp',field='2',
        iteration='antenna',subplot=331,
        showgui=T)

Now that the gains have been determined, you can bootstrap the flux of 3C454.3 to the other sources, using fluxscale. This command uses the gain table (specified by caltable) and needs to be told which source is the reference source (3C454.3, so that reference='1').

# In CASA
fluxscale(vis=msfile,caltable=msdir+project+'.gcal',
          fluxtable=msdir+proj+'.fcal', reference='1')

Note: All of the information from the gain table is contained in the flux table, so in the end, you will apply the bandpass and flux calibration tables in order to apply all relevant calibrations to your source data.

Applying your calibrations

Now that you have solutions for both bandpass and gain calibration, you can apply them to your data. Note that applycal does not operate on the raw data in this step, so you do not need to create a copy of the data before proceeding. Use of the command clearcal will return your data to a pristine state, if needed.

Applycal is fairly flexible, allowing you to apply multiple calibration tables, and calibrations from one spectral window to others (however, you may need to consider the task accum if you have multiple pairs of sources and calibrators in the same dataset; see section 4.3 of Calibrating a VLA 5 GHz continuum survey for an example using VLA data).

Here are two examples of applying calibrations, but these are still relatively simple. Consult the helpfile for applycal for a detailed explanation of how to use this command--note in particular the use of the parameter spwmap.

In the first example, we apply calibrations to the bandpass/flux calibrator (3C454.3, field='1'). We apply both bandpass and flux calibration table. The order of entries in gainfield and spwmap are the same as for gaintable: in this case, it means that we take the bandpass calibration for 3C454.3 (gainfield=['1',...) and apply the solutions for each spectral window to the same spectral window for the other sources (spwmap=[[],...), but we take the gain/flux calibration of the same source (gainfield=...,'1']from the wideband channel (spw='0') and apply it to all spectra windows (spwmap=...,[0]]).

You would only want to do this if you wanted to image the bandpass/flux calibrator.

# In CASA
applycal(vis=catfile,field='1',spw='',  
         gaintable=[msdir+project+'.bcal',msdir+project+'.fcal'],
         gainfield=['1','1'],spwmap=[[],[0]])

In this second example, we apply bandpass and flux calibrations to the rest of the observed objects (phase calibrator, field='2'; source, field='3~51'). In this case, we use the gain/flux calibration information for the phase calibrator to apply to the source, as it has finer time sampling.

# In CASA
applycal(vis=catfile,field='2~51',spw='',  
         gaintable=[msdir+project+'.bcal',msdir+project+'.fcal'],
         gainfield=['1','2'],spwmap=[[],[0]])

Calibration is now complete! Proceed onward to Imaging a Mosaicked Spectral Line Dataset.

CARMA Tutorials
CASAguides

--Michele Thornley, 28 December 2009