ALMA SIS14 apcal: Difference between revisions

From CASA Guides
Jump to navigationJump to search
No edit summary
Line 109: Line 109:
         plotrange=[0,0,-180,180],
         plotrange=[0,0,-180,180],
         fontsize=20,
         fontsize=20,
         markersize=10,
         markersize=10)
)
</source>
</source>


Line 173: Line 172:
         subplot=331,
         subplot=331,
         iteration="antenna",
         iteration="antenna",
         plotrange=[0,0,0,0])
         plotrange=[0,0,0,0],
        fontsize=20,
        markersize=10)
</source>
</source>
[[Image:plotcal_amp_1.png|center|600px]]


== Another Approach Phase and Amplitude Calibration (per Integration) ==
== Another Approach Phase and Amplitude Calibration (per Integration) ==

Revision as of 12:16, 4 March 2014

This lesson steps through the basic calibration of the phase and amplitude response of each telescope as a function of time.

Setup

To run this tutorial, you need the measurements set "sis14_ampandphase.ms." This measurement set contains only a quasar (the phase calibrator from the parent data set). If you are using the pre-provided directory structure then you want to work in the directory (relative to the root for the package):

lessons/basic_cal/

and you can copy the data to your working directory using the commands

# In CASA
os.system("rm -rf sis14_ampandphase.ms")
os.system("cp -r ../../working_data/sis14_ampandphase.ms sis14_ampandphase.ms")

With this measurement set in place, you can follow the tutorial below inside the "basic_cal/" directory.

Overview

This lesson covers basic calibration. We will use observations of a quasar, which can be assumed to be a point source at the middle of the field. Mainly using the task gaincal, we will derive the time-dependent corrections to the phase and amplitude response of each antenna that cause the observations to best match this model. These corrections are stored in a calibration table by CASA. They can be applied to the data, correcting observations of both the source and the quasar.

This whole procedure makes an underlying assumption about the quasar's geometry (we take it to be a point source) and assumes that antenna-dependent terms are calibration issues rather than something astronomical. The latter is a very good assumption that underlies most of the calibration we do. The geometry of the quasar can be checked and modeled in a more sophisticated way if necessary. A future lesson gives an example of this procedure for planets.

The flow of the lesson is:

  • We orient ourselves using listobs
  • We derive phase corrections for each antenna using gaincal
  • We inspect these phase corrections using plotcal
  • We derive amplitude corrections for each antenna using gaincal and taking into account the phase corrections
  • We inspect the amplitude corrections using plotcal

After the main lesson we discuss some additional options and advanced strategies that can be used with gaincal.

Get Oriented

First, as usual we orient ourselves by looking at the output of listobs (and perhaps plotants or a plotms call). See the lesson on getting started for more details.

# In CASA
listobs("sis14_ampandphase.ms")

A snippet of the output is here:

2014-02-28 19:56:10 INFO listobs	  19-Nov-2012/07:52:42.0 - 07:53:47.6    10      0 J1037-295                 2760  [0]  [6.05] [CALIBRATE_PHASE#ON_SOURCE, CALIBRATE_WVR#ON_SOURCE]
2014-02-28 19:56:10 INFO listobs	              08:04:36.3 - 08:05:41.9    14      0 J1037-295                 3000  [0]  [6.05] [CALIBRATE_PHASE#ON_SOURCE, CALIBRATE_WVR#ON_SOURCE]
2014-02-28 19:56:10 INFO listobs	              08:16:20.6 - 08:17:26.2    18      0 J1037-295                 3000  [0]  [6.05] [CALIBRATE_PHASE#ON_SOURCE, CALIBRATE_WVR#ON_SOURCE]
2014-02-28 19:56:10 INFO listobs	              08:28:17.1 - 08:29:22.6    22      0 J1037-295                 3000  [0]  [6.05] [CALIBRATE_PHASE#ON_SOURCE, CALIBRATE_WVR#ON_SOURCE]
2014-02-28 19:56:10 INFO listobs	              08:40:11.9 - 08:41:17.4    26      0 J1037-295                 3000  [0]  [6.05] [CALIBRATE_PHASE#ON_SOURCE, CALIBRATE_WVR#ON_SOURCE]
2014-02-28 19:56:10 INFO listobs	              08:51:57.1 - 08:53:02.6    30      0 J1037-295                 3000  [0]  [6.05] [CALIBRATE_PHASE#ON_SOURCE, CALIBRATE_WVR#ON_SOURCE]
2014-02-28 19:56:10 INFO listobs	              09:01:35.7 - 09:02:41.2    34      0 J1037-295                 2530  [0]  [6.05] [CALIBRATE_PHASE#ON_SOURCE, CALIBRATE_WVR#ON_SOURCE]
2014-02-28 19:56:10 INFO listobs	              09:09:59.1 - 09:11:04.7    38      0 J1037-295                 2530  [0]  [6.05] [CALIBRATE_PHASE#ON_SOURCE, CALIBRATE_WVR#ON_SOURCE]

From the output of listobs we can see that this data set contains a single spectral window and a single source, the quasar J1037-295. The was the phase calibrator for the original data set (note the scan intent of "CALIBRATE_PHASE") and was originally visited in between integrations on the science source. Each visit to the the quasar was about a minute long.

Following the earlier lesson, we pick out DV22 as a reasonable reference antenna that sits near the center of the array.

Phase Calibration

Our first calibration step is to derive a phase correction for each antenna as a function of time. The task gaincal does this, attempting to match the DATA column (i.e., the measurements) to the MODEL column (the expected visibility). In the absence of any MODEL column (and this is the case here), gaincal tries to match the observed data to a point source of amplitude 1 Jy at the center of the field (we'll discuss the correct amplitude scaling in an upcoming lesson).

For now, calibrate the phase corrections only using:

# In CASA
os.system("rm -rf phase.cal")
gaincal(vis="sis14_ampandphase.ms",
        caltable="phase.cal",
        field="0",
        solint="inf",
        calmode="p",
        refant="DV22",
        gaintype="G")

These commands do the following:

  • First, we delete any previous table using the os.system call.
  • Then we tell gaincal to consider the measurement set "sis14_ampandphase.ms" (via vis).
  • We tell gaincal that we want the output written to the calibration table "phase.cal" (via caltable).
  • We tell gaincal to consider only the quasar, which we know is field number 0 from the listobs (field=0). This is not necessary in this one-source data set, but is usually important.
  • We ask gaincal to solve only for the phase solutions by saying calmode="p".
  • We specify DV22 as our reference antenna (refant). This antenna will have phase correction 0 by definition (the other corrections are relative to the refant).
  • We ask gaincal to solve for a correction for each "correlation" (i.e., each polarization) by specifying gaintype="G".
  • Finally, we specify that we want to combine data across the longest possible time interval by setting the solution interval to infinity (solint="inf"), but because gaincal will not combine across scans (or spws or fields) by default, solint="inf" can be read "solve for the phase correction for each antenna for each scan."

Run this command the results will be written to a new directory, "phase.cal" that contains the calibration table holding the phase corrections. You may want to briefly inspect the directory using linux/unix commands (e.g., "ls phase.cal") just to understand the directory structure. But this isn't strictly necessary. From CASA's perspective the directory "phase.cal" is now a calibration table suitable for use in other tasks.

Read more about the choices involved in gaincal at the end of the lesson.

Inspect Your Phase Calibration Table

Now we plot the results of the calibration. plotcal is the CASA task for plotting calibration tables. We will plot the phase correction as a function of time for our new table via the command:

# In CASA
plotcal(caltable="phase.cal", 
        xaxis="time",
        yaxis="phase",
        iteration="antenna",
        subplot=331,
        plotrange=[0,0,-180,180],
        fontsize=20,
        markersize=10)

This does the following:

  • We plot the calibration table "phase.cal"
  • We choose to plot time on the x-axis.
  • We choose to plot the phase correction to be applied on the y-axis.
  • We want a plot for each antenna and so set iteration to "antenna".
  • We want several plots per page, subplot=331 will plot 3x3 panels with one plot per panel.
  • We set the plot range (via plotrange) to autoscale on the x-axis (0,0) and run from (-180,180) on the y-axis.
  • We set markersize and fontsize to very large values in order to make the plots legible for screen capture.

This produces the plot below. You are able to cycle between successive panels using the buttons at the bottom of the window. For example, because there are more than 9 antennas in these data we will need to do this to see all the plots. Note tat you see two points in each plot because we have a solution for each polarization.

Plotcal phase 1.png

Phase corrections vs. time for our "phase.cal" table. Each panel shows one antenna, the two colors show the two correlations.

What are you looking for in these tables? A well-behaved calibration table shows continuous trends 
in phase and often the same pattern in both calibrations - though perhaps with an overall offset. 
Ideally a stable antenna will change phase only gradually as a function of time. Rapid wrapping may 
be a sign for alarm. Sudden, large jumps in phases may also be a signal for worry; we often want to 
be able to interpolate between these corrections and sudden jumps can make this difficult (or impossible). 
Depending on the application, you may also be interested in the overall amplitude of the solution; e.g., 
when engaged in iterative self-calibration the amplitude of the phase correction is of interest.

For now, these solutions look good. See how they change only gradually and continuously with time and how the two correlations (green and blue) track one another, though sometimes with an offset. We proceed to amplitude self-calibration.

Amplitude Calibration (per Scan)

Now we calibrate the amplitude response of each antenna as a function of time. We have already solved for the phase correction for each scan. Here we will apply these corrections and derive a scaling factor for the amplitude.

# In CASA
os.system("rm -rf amp.cal")
gaincal(vis="sis14_ampandphase.ms",
        caltable="amp.cal",
        field="0",
        solint="inf",
        calmode="a",
        refant="DV22",
        gaintype="G",
        gaintable="phase.cal")

This is fairly similar to the earlier phase cal. Key differences are:

  • We tell gaincal that we want the output written to a new calibration table "amp.cal" (via caltable).
  • We ask gaincal to solve only for the amplitude solutions by saying calmode="a".
  • We apply a previous calibration table "on the fly", meaning that these corrections are applied before the new ones are derived. We provide the previous calibration table via the gaintable parameter. In the end, we will need to apply both for a full solution.

Next we plot the results of this fit, again using plotcal:

# In CASA
plotcal(caltable="amp.cal", 
        xaxis="time",
        yaxis="amp",
        subplot=331,
        iteration="antenna",
        plotrange=[0,0,0,0],
        fontsize=20,
        markersize=10)
Plotcal amp 1.png

Another Approach Phase and Amplitude Calibration (per Integration)

We can also solve for the antenna corrections on shorter timescales.

# In CASA
os.system("rm -rf apcal_int.cal")
gaincal(vis="sis14_ampandphase.ms",
        caltable="apcal_int.cal",
        field="0",
        solint="int",
        calmode="ap",
        refant="DV22",
        gaintype="G")

Plot the per-integration variation of the phase.

# In CASA
plotcal(caltable="apcal_int.cal", 
        xaxis="time",
        yaxis="phase",
        subplot=331,
        iteration="antenna",
        plotrange=[0,0,-180,180])

Now plot the per-integration variation of the amplitude.

# In CASA
plotcal(caltable="apcal_int.cal", 
        xaxis="time",
        yaxis="amp",
        subplot=331,
        iteration="antenna",
        plotrange=[0,0,0,0])

Advanced Considerations

Averaging Options

"Layering" Calibrations

Removing Short-Timescale Phase Variations Before Amplitude Calibration?