EVLA Continuum Tutorial 3C391: Difference between revisions

From CASA Guides
Jump to navigationJump to search
Jlazio (talk | contribs)
Jott (talk | contribs)
 
(264 intermediate revisions by 9 users not shown)
Line 1: Line 1:
[[Category:EVLA]][[Category:Calibration]]
#REDIRECT [[EVLA Continuum Tutorial 3C391-CASA4.6]]
 
== Overview ==
This article describes the calibration and imaging of a multiple-pointing EVLA continuum dataset on the supernova remnant 3C 391.  The data were taken in OSRO1 mode, with 128 MHz of bandwidth in each of two widely spaced spectral windows, centered at 4.6 and 7.5 GHz, and were set up for full polarization calibration.  To generate the full data reduction script described here, use the [[Extracting_scripts_from_these_tutorials | script extractor]].
 
== Getting hold of your data ==
The data are publicly available from the [https://archive.nrao.edu/archive/archiveproject.jsp NRAO archive], under Project name TDEM0001.  The archive lists two separate files; one taken on 2010-Apr-15, and the other on 2010-Apr-24.  You will want to download the second file (file size 39.79 GB).  This file contains data at the full 1-s time resolution.
 
== Loading in your data ==
<source lang="python">
importevla(asdm='TDEM0001_sb1218006_1.55310.33439732639',vis='3c391_mosaic_fullres.ms',flagzero=True,shadow=True)
</source>
 
== Examining your data ==
 
Before starting the calibration process, we want to get some basic information about the data set.  To examine the observing conditions during the observing run, and to find out any known problems with the data, download the [http://www.vla.nrao.edu/cgi-bin/oplogs.cgi observer log].  Simply fill in the known observing date (in our case 2010-Apr-24) as both the Start and Stop date, and click on the "Show Logs" button.  The relevant log is labeled with the project code, TDEM0001, and can be downloaded as a PDF file.
 
To get a listing of the individual scans comprising the observation, the frequency setup, source list, and antenna locations, use the task [[listobs]].
 
<source lang="python">
listobs(vis='3c391_ctm_mosaic_10s.ms',verbose=T)
</source>
 
listobs should now produce the following output in the casa logger:
 
<pre style="background-color: #ffe4b5;">
2010-04-27 19:16:49 INFO listobs::::casa ##########################################
2010-04-27 19:16:49 INFO listobs::::casa ##### Begin Task: listobs            #####
2010-04-27 19:16:49 INFO listobs::::casa
2010-04-27 19:16:49 INFO listobs::ms::summary ================================================================================
2010-04-27 19:16:49 INFO listobs::ms::summary+           MeasurementSet Name:  /export/home/hamal/jmiller/TDEM0001_sb1218006/3c391_mosaic_fullres.ms      MS Version 2
2010-04-27 19:16:49 INFO listobs::ms::summary+ ================================================================================
2010-04-27 19:16:49 INFO listobs::ms::summary+   Observer: Dr. James Miller-Jones    Project: T.B.D. 
2010-04-27 19:16:49 INFO listobs::ms::summary+ Observation: EVLA
2010-04-27 19:16:49 INFO listobs::ms::summary Data records: 18666050      Total integration time = 28716 seconds
2010-04-27 19:16:49 INFO listobs::ms::summary+   Observed from  24-Apr-2010/08:01:34.5  to  24-Apr-2010/16:00:10.5 (UTC)
2010-04-27 19:17:47 INFO listobs::ms::summary
2010-04-27 19:17:47 INFO listobs::ms::summary+   ObservationID = 0        ArrayID = 0
2010-04-27 19:17:47 INFO listobs::ms::summary+   Date        Timerange (UTC)          Scan  FldId FieldName    nVis  Int(s)  SpwIds
2010-04-27 19:17:47 INFO listobs::ms::summary+   24-Apr-2010/08:01:34.5 - 08:02:28.5    1      0 J1331+3030  35750  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:02:29.5 - 08:09:27.5    2      0 J1331+3030  272350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:09:28.5 - 08:16:26.5    3      0 J1331+3030  272350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:16:27.5 - 08:24:25.5    4      1 J1822-0938  311350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:24:26.5 - 08:29:44.5    5      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:29:45.5 - 08:34:43.5    6      3 3C391 C2    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:34:44.5 - 08:39:42.5    7      4 3C391 C3    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:39:43.5 - 08:44:41.5    8      5 3C391 C4    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:44:42.5 - 08:49:40.5    9      6 3C391 C5    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:49:41.5 - 08:54:40.5    10      7 3C391 C6    195000 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:54:41.5 - 08:59:39.5    11      8 3C391 C7    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               08:59:40.5 - 09:01:29.5    12      1 J1822-0938  71500  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:01:30.5 - 09:06:48.5    13      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:06:49.5 - 09:11:47.5    14      3 3C391 C2    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:11:48.5 - 09:16:46.5    15      4 3C391 C3    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:16:47.5 - 09:21:45.5    16      5 3C391 C4    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:21:46.5 - 09:26:44.5    17      6 3C391 C5    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:26:45.5 - 09:31:44.5    18      7 3C391 C6    195000 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:31:45.5 - 09:36:43.5    19      8 3C391 C7    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:36:44.5 - 09:38:32.5    20      1 J1822-0938  70850  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:38:33.5 - 09:43:52.5    21      2 3C391 C1    208000 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:43:53.5 - 09:48:51.5    22      3 3C391 C2    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:48:52.5 - 09:53:50.5    23      4 3C391 C3    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:53:51.5 - 09:58:49.5    24      5 3C391 C4    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               09:58:50.5 - 10:03:48.5    25      6 3C391 C5    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:03:49.5 - 10:08:47.5    26      7 3C391 C6    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:08:48.5 - 10:13:47.5    27      8 3C391 C7    195000 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:13:48.5 - 10:15:36.5    28      1 J1822-0938  70850  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:15:37.5 - 10:20:55.5    29      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:20:56.5 - 10:25:55.5    30      3 3C391 C2    195000 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:25:56.5 - 10:30:54.5    31      4 3C391 C3    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:30:55.5 - 10:35:53.5    32      5 3C391 C4    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:35:54.5 - 10:40:52.5    33      6 3C391 C5    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:40:53.5 - 10:45:51.5    34      7 3C391 C6    194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:45:52.5 - 10:50:51.5    35      8 3C391 C7    195000 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:50:52.5 - 10:52:40.5    36      1 J1822-0938  70850  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:52:41.5 - 10:57:39.5    37      0 J1331+3030  194350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               10:57:40.5 - 11:02:39.5    38      1 J1822-0938  195000 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:02:40.5 - 11:07:58.5    39      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:07:59.5 - 11:12:47.5    40      3 3C391 C2    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:12:48.5 - 11:17:36.5    41      4 3C391 C3    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:17:37.5 - 11:22:25.5    42      5 3C391 C4    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:22:26.5 - 11:27:15.5    43      6 3C391 C5    188500 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:27:16.5 - 11:32:04.5    44      7 3C391 C6    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:32:05.5 - 11:36:53.5    45      8 3C391 C7    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:36:54.5 - 11:38:43.5    46      1 J1822-0938  71500  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:38:44.5 - 11:44:02.5    47      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:44:03.5 - 11:48:51.5    48      3 3C391 C2    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:48:52.5 - 11:53:40.5    49      4 3C391 C3    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:53:41.5 - 11:58:29.5    50      5 3C391 C4    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               11:58:30.5 - 12:03:19.5    51      6 3C391 C5    188500 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:03:20.5 - 12:08:08.5    52      7 3C391 C6    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:08:09.5 - 12:12:57.5    53      8 3C391 C7    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:12:58.5 - 12:14:47.5    54      1 J1822-0938  71500  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:14:48.5 - 12:20:06.5    55      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:20:07.5 - 12:24:55.5    56      3 3C391 C2    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:24:56.5 - 12:29:44.5    57      4 3C391 C3    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:29:45.5 - 12:34:34.5    58      5 3C391 C4    188500 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:34:35.5 - 12:39:23.5    59      6 3C391 C5    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:39:24.5 - 12:44:12.5    60      7 3C391 C6    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:44:13.5 - 12:49:01.5    61      8 3C391 C7    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:49:02.5 - 12:50:51.5    62      1 J1822-0938  71500  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:50:52.5 - 12:56:10.5    63      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               12:56:11.5 - 13:00:59.5    64      3 3C391 C2    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:01:00.5 - 13:05:48.5    65      4 3C391 C3    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:05:49.5 - 13:10:38.5    66      5 3C391 C4    188500 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:10:39.5 - 13:15:27.5    67      6 3C391 C5    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:15:28.5 - 13:20:16.5    68      7 3C391 C6    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:20:17.5 - 13:25:05.5    69      8 3C391 C7    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:25:06.5 - 13:26:55.5    70      1 J1822-0938  71500  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:26:56.5 - 13:32:14.5    71      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:32:15.5 - 13:37:03.5    72      3 3C391 C2    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:37:04.5 - 13:41:52.5    73      4 3C391 C3    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:41:53.5 - 13:46:42.5    74      5 3C391 C4    188500 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:46:43.5 - 13:51:31.5    75      6 3C391 C5    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:51:32.5 - 13:56:20.5    76      7 3C391 C6    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               13:56:21.5 - 14:01:09.5    77      8 3C391 C7    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:01:10.5 - 14:02:59.5    78      1 J1822-0938  71500  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:03:00.5 - 14:08:18.5    79      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:08:19.5 - 14:13:07.5    80      3 3C391 C2    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:13:08.5 - 14:17:57.5    81      4 3C391 C3    188500 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:17:58.5 - 14:22:46.5    82      5 3C391 C4    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:22:47.5 - 14:27:35.5    83      6 3C391 C5    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:27:36.5 - 14:32:24.5    84      7 3C391 C6    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:32:25.5 - 14:37:13.5    85      8 3C391 C7    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:37:14.5 - 14:39:03.5    86      1 J1822-0938  71500  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:39:04.5 - 14:44:22.5    87      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:44:23.5 - 14:49:11.5    88      3 3C391 C2    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:49:12.5 - 14:54:01.5    89      4 3C391 C3    188500 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:54:02.5 - 14:58:50.5    90      5 3C391 C4    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               14:58:51.5 - 15:03:39.5    91      6 3C391 C5    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:03:40.5 - 15:08:28.5    92      7 3C391 C6    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:08:29.5 - 15:13:17.5    93      8 3C391 C7    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:13:18.5 - 15:15:07.5    94      1 J1822-0938  71500  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:15:08.5 - 15:20:26.5    95      2 3C391 C1    207350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:20:27.5 - 15:25:15.5    96      3 3C391 C2    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:25:16.5 - 15:30:05.5    97      4 3C391 C3    188500 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:30:06.5 - 15:34:54.5    98      5 3C391 C4    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:34:55.5 - 15:39:43.5    99      6 3C391 C5    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:39:44.5 - 15:44:32.5  100      7 3C391 C6    187850 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:44:33.5 - 15:49:22.5  101      8 3C391 C7    188500 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:49:23.5 - 15:51:11.5  102      1 J1822-0938  70850  1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary+               15:51:12.5 - 16:00:10.5  103      9 J0319+4130  350350 1        [0, 1]
2010-04-27 19:17:47 INFO listobs::ms::summary           (nVis = Total number of time/baseline visibilities per scan)
2010-04-27 19:17:51 INFO listobs::ms::summary Fields: 10
2010-04-27 19:17:51 INFO listobs::ms::summary+   ID  Code Name        RA            Decl          Epoch  SrcId nVis 
2010-04-27 19:17:51 INFO listobs::ms::summary+   0    N    J1331+3030  13:31:08.2880 +30.30.32.9589 J2000  0    774800
2010-04-27 19:17:51 INFO listobs::ms::summary+   1    J    J1822-0938  18:22:28.7042 -09.38.56.8350 J2000  1    1361750
2010-04-27 19:17:51 INFO listobs::ms::summary+   2    NONE 3C391 C1    18:49:24.2440 -00.55.40.5800 J2000  2    2488850
2010-04-27 19:17:51 INFO listobs::ms::summary+   3    NONE 3C391 C2    18:49:29.1490 -00.57.48.0000 J2000  3    2280850
2010-04-27 19:17:51 INFO listobs::ms::summary+   4    NONE 3C391 C3    18:49:19.3390 -00.57.48.0000 J2000  4    2282150
2010-04-27 19:17:51 INFO listobs::ms::summary+   5    NONE 3C391 C4    18:49:14.4340 -00.55.40.5800 J2000  5    2282150
2010-04-27 19:17:51 INFO listobs::ms::summary+   6    NONE 3C391 C5    18:49:19.3390 -00.53.33.1600 J2000  6    2281500
2010-04-27 19:17:51 INFO listobs::ms::summary+   7    NONE 3C391 C6    18:49:29.1490 -00.53.33.1600 J2000  7    2281500
2010-04-27 19:17:51 INFO listobs::ms::summary+   8    NONE 3C391 C7    18:49:34.0540 -00.55.40.5800 J2000  8    2282150
2010-04-27 19:17:51 INFO listobs::ms::summary+   9    Z    J0319+4130  03:19:48.1601 +41.30.42.1030 J2000  9    350350
2010-04-27 19:17:51 INFO listobs::ms::summary+   (nVis = Total number of time/baseline visibilities per field)
2010-04-27 19:17:54 INFO listobs::ms::summary Spectral Windows:  (2 unique spectral windows and 1 unique polarization setups)
2010-04-27 19:17:54 INFO listobs::ms::summary+   SpwID  #Chans Frame Ch1(MHz)    ChanWid(kHz)TotBW(kHz)  Ref(MHz)    Corrs         
2010-04-27 19:17:54 INFO listobs::ms::summary+   0          64 TOPO  4536        2000        128000      4536        RR  RL  LR  LL 
2010-04-27 19:17:54 INFO listobs::ms::summary+   1          64 TOPO  7436        2000        128000      7436        RR  RL  LR  LL 
2010-04-27 19:17:54 INFO listobs::ms::summary Sources: 20
2010-04-27 19:17:54 INFO listobs::ms::summary+   ID  Name        SpwId RestFreq(MHz)  SysVel(km/s)
2010-04-27 19:17:54 INFO listobs::ms::summary+   0    J1331+3030  0    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   0    J1331+3030  1    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   1    J1822-0938  0    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   1    J1822-0938  1    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   2    3C391 C1    0    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   2    3C391 C1    1    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   3    3C391 C2    0    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   3    3C391 C2    1    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   4    3C391 C3    0    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   4    3C391 C3    1    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   5    3C391 C4    0    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   5    3C391 C4    1    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   6    3C391 C5    0    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   6    3C391 C5    1    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   7    3C391 C6    0    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   7    3C391 C6    1    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   8    3C391 C7    0    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   8    3C391 C7    1    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   9    J0319+4130  0    -              -           
2010-04-27 19:17:54 INFO listobs::ms::summary+   9    J0319+4130  1    -              -           
2010-04-27 19:18:02 INFO listobs::ms::summary Antennas: 26:
2010-04-27 19:18:02 INFO listobs::ms::summary+   ID  Name  Station  Diam.    Long.        Lat.       
2010-04-27 19:18:02 INFO listobs::ms::summary+   0    ea01  W09      25.0 m  -107.37.25.2  +33.53.51.0 
2010-04-27 19:18:02 INFO listobs::ms::summary+   1    ea02  E02      25.0 m  -107.37.04.4  +33.54.01.1 
2010-04-27 19:18:02 INFO listobs::ms::summary+   2    ea03  E09      25.0 m  -107.36.45.1  +33.53.53.6 
2010-04-27 19:18:02 INFO listobs::ms::summary+   3    ea04  W01      25.0 m  -107.37.05.9  +33.54.00.5 
2010-04-27 19:18:02 INFO listobs::ms::summary+   4    ea05  W08      25.0 m  -107.37.21.6  +33.53.53.0 
2010-04-27 19:18:02 INFO listobs::ms::summary+   5    ea07  N06      25.0 m  -107.37.06.9  +33.54.10.3 
2010-04-27 19:18:02 INFO listobs::ms::summary+   6    ea08  N01      25.0 m  -107.37.06.0  +33.54.01.8 
2010-04-27 19:18:02 INFO listobs::ms::summary+   7    ea09  E06      25.0 m  -107.36.55.6  +33.53.57.7 
2010-04-27 19:18:02 INFO listobs::ms::summary+   8    ea11  E04      25.0 m  -107.37.00.8  +33.53.59.7 
2010-04-27 19:18:02 INFO listobs::ms::summary+   9    ea12  E08      25.0 m  -107.36.48.9  +33.53.55.1 
2010-04-27 19:18:02 INFO listobs::ms::summary+   10  ea13  N07      25.0 m  -107.37.07.2  +33.54.12.9 
2010-04-27 19:18:02 INFO listobs::ms::summary+   11  ea14  E05      25.0 m  -107.36.58.4  +33.53.58.8 
2010-04-27 19:18:02 INFO listobs::ms::summary+   12  ea15  W06      25.0 m  -107.37.15.6  +33.53.56.4 
2010-04-27 19:18:02 INFO listobs::ms::summary+   13  ea16  W02      25.0 m  -107.37.07.5  +33.54.00.9 
2010-04-27 19:18:02 INFO listobs::ms::summary+   14  ea17  W07      25.0 m  -107.37.18.4  +33.53.54.8 
2010-04-27 19:18:02 INFO listobs::ms::summary+   15  ea18  N09      25.0 m  -107.37.07.8  +33.54.19.0 
2010-04-27 19:18:02 INFO listobs::ms::summary+   16  ea19  W04      25.0 m  -107.37.10.8  +33.53.59.1 
2010-04-27 19:18:02 INFO listobs::ms::summary+   17  ea20  N05      25.0 m  -107.37.06.7  +33.54.08.0 
2010-04-27 19:18:02 INFO listobs::ms::summary+   18  ea21  E01      25.0 m  -107.37.05.7  +33.53.59.2 
2010-04-27 19:18:02 INFO listobs::ms::summary+   19  ea22  N04      25.0 m  -107.37.06.5  +33.54.06.1 
2010-04-27 19:18:02 INFO listobs::ms::summary+   20  ea23  E07      25.0 m  -107.36.52.4  +33.53.56.5 
2010-04-27 19:18:02 INFO listobs::ms::summary+   21  ea24  W05      25.0 m  -107.37.13.0  +33.53.57.8 
2010-04-27 19:18:02 INFO listobs::ms::summary+   22  ea25  N02      25.0 m  -107.37.06.2  +33.54.03.5 
2010-04-27 19:18:02 INFO listobs::ms::summary+   23  ea26  W03      25.0 m  -107.37.08.9  +33.54.00.1 
2010-04-27 19:18:02 INFO listobs::ms::summary+   24  ea27  E03      25.0 m  -107.37.02.8  +33.54.00.5 
2010-04-27 19:18:02 INFO listobs::ms::summary+   25  ea28  N08      25.0 m  -107.37.07.5  +33.54.15.8 
2010-04-27 19:18:02 INFO listobs::::casa
2010-04-27 19:18:02 INFO listobs::::casa ##### End Task: listobs              #####
2010-04-27 19:18:02 INFO listobs::::casa ##########################################
</pre>
 
Both to get a sense of the array, as well as identify an antenna for later use in calibration, use the task [[plotants]].  In general, for calibration purposes, one would like to select an antenna that is close to the center of the array (and that is not listed in the operator's log as having had problems!). 
 
<source lang="python">
plotants(vis='3c391_ctm_mosaic_10s.ms',figfile='3c391_ctm_mosaic_antenna_layout.png')
</source>
 
[[Image:3c391_ctm_plotants_parameters.jpg|200px|thumb|left|plotants parameters]]
[[Image:3C391_mosaic-plotants.png|200px|thumb|center|plotants figure]]
 
== Examining and Editing the Data ==
 
It is always a good idea, particularly with a new system like the EVLA, to examine the data.  Moreover, from the observer's log, we already know that one antenna will need to be flagged because it does not have a C-band receiver.  Start by flagging data known to be bad, then examine the data.
 
In its current operation, it is common to insert a dummy scan as the first scan.  (From the [[listobs]] output above, one may have noticed that the first scan is only 10 seconds long.)  This first scan can safely be deleted.
<source lang="python">
flagdata(vis='3c391_ctm_mosaic_10s.ms',flagbackup=T,mode='manualflag',selectdata=T,scan='1')
</source>
 
* <strong>flagbackup=T</strong> : A comment is warranted on the setting of flagbackup (here set to T or True).  If set to True, [[flagdata]] will save a copy of the existing set of flags <em>before</em> entering any new flags.  The setting of flagbackup is therefore a matter of some taste.  One could choose not to save any flags or only save "major" flags, or one could save every flag.  (One of the authors of this document was glad that flagbackup was set to True as he recently ran [[flagdata]] with a typo in one of the entries.)
* <strong>mode='manualflag'</strong> : Specific data are going to be selected to be edited. 
* <strong>selectdata=T</strong> : In order to select the specific data to be flagged, selectdata has to be set to True.  Once selectdata is set to True, then the various data selection options become visible (use inp flagdata to see the possible options).  In this case, scan='1' is chosen to select only the first scan.  Note that scan expects an entry in the form of a <em>string</em>.  (scan=1 would generate an error.)
 
If satisfied with the inputs, run this task.  The initial display in the logger will include
<pre style="background-color: #ffe4b5;">
##########################################
##### Begin Task: flagdata          #####
flagdata::::casa
attached MS [...]
Saving current flags to manualflag_2 before applying new flags
Creating new backup flag file called manualflag_2
</pre>
which indicates that, among other things, the flags that existed in the data set prior to this run will be saved to another file called manualflag_2.  Should one ever desire to revert to the data prior to this run, the task [[flagmanager]] could be used.
 
 
 
From the observer's log, we know that antenna 13 does not have a C band receiver, so it should be flagged as well.  The parameters are similar as before.
<source lang="python">
flagdata(vis='3c391_ctm_mosaic_10s.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea13')
</source>
* antenna='ea13' : Once again, this parameter requires a string output.  Also note that antenna='ea13' and 'antenna='13' are <em>not</em> the same antenna.  (Check the output from [[listobs]] above.)
 
 
Finally, it is common for the array to require a small amount of time to "settle down" at the start of a scan.  Consequently, it has become standard practice to edit out the initial samples from the start of each scan.
 
<source lang="python">
flagdata(vis='3c391_ctm_mosaic_10s.ms',mode='quack',quackinterval=10.0,quackmode='beg')
</source>
* mode='quack' : Quack is another mode in which the same edit will be applied to all scans for all baselines.
* quackmode='beg' : In this case, data from the start of each scan will be flagged.  Other options include flagging data at the end of the scan.
* quackinterval=10 : In this data set, the sampling time is 10 seconds, so this choice flags the first sample from all scans on all baselines.
 
 
Having now done some basic editing of the data, based in part on <i>a priori</i> information, it is time to look at the data to determine if there are any other obvious problems.  One task to examine the data themselves is [[plotms]].
 
<source lang="python">
plotms(vis='3c391_ctm_mosaic_10s.ms',xaxis='',yaxis='',selectdata=True,averagedata=False,transform=False,extendflag=False,plotfile='')
</source>
* xaxis=' ', yaxis=' ' : One can choose the axes of the plot, i.e., the way of visualizing the data.
* selectdata=T : One can choose to plot only subsets of the data.
* averagedata=F : It is possible to average the data in time, frequency, etc.
* transform=F : It is possible to change the velocity reference frame of the data.
* extendflag=F : It is possible to "extend" a flag, i.e., flag data surrounding bad data.  For example, one might want to flag spectral channels surrounding a bad spectral channel or one might want to flag cross-polarization data if one flags the parallel polarization data.
* plotfile=' ' : It is possible to produce a hard copy (e.g., for a paper, report, or Web site) by specifying a file.
In this case, most of the values have been left to defaults as it is also possible to select them from within the [[plotms]] GUI.  Review the inputs, then run the task.
 
[[plotms]] should produce a GUI, with the default view being to show the visibility amplitude as a function of time.
[[Image:plotms-default.png|200px|right|thumb|plotms default GUI view]]
[[plotms]] allows one to select and view the data in many ways.  Across the top of the right panel are a set of tabs labeled 'Plots', 'Flagging', 'Tools', 'Annotator', and 'Options'.  If one selects the 'Flagging' tab, the option is to 'Extend flags'.  Thus, even though [[plotms]] was started with extendflag=F, if one decides that it does make sense to extend the flags, one can still do so here.
 
In the default view, the 'Plots' tab is visible, and there are a number of tabs running down the side of the right hand panel, including 'Data', 'Axes', 'Trans', 'Cache', 'Display', 'Canvas', and 'Export'.  Once again, one can make changes on the fly.  Thus, supposing that one wants to save a hard copy, even if [[plotms]] was started with plotfile=' ', one can select 'Export' and enter a file name in which to save a copy of a plot.
 
One should spend several minutes displaying the data in various formats.  For instance, one could select the 'Data' tab and specify field 0 (source J1331+3030, a.k.a. 3C 286) to display data associated with the amplitude calibrator, then select the 'Axes' tab and change the x axis to be UVDist, and plot the data.  The result should be that of the first thumbnail image shown below.  The amplitude distribution is relatively constant as a function of u-v distance or baseline length (i.e., sqrt[u*u + v*v]).  From the various lectures, one should recognize that a relatively constant visibility amplitude as a function of baseline length means that the source is very nearly a point source.  (The Fourier transform of a constant is a delta function, a.k.a. a point source.) 
 
By contrast, if one selects field 3 (one of the 3C 391 fields) in the 'Data' tab and plots these data, one sees a visibility function that falls rapidly with increasing baseline length.  Such a visibility function indicates a highly resolved source.  By noting the baseline length at which the visibility function falls to some fiducial value (e.g., 1/2 of its peak value), one can obtain a rough estimate of the angular scale of the source.  (From the lectures, angular scale [in radians] ~ 1/baseline [in wavelengths].)
 
 
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view of 3C 286]]
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view of 3C 391]]
 
 
As a general data editing and examination strategy, at this stage in the data reduction process, one wants to focus on the calibrators.  The data reduction strategy is to determine various corrections from the calibrators, then apply these correction factors to the science data.  The 3C 286 data look relatively clean.  There are no wildly egregious data (e.g., amplitudes that are 100,000x larger than the rest of the data).  One may notice that there are antenna-to-antenna variations (under the 'Display' tab, select 'Colorize by Antenna1').  These antenna-to-antenna variations are acceptable, that's what calibration will help determine.
 
== Calibrating the data ==
 
It is now time to begin calibrating the data.  The general data reduction strategy is to derive a series of scaling factors or corrections from the calibrators, which are then collectively applied to the science data. 
For <em>much</em> more discussion of the philosophy, strategy, and implementation of calibration of synthesis data within CASA, see [http://casa.nrao.edu/docs/userman/UserManch4.html#x177-1740004 Synthesis Calibration] in the CASA Reference Manual.
 
Recall that the observed visibility V' between two antennas (i,j) is related to the "true" visibility V by
<pre>
    V'_{i,j}(u,v,f) = b_{ij}(t) * [B_i(f,t) * B*_j(f,t)] * g_i(t) * g_j(t) * V_{i,j}(u,v,f) * exp{i [theta_i(t) - theta_j(t)]}
</pre>
Here, for generality, we show the visibility as a function of frequency f and spatial wavenumbers u and v.  The other terms are
* g_i and theta_i are the amplitude and phase portions of what is commonly termed the complex gain.  They are shown separately here because they are usually determined separately.  For completeness, these are shown as a function of time t to indicate that they can change with temperature, atmospheric conditions, etc.
* B_i is the complex bandpass.  This is clearly a function of frequency f, but, for completeness, it is also shown as a function of time.
* b(t) is the often-neglected baseline term.  It shall be neglected here as well, though it can be important to include for the highest dynamic range images or shortly after a configuration change at the [E]VLA, when antenna positions may not be known well. 
Strictly, the equation above is a simplification of a more general measurement equation formalism, but it is a useful simplification in many cases.
 
For safety or sanity, one can begin by "clearing the calibration."  In CASA, the data structure is that the observed data are stored in a DATA column, estimates of the data (e.g., from the self-calibration process to be done later) are stored in the MODEL_DATA column, and the calibrated data are stored in the CORRECTED_DATA column.  The task clearcal initializes the MODEL_DATA and CORRECTED_DATA and sets up some scratch data columns as well.  For a pristine data set, straight from the Archive, clearcal probably should not be required; clearcal could be quite important if one decides later that a horrible mistake has been made in the calibration process and one wishes to start over.
 
<source lang="python">
clearcal(vis='3c391_ctm_mosaic_10s.ms',field='',spw='')
</source>
 
All parameters are set to blank so that the initialization occurs for all sources and spectral windows.
 
 
The first step is to provide a flux density value for the amplitude calibrator J1331+3030 (a.k.a. 3C 286).  For the VLA, the ultimate flux density scale at most frequencies was set by 3C 295, which was then transferred to a small number of "primary flux density calibrators," including 3C 286.  For the EVLA, at the time of this writing, the flux density scale at most frequencies will be determined from WMAP observations of the planet Mars, in turn then transferred to a small number of primary flux density calibrators.  Thus, the procedure is to assume that the flux density of a primary calibrator source is known and, by comparison with the observed data for that calibrator, determine the g_i values.
 
<source lang="python">
setjy(vis='3c391_ctm_mosaic_10s.ms',field='J1331+3030',spw='0',
    modimage = '/home/casa/data/nrao/VLA/CalModels/3C286_C.im',standard = 'Perley-Taylor 99',
    fluxdensity = -1)
</source>
* field='J1331+3030' : Clearly one has to specify what the flux density calibrator is, otherwise <em>all</em> sources will be assumed to have the same flux density.
* spw='0' : In this observation, the spectral windows are sufficiently separated that the spectrum of 3C 286 means that the same flux density for the calibrator source cannot be assumed for both.  If the spectral windows were much closer together, it might be possible to calibrate both with the same flux density value.
* modimage='/home/casa/data/nrao/VLA/CalModels/3C286_C.im' : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved.  Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects.  In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used.
* standard='Perley-Taylor 99' : Periodically, the flux density scale at the VLA was revised, updated, or expanded.  The specified value represents the most recent determination of the flux density scale (by R. Perley and G. Taylor in 1999); older scales can also be specified, and might be important if, for example, one was attempting to conduct a careful comparison with a previously published result.
* fluxdensity=-1 : It is possible to specify (i.e., force) the flux density of the source to be a particular value.  In this case, a model image of a primary flux density calibrator exists.  However, for some kinds of polarization calibration or in extreme situations (e.g., there are problems with the scan on the flux density calibrator), it can be useful or required to set the flux density of the source explicitly.
 
The output from setjy should look similar to the following.
<pre style="background-color: #ffe4b5;">
INFO    taskmanager::::casa    ##### async task launch:    setjy ########################
INFO    setjy::imager::setjy()    J1331+3030  spwid=  0  [I=7.747, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)
INFO    setjy::imager::setjy()  Using model image /home/casa/data/nrao/VLA/CalModels/3C286_C.im
INFO    setjy::imager::setjy()  The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.
INFO    setjy::imager::setjy()  Scaling model image to I=7.74664 Jy for visibility prediction.
INFO    setjy::imager::data selection  Selecting data
</pre>
As set, the flux density scale is being set only for spectral window 0 (spwid=0).  The flux density at the center of the spectral window is reported.  This value is determined from an analytical formula for the spectrum of the source as a function of frequency; this value must be determined so that the flux density in the image can be scaled to it, as it is unlikely that the observation was taken at exactly the same frequency as the model image.
 
 
<source lang="python">
setjy(vis='3c391_ctm_mosaic_10s.ms',field='J1331+3030',spw='1',
    modimage = '/home/casa/data/nrao/VLA/CalModels/3C286_X.im',standard = 'Perley-Taylor 99',
    fluxdensity = -1)
</source>
Spectral window 1 (at 7.436 GHz) is formally within the C band (4--8 GHz), not the X band (8--12 GHz).  A model image at X band is utilized nonetheless, because the actual frequency of spw 1 is much closer to the frequency at which the X band model was made than the C band model. 
 
 
=== Bandpass calibration ===
 
In this step one solves for the complex bandpass, B_i. 
[[Image:plotms-3C286-RRbandpass.png|200px|thumb|right|bandpass illustration]]
For the VLA, in its old continuum modes, this step could be skipped.  With the EVLA, all data are spectral line, even if the science that one is conducting is continuum.  Solving for the bandpass won't hurt for continuum data, and, for moderate or high dynamic range image, it is essential.  To motivate the need for solving for the bandpass, consider the image to the left.  It shows the right circularly polarized data (RR polarization) for the source J1331+3030, which will serve as the bandpass calibrator.  The data are color coded by scan, and they are averaged over all baselines, as earlier plots from [[plotms]] indicated that the visibility data are nearly constant with baseline length.  Ideally, the visibility data would be constant as a function of frequency, with the same amplitude on all baselines.  The variations with frequency are a reflection of the (slightly) different antenna bandpasses.  (<em>Exercise for the reader, reproduce this plot using [[plotms]].</em>)
 
Depending upon frequency and configuration, there could be gain variations between the different scans of the bandpass calibrator, particularly if the scans happen at much different elevations.  One can solve for an initial set of antenna-based gains, which will later be discarded, in order to moderate the effects of gain variations from scan to scan on the bandpass calibrator.
<source lang="python">
gaincal(vis='3c391_ctm_mosaic_10s.ms',caltable='3c391_ctm_mosaic.gcal0',field='J1331+3030',
    refant='ea21',spw='0~1:27~36',calmode='p',solint='int',minsnr=5,solnorm=T)
</source>
* caltable='3c391_ctm_mosaic.gcal0' : The gain solutions will be stored in an external table.
* field='J1331+3030' : Specify the bandpass calibrator.  In this case, the bandpass calibrator and the amplitude calibrator happen to be the same source, but it is not always so.
* refant='ea21' : Earlier, by looking at the output from [[plotants]], a <em>reference antenna</em> near the center of the array was noted.  Here is the first time that that choice will be used.  Strictly, all of the gain corrections derived will be <em>relative</em> to this reference antenna.
* spw='0~1:27~36': One wants to choose a subset of the channels from which to determine the gain corrections.  These should be near the center of the band, and there should be enough channels chosen so that a reasonable signal-to-noise ratio can be obtained.  (See the output of [[plotms]] above.)  Particularly at lower frequencies where RFI can manifest itself, one should choose RFI-free frequency channels.
* calmode='p' : Solve for only the phase portion of the gain.
* solint='int' : One wants to be able to track the phases, so a short solution interval is chosen.  (A single integration time or 10 seconds for this case)
* minsnr=5 : One probably wants to restrict the solutions to be at relatively high signal-to-noise ratios, although this parameter may need to be varied depending upon the source and frequency.
* solnorm=T : Strictly, for a phase-only solution, the amplitudes should be normalized by zero.  This setting enforces that.
One can now examine the phase solutions using [[plotcal]].  The inputs shown below plot the phase portion of the gain solutions as a function of time for the calibrator for R and L polarization separately.
<source lang="python">
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='',yaxis='phase',poln='R',field= 'J1331+3030',spw='0',figfile='plotcal-3C286-G0-phase-L.png')
</source>
<source lang="python">
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='',yaxis='phase',poln='L',field= 'J1331+3030',spw='0',figfile='plotcal-3C286-G0-phase-L.png')
</source>
Inspection of the resulting plots (shown below, <em>exercise for the reader, reproduce these plots</em>) shows that the phase is relatively stable within a scan, but does vary from scan to scan.  If [[plotcal]] is run interactively, with the GUI, one can select sub-regions within the plot and zoom into them to look at the phase in more detail.
[[Image:plotcal-3C286-G0-phase-R.png|200px|thumb|left|gain phases for 3C 286, R polarization]]
[[Image:plotcal-3C286-G0-phase-L.png|200px|thumb|center|gain phases for 3C 286, L polarization]]
 
 
Now form the bandpass itself, using the phase solutions just derived.
<source lang="python">
bandpass(vis='3c391_ctm_mosaic_10s.ms',gaintable='3c391_ctm_mosaic.gcal0',caltable='3c391_ctm_mosaic.bcal0',
    field='J1331+3030',spw='0,1',refant='ea21',solnorm=True,combine='scan',solint='inf',bandtype='B')
</source>
* gaintable='3c391_ctm_mosaic.gcal0' : This gaintable contains the phase solutions just derived.  By having a non-blank value for gaintable, [[bandpass]] will apply the solutions contained within it before deriving the bandpass corrections themselves.
* caltable='3c391_ctm_mosaic.bcal0' : Specify where to store the bandpass corrections.
* solnorm=T : Make sure that the amplitudes of the bandpass corrections are normalized to unity.
* solint='inf' and combine='scan' : This observation contains multiple scans on the bandpass calibrator, J1331+3030.  Because these are continuum observations, it is probably acceptable to combine all the scans and compute one bandpass correction per antenna, which is achieved by the combination of solint='inf' and combine='scan'.  Had combine=' ', then there would have been a bandpass correction derived per scan, which might be necessary for the highest dynamic range spectral line observations.
* bandtype='B' : The bandpass solution will be derived on a channel-by-channel basis.  There is an alternate, somewhat experimental option of bandtype='BPOLY' that will attempt to fit an n-th order polynomial to the bandpass.
 
Once again, one can use [[plotcal]] to display the bandpass solutions.  Note that in the [[plotcal]] inputs below, the amplitudes are being displayed as a function of frequency channel and, for compactness, subplot=221 is used to display multiple plots per page.  One could use yaxis='phase' to view the phases as well.
<source lang="python">
plotcal(caltable= '3C391_split_spw0_continuum_mosaic.B0',poln='R',field= 'J1331+3030',subplot=221,figfile='plotcal-3C286-B0-R.png')
plotcal(caltable= '3C391_split_spw0_continuum_mosaic.B0',poln='L',field= 'J1331+3030',subplot=221,figfile='plotcal-3C286-B0-L.png')
<source lang="python">
[[Image:plotcal-3C286-G0-bandpass-R.png|200px|thumb|left|bandpass for 3C 286, R polarization]]
[[Image:plotcal-3C286-G0-bandpass-L.png|200px|thumb|center|bandpass for 3C 286, L polarization]]
 
=== Gain calibration ===
<source lang="python">
gaincal(vis='3c391_ctm_mosaic_10s.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1331+3030',spw='0,1:5~58'
    refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',solint='inf')
</source>
 
<source lang="python">
gaincal(vis='3c391_ctm_mosaic_10s.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1822-0938,J0319+4130',
    spw='0,1:5~58',refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',
    solint='inf',append=True)
</source>
 
=== Polarization calibration ===
 
Now we need to do the polarization calibration.  This should be done prior to running [[fluxscale]], since it has to run using the un-rescaled gains in the model data column of the measurement set.  Polarization calibration is done in two steps.  First, we solve for the instrumental polarization (the frequency-dependent leakage terms, or 'D-terms'), using either an unpolarized source or a source which has sufficiently good parallactic angle coverage.  Second, we solve for the polarization position angle using a source with a known polarization position angle (3C 286 is recommended here).
 
Our initial run of [[setjy]] only set the total intensity of our flux calibrator source, 3C 286.  This source is [http://www.vla.nrao.edu/astro/calib/polar/ known] to have a fractional polarization of 11.2% at C-band, and a polarization position angle of 66 degrees.  In order to calibrate the position angle, we need to set the appropriate values for Stokes Q and U at the two observing frequencies.  Examining our casapy.log file to find the output of [[setjy]], we find that the total intensity was set to 7.74664 Jy in the lower spectral window (spw0) and 5.65053 Jy in the upper spectral window (spw1).  We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at both frequencies.
 
<source lang="python">
i0=7.74664
p0=0.112*i0
q0=p0*cos(66*pi/180)
u0=p0*sin(66*pi/180)
 
i1=5.65053
p1=0.112*i1
q1=p1*cos(66*pi/180)
u1=p1*sin(66*pi/180)
</source>
 
We now set the values of Stokes Q and U for 3C 286 at both frequencies, using [[setjy]] as we did before.  This time, however, we do not use the model image.
 
<source lang="python">
setjy(vis='3c391_ctm_mosaic_10s.ms',field='J1331+3030',modimage='',spw='0',fluxdensity=[i0,q0,u0,0])
setjy(vis='3c391_ctm_mosaic_10s.ms',field='J1331+3030',modimage='',spw='1',fluxdensity=[i1,q1,u1,0])
</source>
 
==== Solving for the leakage terms ====
 
The task we will use to do all the polarization calibration is [[polcal]].  In this data set, we observed the unpolarized source J0319+4130 (i.e. 3C 84) to allow us to solve for the leakages.  [[polcal]] uses the Stokes IQU values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to solve for the leakages, and we wish to do this in a frequency-dependent sense, so we set ''poltype='Df' '' (''D'' specifying to solve for the leakages, and ''f'' to do so on a per-channel basis).  Had we been solving for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, we would simultaneously have needed to solve for the source polarization (''poltype='Df+QU' '').  We apply our existing gain and bandpass tables on-the-fly by setting ''gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0']''.  [[polcal]] will create a new calibration table containing the leakage solutions, which we specify with the ''caltable'' argument.  We wish to solve for both spectral windows (setting ''spw='0,1' ''), and specify the source to be used for the calibration (''field='J0319+4130' '').  The final function call is then:
 
<source lang="python">
polcal(vis='3c391_ctm_mosaic_10s.ms',caltable='3c391_ctm_mosaic.pcal0',field='J0319+4130',
    spw='0,1',refant='ea21',poltype='Df',gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'])
</source>
 
After polcal has finished running, you are strongly advised to examine the solutions with [[plotcal]], to ensure that everything looks good.
 
<source lang="python">
plotcal(caltable='3c391_ctm_mosaic.pcal0',xaxis='chan',yaxis='amp',spw='0',field='',iteration='antenna')
</source>
 
This will produce plots similar to that shown at right:
[[Image:3c391_ctm_plotcal_Df_solutions.jpg|thumb|[[plotcal]] GUI showing the Df solutions from [[polcal]] ]]
 
As ever, you can cycle through the antennas by clicking the "Next" button.  You should see leakages of between 5 and 15% in most cases.
 
==== Solving for the R-L polarization angle ====
 
Having calibrated the instrumental polarization, the total polarization is now correct, but we still need to calibrate the R-L phase, to get an accurate polarization position angle.  We use the same task, [[polcal]], but this time set ''poltype='Xf' '', which specifies a frequency-dependent (''f'') position angle (''X'') calibration, using the source J1331+3030 (aka 3C 286), whose position angle we know, having set this earlier using [[setjy]].  Note that we must correct for the leakages before determining the R-L phase, which we do by adding the calibration table made in the previous step (3c391_ctm_mosaic.pcal0) to the gain tables which are applied on-the-fly.
 
<source lang="python">
polcal(vis='3c391_ctm_mosaic_10s.ms',caltable='3c391_ctm_mosaic.xcal0',poltype='Xf',
    gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0', '3c391_ctm_mosaic.pcal0']),
    field='J1331+3030',refant='ea21',spw='0,1')
</source>
 
Again, it is strongly suggested that you check the calibration worked properly, by plotting up the newly-generated calibration table using [[plotcal]].  The results are shown at right.  You will notice that when iterating, the calibration appears to be identical for all antennas.
 
<source lang="python">
plotcal(caltable='3c391_ctm_mosaic.xcal0',xaxis='chan',yaxis='phase',iteration='antenna')
</source>
[[Image:3c391_ctm_plotcal_Xf_solutions.jpg|thumb|[[plotcal]] GUI showing Xf solutions from [[polcal]] ]]
 
At this point, your dataset contains all the necessary polarization calibration, which will shortly be applied to the data.
 
== Applying the calibration ==
 
While we know the flux density of our primary calibrator (in our case, J1331+3030<math>\equiv</math>3C 286), the model assumed for the secondary calibrator (here, J1822-0938) was a point source of 1 Jy located at the phase center.  While the secondary calibrator was chosen to be a point source (at least, over some limited range of ''uv''-distance; see [http://www.vla.nrao.edu/astro/calib/manual/csource.html the VLA calibrator manual] for any ''uv''-restrictions on your calibrator of choice at the observing frequency), its absolute flux density is unknown.  Being pointlike, secondary calibrators typically vary on timescales of months to years, in some cases by up to 50-100%.  A nice [http://www.vla.nrao.edu/astro/calib/flux/ Java Applet] is available to track the flux density history of various calibrators over time.  Play around with it to see how much some of the calibrators from the manual can vary, and over what sorts of timescales.
 
We use the primary calibrator (the 'flux calibrator') to determine the system response to a source of known flux density, and assume that the mean gain amplitudes for the primary calibrator are the same as those for the secondary calibrator.  This then allows us to find the true flux density of the secondary calibrator.  To do this, we use the task [[fluxscale]], which produces a new calibration table containing properly-scaled amplitude gains for the secondary calibrator.
 
<source lang="python">
fluxscale(vis='3c391_ctm_mosaic_10s.ms',caltable='3c391_ctm_mosaic.gcal1',fluxtable='3c391_ctm_mosaic.fluxscale1',
    reference='J1331+3030',transfer='J1822-0938,J0319+4130',append=True)
</source>
 
We provide [[fluxscale]] with the calibration table containing the amplitude gain solutions derived earlier by setting ''caltable='3c391_ctm_mosaic.gcal1' '', and specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains (''fluxtable='3c391_ctm_mosaic.fluxscale1' '').  We also set ''reference='J1331+3030' '' to specify the source with the known flux density, and ''transfer='J1822-0938,J0319+4130' '' to specify the sources whose amplitude gains are to be rescaled.
 
[[fluxscale]] will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. You should examine the output to ensure that it looks sensible.  Our two spectral windows are spaced relatively far apart within the C-band, so we should expect significantly different flux densities at the two frequencies for any source with a non-zero spectral index.  Example output for this data set would be:
 
<pre style="background-color: #fffacd;">
2010-05-03 19:09:07    INFO    fluxscale::::casa      ##########################################
2010-05-03 19:09:07    INFO    fluxscale::::casa      ##### Begin Task: fluxscale          #####
2010-05-03 19:09:07    INFO    fluxscale::::casa
2010-05-03 19:09:07    INFO    fluxscale::calibrater::open    Opening MS: 3c391_mosaic_10s.ms for calibration.
2010-05-03 19:09:07    INFO    fluxscale::Calibrater:: Initializing nominal selection to the whole MS.
2010-05-03 19:09:07    INFO    fluxscale::calibrater::fluxscale        Beginning fluxscale--(MSSelection version)-------
2010-05-03 19:09:07    INFO    fluxscale::::    Found reference field(s): J1331+3030
2010-05-03 19:09:07    INFO    fluxscale::::    Found transfer field(s):  J1822-0938 J0319+4130
2010-05-03 19:09:07    INFO    fluxscale::::    Flux density for J1822-0938 in SpW=0 is: 2.32824 +/- 0.00706023 (SNR = 329.768, nAnt= 25)
2010-05-03 19:09:07    INFO    fluxscale::::    Flux density for J1822-0938 in SpW=1 is: 1.45518 +/- 0.00472361 (SNR = 308.066, nAnt= 25)
2010-05-03 19:09:07    INFO    fluxscale::::    Flux density for J0319+4130 in SpW=0 is: 13.7643 +/- 0.0348429 (SNR = 395.04, nAnt= 25)
2010-05-03 19:09:07    INFO    fluxscale::::    Flux density for J0319+4130 in SpW=1 is: 17.7406 +/- 0.0344165 (SNR = 515.468, nAnt= 25)
2010-05-03 19:09:07    INFO    fluxscale::Calibrater::fluxscale        Appending result to 3c391_mosaic.fluxscale1
2010-05-03 19:09:07    INFO    fluxscale::::  Appending solutions to table: 3c391_mosaic.fluxscale1
2010-05-03 19:09:07    INFO    fluxscale::::casa
2010-05-03 19:09:07    INFO    fluxscale::::casa      ##### End Task: fluxscale            #####
</pre>
 
We see that the secondary calibrator, J1822-0938, has a steep spectral index (flux density is lower at the higher frequency), whereas the polarization calibrator, J0319+4130, is much brighter, and has an inverted spectral index (flux density is higher at the higher frequency).  The [http://www.vla.nrao.edu/astro/calib/manual/csource.html VLA calibrator manual] can be used to check whether the derived flux densities look sensible.  Wildly different flux densities in the two spectral windows, or flux densities with very high error bars should be treated with suspicion; in such cases you will have to figure out whether something has gone wrong.
 
Now that we have derived all the calibration solutions, we need to apply them to the actual data, using the task [[applycal]].  The measurement set contains three data columns; DATA, MODEL_DATA, and CORRECTED_DATA.  The DATA column contains the original data.  The MODEL_DATA column contains whatever model we used for the calibration; for J1331=3030, this is what we specified in [[setjy]], and for all other sources, this was set to a point source of 1 Jy at the phase center when the scratch columns were originally created using [[clearcal]].  To apply the calibration we have so painstakingly derived, we specify the appropriate calibration tables, which are then applied to the DATA column, with the results being written in the CORRECTED_DATA column.
 
First, we apply the calibration to each individual calibrator, using the gain solutions derived on that calibrator alone to compute the CORRECTED_DATA.  To do this, we iterate over the different calibrators, in each case specifying the source to be calibrated (using the ''field'' parameter).  We provide a Python list of the calibration tables to be applied, using the ''gaintable'' argument.  This must contain our properly-scaled gain calibration for the amplitudes and phases (in 3c391_ctm_mosaic.fluxscale1) which we just made using [[fluxscale]], our bandpass solutions (in 3c391_ctm_mosaic.bcal0), our leakage calibration (in 3c391_ctm_mosaic.pcal0) and the R-L phase corrections (in 3c391_ctm_mosaic.xcal0).  While the latter three tables were derived using a particular calibrator source, the table containing the gain solutions for amplitude and phase was derived separately for each individual calibrator.  To ensure that we use the correct gain amplitudes and phases for a given calibrator (those derived on that same calibrator), then for each calibrator source, we need to specify the particular subset of gain solutions to be applied. This requires use of the ''gainfield'' and ''interp'' arguments; these are both Python lists, and for the list item corresponding to the calibration table made by [[fluxscale]], we set ''gainfield'' to the field name corresponding to that calibrator, and the desired interpolation type (''interp'') to ''nearest''.
 
Finally, since we have performed polarization calibration, we '''must''' set ''parang=True'', or we will discard all that hard work we did earlier on.
 
<source lang="python">
applycal(vis='3c391_ctm_mosaic_10s.ms',
    gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],
    parang=True,field='J1331+3030',gainfield=['J1331+3030','','',''],interp=['nearest','','',''])
 
applycal(vis='3c391_ctm_mosaic_10s.ms',
    gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],
    parang=True,field='J0319+4130',gainfield=['J0319+4130','','',''],interp=['nearest','','',''])
 
applycal(vis='3c391_ctm_mosaic_10s.ms',
    gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],
    parang=True,field='J1822-0938',gainfield=['J1822-0938','','',''],interp=['nearest','','',''])
</source>
 
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938.  We can select all 7 fields at once (setting ''field='2~8''').  In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator.  Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target.  However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.
 
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.  For the reasons explained in the previous paragraph, we set the ''gainfield'' to the secondary calibrator, but this time request ''linear'' interpolation between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.
 
<source lang="python">
applycal(vis='3c391_ctm_mosaic_10s.ms',
    gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],
    parang=True,field='2~8',gainfield=['J1822-0938','','',''],interp=['linear','','',''])
</source>
 
[[Image:3c391 ctm plotms AP corrected.jpg|thumb|[[plotms]] GUI showing amplitude plotted against phase for the calibrated data on the secondary calibrator J1822-0938]]
We should now have fully-calibrated visibilities in the CORRECTED_DATA column of the measurement set, and it is worthwhile pausing to inspect them, to ensure that the calibration did what we expected it to.  A nice way of doing this is to use [[plotms]] to plot the amplitude and phase of the CORRECTED_DATA column against one another.  This should show a nice ball of visibilities centered at zero phase (with some scatter) and the amplitude found for that source in [[fluxscale]].  An example is shown at right.
 
Once the calibration has been applied to the target data, we can split off the source, creating a new, calibrated measurement set containing all the target fields.  In this case, we also split up the data by spectral window, so we can image the two different frequencies separately.
 
<source lang="python">
split(vis='3c391_mosaic_10s.ms',outputvis='3c391_ctm_mosaic_spw0.ms',datacolumn='corrected',field='2~8',spw='0')
split(vis='3c391_mosaic_10s.ms',outputvis='3c391_ctm_mosaic_spw1.ms',datacolumn='corrected',field='2~8',spw='1')
</source>
 
== Imaging and self-calibration ==
 
Now that we have split off your target data into a separate measurement set with all the calibration applied, it's time to make an image.  CASA has a single task, [[clean]] which both Fourier transforms the data and deconvolves the resulting image.
 
A command line call to image and deconvolve the dataset would be:
<source lang="python">
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',cell=['2.0arcsec','2.0arcsec'],imsize=[576,576],
    mode='mfs',niter=10000,threshold='1.0mJy',stokes='IQUV',psfmode='clarkstokes',
    weighting='briggs',imagermode='mosaic',multiscale=[1,3,10,30,100],mask=[162,177,377,397])
</source>
 
To image the dataset in all four polarizations (total intensity I, linear polarizations Q and U, and circular polarization V), we set ''stokes='IQUV''', which makes separate images in each polarization.  We also set ''psfmode='clarkstokes'', which uses the clark clean algorithm to deconvolve each Stokes plane separately.  This makes the polarization image more independent of the total intensity.
[[Image:3c391 ctm spw0 uvplt.jpg|thumb|[[plotms]] GUI showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]
 
Since our fractional bandwidth is non-zero (128 MHz at a central frequency of 4.6 GHz), there is a slight improvement in uv-coverage if we do not average all channels together.  Our dataset consists of multiple spectral channels, whose data we wish to combine into a single image, gridding each channel separately.  We therefore set ''mode='mfs'''.
 
We need to select the appropriate pixel size to use.  Using plotms to look at the newly-calibrated, target-only data set:
<source lang="python">
plotms(vis='3c391_ctm_mosaic_spw0.ms')
</source>
we select the axes tab on the left hand side, and select UVDist_L as the x-axis.  This gives the plot shown at right.
 
The maximum baseline shown corresponds to about 16,000 wavelengths, i.e. an angular scale of 12 arcseconds (<math>\lambda/D=1/16000</math>).  Since we wish to have a number of pixels across a resolution element, we then select a pixel size of 2 arcseconds in both co-ordinates by setting ''cell=['2.0arcsec','2.0arcsec']''.  The supernova remnant is known to have a diameter of order 9 arcmin, which corresponds to about 270 pixels. To prevent image artifacts arising from aliasing, we wish to keep the emission region to roughly the inner quarter of the image.  The Fourier transform is most efficient if the number of pixels on a side is a composite number divisible by 2 and 3 and/or 5.  We choose 576, which is <math>2^6\times3^2</math>, and is close to <math>2\times270</math>.  We therefore set ''imsize=[576,576]''.
 
Since 3C 391 has diffuse, extended emission which is being resolved out by the interferometer owing to a lack of short spacings, a naturally-weighted image would show large-scale patchiness in the noise.  In order to suppress this effect, we select Briggs weighting (intermediate between natural and uniform weighting), with a default robust factor of 0 (setting ''weighting='briggs''').
 
Our data consists of a 7-pointing mosaic, since the supernova remnant fills almost the full primary beam at 4.6 GHz.  We therefore wish to perform a joint deconvolution on all 7 fields, which we do simply by setting ''imagermode='mosaic''', and using the default mosaic parameters.
 
Because the supernova remnant contains both diffuse, extended structure on large spatial scales, and also finer filamentary structure on smaller scales, we use the multiscale clean algorithm, which removes clean components which are circular Gaussians as well as delta functions.  We set a logarithmically-spaced range of spatial scales to use for the widths of the Gaussian components, which we specify in pixels.  To do this, we set ''multiscale=[1,3,10,30,100]''.
 
To prevent the clean algorithm finding spurious components on noise peaks, especially at the larger scales in the multiscale clean, we set a region within which the task will search for clean components, using ''mask=[162,177,377,397]'', which encompasses the observed emission (we can get a rough idea of where the bulk of the emission lies by running clean once with no deconvolution, i.e. ''niter=0'', to make a dirty image, which we can then inspect with the [[viewer]] to locate the emission regions).  To prevent overcleaning, we wish to stop the deconvolution when we have reached a residual flux level of 1 mJy (setting ''threshold='1.0mJy'''), or when we have generated 10000 clean components (setting ''niter=10000'').
 
[[Image:3c391_ctm_i_image.jpg|thumb|[[viewer]] display of the Stokes I mosaic of 3C 391 at 4600 MHz]]
[[clean]] will make several output files, all named with the prefix given as ''imagename''.  These include:
* .image - the final restored image, with the clean components convolved with a restoring beam and added to the remaining residuals at the end of the imaging process
* .flux - the effective response of the telescope (the primary beam)
* .flux.pbcoverage - the effective response of the full mosaic image
* .mask - the areas where you have permitted imager to find clean components
* .model - the sum of all the clean components, which has been stored as the model_data column in the measurement set
* .psf - the dirty beam, which is being deconvolved from the true sky brightness during the clean process
* .residual - what is left at the end of the deconvolution process; this is useful to diagnose whether or not to clean more deeply
 
After the imaging and deconvolution process has finished, you can use the [[viewer]] to look at your image.
 
<source lang="python">
viewer('3c391_ctm_spw0_IQUV.image')
</source>
 
This will bring up a viewer window containing the image, which should look similar to that shown at right.  The tape deck buttons that you see under the image can be used to step through the different Stokes parameters (I,Q,U,V).  You can adjust the color scale and zoom in to a selected region by assigning mouse buttons to the icons immediately above the image (hover over the icons to get a description of what they do).
 
Note that the image is cut off in a circular fashion at the edges, corresponding to the default minimum primary beam response within [[clean]] of 0.2.

Latest revision as of 16:37, 27 April 2016