https://casaguides.nrao.edu/api.php?action=feedcontributions&user=Jgallimo&feedformat=atomCASA Guides - User contributions [en]2024-03-19T09:52:51ZUser contributionsMediaWiki 1.38.6https://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4077EVLA Continuum Tutorial 3C3912010-06-10T22:56:32Z<p>Jgallimo: /* Overview */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
<br />
== BEFORE YOU START==<br />
Make sure you have done the steps described at [[Initial_instructions_for_2010| the initial instructions for the 2010 Synthesis Workshop Tutorials]].<br />
<br />
== Overview ==<br />
This article describes the calibration and imaging of a multiple-pointing EVLA continuum dataset on the supernova remnant <br />
[http://simbad.u-strasbg.fr/simbad/sim-id?Ident=3C+391&NbIdent=1&Radius=2&Radius.unit=arcmin&submit=submit+id 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.<br />
<br />
There are a number of possible ways to run CASA, described in more detail in [[Getting Started in CASA]]. In brief, there are at least three different ways to run CASA:<br />
* Interactively examining task inputs. In this mode, one types <tt>default taskname</tt> to load the task, <tt>inp</tt> to examine the inputs, and <tt>go</tt> once those inputs have been set to your satisfaction. Allowed inputs are shown in blue, and bad inputs are colored red. The inputs themselves are changed one by one, e.g., <tt>selectdata=T</tt>. Screenshots of the inputs to various tasks used in the data reduction below are provided, to illustrate which parameters need to be set.<br />
More detailed help can be obtained on any task by typing <tt>help taskname</tt>. Once a task is run, the set of inputs are stored and can be retrieved via <tt>tget taskname</tt>; subsequent runs will overwrite the previous <tt>tget</tt> file.<br />
* Pseudo-interactively via task function calls. In this case, all of the desired inputs to a task are provided at once on the CASA command line. This tutorial is made up of such calls, which were developed by looking at the inputs for each task and deciding what needed to be changed from default values. For task function calls, only parameters that you want to be different from their defaults need to be set. <br />
* Non-interactively via a script. A series of task function calls can be combined together into a script, and run from within CASA via <tt>execfile('scriptname.py')</tt>. This (and other) CASAguide has been designed to be extracted into a script using the [[Extracting_scripts_from_these_tutorials | script extractor]]. Should one use the script generated by the [[Extracting_scripts_from_these_tutorials | script extractor]] for this CASAguide, be aware that it will require some small amount of interaction related to the plotting, occasionally suggesting that you close the graphics window and hitting return in the terminal to proceed. It is in fact unnecessary to close the graphics windows (it is suggested that you do so purely to keep your desktop uncluttered), and in one case (that of {{plotms}}), you '''must''' leave the graphics window open, as the GUI cannot be reopened without first exiting from CASA.<br />
<br />
If you are a relative novice (and <em>particularly</em> for this tutorial), it is <em>strongly</em> recommended that you start with the interactive mode, graduating to the pseudo- or non-interactive mode as you gain experience. Work at your own pace, look at the inputs to the tasks to see what other options exist, and read the help files.<br />
<br />
== Obtaining the Data ==<br />
<br />
For the purposes of this tutorial, we have created a "starting" data set, upon which several initial processing steps have already been conducted. This data set may already be present on the machine that you are using; if not, obtain it from the<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz CASA data archive].<br />
<br />
We are providing this "starting" data set, rather than the "true" initial data set for (at least) two reasons. First, many of these initial processing steps can be rather time consuming (> 1 hr), and the time for the data reduction tutorial is limited. Second, while necessary, many of these steps are not fundamental to the calibration and imaging process, upon which we want to focus today. For completeness, however, here are the steps that were taken from the initial data set to produce the "starting" data set:<br />
* The data loaded into CASA, converting the initial Science Data Model (SDM) file into a measurement set.<br />
* Basic data flagging was applied, to account for "shadowing" of the antennas. These data are from the D configuration, in which antennas are particularly susceptible to being blocked or "shadowed" by other antennas in the array, depending upon the elevation of the source.<br />
* The data were averaged to 10-second samples, from the initial 1-second correlator sample time. In the D configuration, the fringe rate is relatively slow and time-average smearing is less of a concern.<br />
* The data were acquired with two spectral windows (around 4.6 and 7.5 GHz). Because of disk space concerns on some machines, the focus will be on only one of the two spectral windows.<br />
<br />
We emphasize that, were this a real science observation, all of these steps would need to be run. Detailed instructions on obtaining the data from the archive and creating this "starting" data set may be found in the [[Obtaining EVLA Data: 3C 391 Example]] tutorial.<br />
<br />
== The Observation ==<br />
<br />
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. From this, we find the following:<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Information from observing log:<br />
There is no C-band receivers on ea13<br />
Antenna ea06 is out of the array<br />
Antenna ea15 has some corrupted data<br />
Antennas ea10, ea12, ea22 do not have good baseline positions<br />
Gusty winds, mixed clouds, API rms up to 11.5.<br />
</pre><br />
<br />
Before beginning our data reduction, we must start CASA. If you have not used CASA before, some helpful tips are available on the [[Getting Started in CASA]] page.<br />
<br />
Once you have CASA up and running in the directory containing the data, then start your data reduction by getting some basic information about the data. The task {{listobs}} can be used to get a listing of the individual scans comprising the observation, the frequency setup, source list, and antenna locations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='3c391_ctm_mosaic_10s_spw0.ms',verbose=T)<br />
</source><br />
<br />
{{listobs}} should now produce output similar to the following in the casa logger. (Note that the listing shown is for both spectral windows, whereas the data set actually being used contains only one spectral window.)<br />
<br />
One will note that there are nine sources observed. Here the various sources are introduced briefly, with more detail contained in the sections below in which they are used.<br />
* J1331+3030 = 3C 286, which will later serve as a calibrator for the visibility amplitudes, i.e., it is assumed to have a precisely known flux density; the spectral bandpass; and the polarization position angle;<br />
* J1822-0938, which will serve as a calibrator for the visibility phases;<br />
* J0319+4130 = 3C 84, which will serve as a polarization calibrator; and<br />
* 3C391 C1--C7, which are 7 fields centered on and surrounding the supernova remnant.<br />
This observation was set up as a 7-pointing mosaic because the supernova remnant is so large that it essentially fills the primary beam.<br />
<br />
<br />
<pre style="background-color: #ffe4b5;"><br />
INFO listobs::::casa ##########################################<br />
INFO listobs::::casa ##### Begin Task: listobs #####<br />
INFO listobs::::casa <br />
INFO listobs::ms::summary ================================================================================<br />
INFO listobs::ms::summary+ MeasurementSet Name: /export/home/hamal/jmiller/TDEM0001_sb1218006/3c391_mosaic_fullres.ms MS Version 2<br />
INFO listobs::ms::summary+ ================================================================================<br />
INFO listobs::ms::summary+ Observer: Dr. James Miller-Jones Project: T.B.D. <br />
INFO listobs::ms::summary+ Observation: EVLA<br />
INFO listobs::ms::summary Data records: 18666050 Total integration time = 28716 seconds<br />
INFO listobs::ms::summary+ Observed from 24-Apr-2010/08:01:34.5 to 24-Apr-2010/16:00:10.5 (UTC)<br />
INFO listobs::ms::summary <br />
INFO listobs::ms::summary+ ObservationID = 0 ArrayID = 0<br />
INFO listobs::ms::summary+ Date Timerange (UTC) Scan FldId FieldName nVis Int(s) SpwIds<br />
INFO listobs::ms::summary+ 24-Apr-2010/08:01:34.5 - 08:02:28.5 1 0 J1331+3030 35750 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:02:29.5 - 08:09:27.5 2 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:09:28.5 - 08:16:26.5 3 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:16:27.5 - 08:24:25.5 4 1 J1822-0938 311350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:24:26.5 - 08:29:44.5 5 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:29:45.5 - 08:34:43.5 6 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:34:44.5 - 08:39:42.5 7 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:39:43.5 - 08:44:41.5 8 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:44:42.5 - 08:49:40.5 9 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:49:41.5 - 08:54:40.5 10 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:54:41.5 - 08:59:39.5 11 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:59:40.5 - 09:01:29.5 12 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:01:30.5 - 09:06:48.5 13 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:06:49.5 - 09:11:47.5 14 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:11:48.5 - 09:16:46.5 15 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:16:47.5 - 09:21:45.5 16 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:21:46.5 - 09:26:44.5 17 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:26:45.5 - 09:31:44.5 18 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:31:45.5 - 09:36:43.5 19 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:36:44.5 - 09:38:32.5 20 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:38:33.5 - 09:43:52.5 21 2 3C391 C1 208000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:43:53.5 - 09:48:51.5 22 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:48:52.5 - 09:53:50.5 23 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:53:51.5 - 09:58:49.5 24 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:58:50.5 - 10:03:48.5 25 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:03:49.5 - 10:08:47.5 26 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:08:48.5 - 10:13:47.5 27 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:13:48.5 - 10:15:36.5 28 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:15:37.5 - 10:20:55.5 29 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:20:56.5 - 10:25:55.5 30 3 3C391 C2 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:25:56.5 - 10:30:54.5 31 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:30:55.5 - 10:35:53.5 32 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:35:54.5 - 10:40:52.5 33 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:40:53.5 - 10:45:51.5 34 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:45:52.5 - 10:50:51.5 35 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:50:52.5 - 10:52:40.5 36 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:52:41.5 - 10:57:39.5 37 0 J1331+3030 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:57:40.5 - 11:02:39.5 38 1 J1822-0938 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:02:40.5 - 11:07:58.5 39 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:07:59.5 - 11:12:47.5 40 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:12:48.5 - 11:17:36.5 41 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:17:37.5 - 11:22:25.5 42 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:22:26.5 - 11:27:15.5 43 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:27:16.5 - 11:32:04.5 44 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:32:05.5 - 11:36:53.5 45 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:36:54.5 - 11:38:43.5 46 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:38:44.5 - 11:44:02.5 47 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:44:03.5 - 11:48:51.5 48 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:48:52.5 - 11:53:40.5 49 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:53:41.5 - 11:58:29.5 50 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:58:30.5 - 12:03:19.5 51 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:03:20.5 - 12:08:08.5 52 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:08:09.5 - 12:12:57.5 53 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:12:58.5 - 12:14:47.5 54 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:14:48.5 - 12:20:06.5 55 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:20:07.5 - 12:24:55.5 56 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:24:56.5 - 12:29:44.5 57 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:29:45.5 - 12:34:34.5 58 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:34:35.5 - 12:39:23.5 59 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:39:24.5 - 12:44:12.5 60 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:44:13.5 - 12:49:01.5 61 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:49:02.5 - 12:50:51.5 62 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:50:52.5 - 12:56:10.5 63 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:56:11.5 - 13:00:59.5 64 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:01:00.5 - 13:05:48.5 65 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:05:49.5 - 13:10:38.5 66 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:10:39.5 - 13:15:27.5 67 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:15:28.5 - 13:20:16.5 68 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:20:17.5 - 13:25:05.5 69 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:25:06.5 - 13:26:55.5 70 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:26:56.5 - 13:32:14.5 71 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:32:15.5 - 13:37:03.5 72 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:37:04.5 - 13:41:52.5 73 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:41:53.5 - 13:46:42.5 74 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:46:43.5 - 13:51:31.5 75 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:51:32.5 - 13:56:20.5 76 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:56:21.5 - 14:01:09.5 77 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:01:10.5 - 14:02:59.5 78 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:03:00.5 - 14:08:18.5 79 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:08:19.5 - 14:13:07.5 80 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:13:08.5 - 14:17:57.5 81 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:17:58.5 - 14:22:46.5 82 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:22:47.5 - 14:27:35.5 83 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:27:36.5 - 14:32:24.5 84 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:32:25.5 - 14:37:13.5 85 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:37:14.5 - 14:39:03.5 86 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:39:04.5 - 14:44:22.5 87 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:44:23.5 - 14:49:11.5 88 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:49:12.5 - 14:54:01.5 89 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:54:02.5 - 14:58:50.5 90 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:58:51.5 - 15:03:39.5 91 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:03:40.5 - 15:08:28.5 92 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:08:29.5 - 15:13:17.5 93 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:13:18.5 - 15:15:07.5 94 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:15:08.5 - 15:20:26.5 95 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:20:27.5 - 15:25:15.5 96 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:25:16.5 - 15:30:05.5 97 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:30:06.5 - 15:34:54.5 98 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:34:55.5 - 15:39:43.5 99 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:39:44.5 - 15:44:32.5 100 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:44:33.5 - 15:49:22.5 101 8 3C391 C7 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:49:23.5 - 15:51:11.5 102 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:51:12.5 - 16:00:10.5 103 9 J0319+4130 350350 1 [0, 1]<br />
INFO listobs::ms::summary (nVis = Total number of time/baseline visibilities per scan) <br />
INFO listobs::ms::summary Fields: 10<br />
INFO listobs::ms::summary+ ID Code Name RA Decl Epoch SrcId nVis <br />
INFO listobs::ms::summary+ 0 N J1331+3030 13:31:08.2880 +30.30.32.9589 J2000 0 774800 <br />
INFO listobs::ms::summary+ 1 J J1822-0938 18:22:28.7042 -09.38.56.8350 J2000 1 1361750<br />
INFO listobs::ms::summary+ 2 NONE 3C391 C1 18:49:24.2440 -00.55.40.5800 J2000 2 2488850<br />
INFO listobs::ms::summary+ 3 NONE 3C391 C2 18:49:29.1490 -00.57.48.0000 J2000 3 2280850<br />
INFO listobs::ms::summary+ 4 NONE 3C391 C3 18:49:19.3390 -00.57.48.0000 J2000 4 2282150<br />
INFO listobs::ms::summary+ 5 NONE 3C391 C4 18:49:14.4340 -00.55.40.5800 J2000 5 2282150<br />
INFO listobs::ms::summary+ 6 NONE 3C391 C5 18:49:19.3390 -00.53.33.1600 J2000 6 2281500<br />
INFO listobs::ms::summary+ 7 NONE 3C391 C6 18:49:29.1490 -00.53.33.1600 J2000 7 2281500<br />
INFO listobs::ms::summary+ 8 NONE 3C391 C7 18:49:34.0540 -00.55.40.5800 J2000 8 2282150<br />
INFO listobs::ms::summary+ 9 Z J0319+4130 03:19:48.1601 +41.30.42.1030 J2000 9 350350 <br />
INFO listobs::ms::summary+ (nVis = Total number of time/baseline visibilities per field) <br />
INFO listobs::ms::summary Spectral Windows: (2 unique spectral windows and 1 unique polarization setups)<br />
INFO listobs::ms::summary+ SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
INFO listobs::ms::summary+ 0 64 TOPO 4536 2000 128000 4536 RR RL LR LL <br />
INFO listobs::ms::summary+ 1 64 TOPO 7436 2000 128000 7436 RR RL LR LL <br />
INFO listobs::ms::summary Sources: 20<br />
INFO listobs::ms::summary+ ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
INFO listobs::ms::summary+ 0 J1331+3030 0 - - <br />
INFO listobs::ms::summary+ 0 J1331+3030 1 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 0 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 1 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 0 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 1 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 0 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 1 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 0 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 1 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 0 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 1 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 0 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 1 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 0 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 1 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 0 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 1 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 0 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 1 - - <br />
INFO listobs::ms::summary Antennas: 26:<br />
INFO listobs::ms::summary+ ID Name Station Diam. Long. Lat. <br />
INFO listobs::ms::summary+ 0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
INFO listobs::ms::summary+ 1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
INFO listobs::ms::summary+ 2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
INFO listobs::ms::summary+ 3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
INFO listobs::ms::summary+ 4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
INFO listobs::ms::summary+ 5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
INFO listobs::ms::summary+ 6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
INFO listobs::ms::summary+ 7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
INFO listobs::ms::summary+ 8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
INFO listobs::ms::summary+ 9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
INFO listobs::ms::summary+ 10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
INFO listobs::ms::summary+ 11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
INFO listobs::ms::summary+ 12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
INFO listobs::ms::summary+ 13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
INFO listobs::ms::summary+ 14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
INFO listobs::ms::summary+ 15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
INFO listobs::ms::summary+ 16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
INFO listobs::ms::summary+ 17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
INFO listobs::ms::summary+ 18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
INFO listobs::ms::summary+ 19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
INFO listobs::ms::summary+ 20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
INFO listobs::ms::summary+ 21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
INFO listobs::ms::summary+ 22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
INFO listobs::ms::summary+ 23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
INFO listobs::ms::summary+ 24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
INFO listobs::ms::summary+ 25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
INFO listobs::::casa <br />
INFO listobs::::casa ##### End Task: listobs #####<br />
INFO listobs::::casa ##########################################<br />
</pre><br />
<br />
Note that the antenna IDs (which are numbered sequentially up to the total number of antennas in the array; 0 through 25 in this instance) do not correspond to the actual antenna names (ea01 through ea28; these numbers correspond to those painted on the side of the dishes). During our data reduction, we can refer to the antennas using either convention; ''antenna='22' '' would correspond to ea25, whereas ''antenna='ea22' '' would correspond to ea22. Note that the antenna numbers in the observer log correspond to the actual antenna names, i.e. the 'ea??' numbers given in listobs.<br />
<br />
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!). <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotants(vis='3c391_ctm_mosaic_10s_spw0.ms',figfile='3c391_ctm_mosaic_antenna_layout.png')<br />
clearstat() # This removes the table lock generated by plotants in script mode<br />
</source><br />
<br />
[[Image:3c391_ctm_plotants_parameters.jpg|200px|thumb|left|plotants parameters]]<br />
[[Image:3C391_mosaic-plotants.png|200px|thumb|center|plotants figure]]<br />
<br />
== Examining and Editing the Data ==<br />
<br />
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.<br />
<br />
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 less than 1 minute long.) This first scan can safely be deleted.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,scan='1')<br />
</source><br />
<br />
[[Image:3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
* <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.)<br />
* <strong>mode='manualflag'</strong> : Specific data are going to be selected to be edited. <br />
* <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 ''help 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.)<br />
<br />
If satisfied with the inputs, run this task. The initial display in the logger will include <br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: flagdata #####<br />
flagdata::::casa<br />
attached MS [...]<br />
Saving current flags to manualflag_1 before applying new flags<br />
Creating new backup flag file called manualflag_1<br />
</pre><br />
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_1. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used.<br />
<br />
<br />
<br />
From the observer's log, we know that antenna ea13 does not have a C band receiver and antenna ea15 had some corrupted data, so they should be flagged as well. The parameters are similar as before.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea13,ea15')<br />
</source><br />
* antenna='ea13,ea15' : Once again, this parameter requires a string input. Remember that antenna='ea13' and 'antenna='13' are <em>not</em> the same antenna. (See the discussion after our call to {{listobs}} above.)<br />
<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',mode='quack',quackinterval=10.0,quackmode='beg')<br />
</source><br />
* mode='quack' : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* 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.<br />
* 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.<br />
<br />
<br />
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}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat() # This removes any existing table locks generated by flagdata<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',xaxis='',yaxis='',averagedata=False,transform=False,extendflag=False,<br />
plotfile='',selectdata=True,field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* xaxis=' ', yaxis=' ' : One can choose the axes of the plot, i.e., the way of visualizing the data, by using the GUI display once the task is executed.<br />
* averagedata=F : It is possible to average the data in time, frequency, etc. <br />
* transform=F : It is possible to change the velocity reference frame of the data.<br />
* 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.<br />
* plotfile=' ' : It is possible to produce a hard copy (e.g., for a paper, report, or Web site) by specifying a file.<br />
* selectdata=T : One can choose to plot only subsets of the data.<br />
* field='0': The entire dataset is rather large, and different sources have very different amplitudes, so it is advisable to start by loading a subset of the data. One can later loop through the different fields (i.e. sources) and spectral windows using the GUI interface.<br />
<br />
In this case, many other 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.<br />
<br />
{{plotms}} should produce a GUI, with the default view being to show the visibility amplitude as a function of time. The figure at right shows the result of running {{plotms}} without the field selection (''field='0' '') discussed above.<br />
[[Image:plotms-default.png|200px|right|thumb|plotms default GUI view, having loaded all fields at once]]<br />
{{plotms}} allows one to select and view the data in many ways. Across the top of the left 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.<br />
<br />
In the default view, the 'Plots' tab is visible, and there are a number of tabs running down the side of the left 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.<br />
<br />
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 (baseline length, in meters), 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., <math>\sqrt{u^2+v^2}</math>). 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.) <br />
<br />
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]. To plot baseline length in wavelengths rather than meters, one needs to select ''UVDist_L'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view of 3C 391]]<br />
<br />
<br />
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.<br />
<br />
'''Do not''' close the plotms GUI after running {{plotms}}, or you will need to exit casapy and restart if at any point you wish to run plotms again, otherwise the GUI will not come up a second time.<br />
<br />
== Calibrating the Data ==<br />
<br />
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. <br />
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.<br />
<br />
Recall that the observed visibility <math>V^{\prime}</math> between two antennas <math>(i,j)</math> is related to the "true" visibility <math>V</math> by <br />
<br />
<math><br />
V^{\prime}_{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)\,e^{i [\theta_i(t) - \theta_j(t)]} <br />
</math><br />
<br />
Here, for generality, we show the visibility as a function of frequency <math>f</math> and spatial wavenumbers <math>u</math> and <math>v</math>. The other terms are <br />
* <math>g_i</math> and <math>\theta_i</math> 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 <math>t</math> to indicate that they can change with temperature, atmospheric conditions, etc.<br />
* <math>B_i</math> is the complex bandpass, the instrumental response as a function of frequency, <math>f</math>. As shown here, the bandpass may also vary as a function of time.<br />
* <math>b(t)</math> is the often-neglected baseline term. 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. <br />
Strictly, the equation above is a simplification of a more general measurement equation formalism, but it is a useful simplification in many cases.<br />
<br />
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., a priori models for the calibrators, and those derived 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. If you have started with the 10s-averaged dataset suggested at the top of this tutorial, this step has already been done for you, so may be omitted.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',spw='')<br />
</source><br />
<br />
All parameters are set to blank so that the initialization occurs for all sources and spectral windows.<br />
<br />
=== <i>A priori</i> Antenna Position Corrections ===<br />
<br />
As mentioned in the observing log above, antennas ea10, ea12, and ea22 do not have good baseline positions. Antenna ea10 was not in the array, but, for the other two antennas, any improved baseline positions need to be incorporated. The importance of this step is that the visibility function is a function of <math>u</math> and <math>v</math>. If the baseline positions are incorrect, then <math>u</math> and <math>v</math> will be calculated incorrectly, and there will be errors in the image. (These corrections could also be determined later by a baseline-based calibration incorporating the <math>b_{ij}</math> term from the equation above, but since they are known <i>a priori</i> it makes sense to incorporate them now.)<br />
<br />
Any corrections can be ascertained from the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site. For future reference, be sure to read to the bottom of that document to see how to calculate the additive corrections. Fortunately, the current case is simple as there is only a single correction for each antenna. The calculations are inserted via [[gencal]]. Currently these must be done by hand, though the plan is for future releases of CASA to have an automated lookup of the corrections.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',<br />
caltype='antpos',<br />
antenna='ea12,ea22',<br />
parameter=[-0.0072,0.0045,-0.0017, -0.0220,0.0040,-0.0190])<br />
</source><br />
<br />
[[Image:gencal.jpg|200px|thumb|right|gencal inputs]]<br />
* caltable='3c391_ctm_mosaic_10s_spw0.antpos' : CASA adopts a strategy of storing corrections in external tables. These can then be applied "on the fly" in future calibration steps, if warranted. <br />
* caltype='antpos' : [[gencal]] can incorporate several types of corrections, in this case corrections to antenna positions are specified.<br />
* antenna='ea12,ea22' : The two antennas for which corrections are to be specified.<br />
* parameter=[-0.0072,0.0045,-0.0017, -0.0220,0.0040,-0.0190] : The actual corrections to be applied. As suggested by the spacing in the listing, the first 3 parameters are for antenna ea12 and the second 3 parameters are for antenna ea22. The expected unit for antenna positions corrections for the EVLA is meters.<br />
<br />
=== Flux Density Scale ===<br />
<br />
The next 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 <math>g_i</math> values.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',<br />
modimage='/home/casa/data/nrao/VLA/CalModels/3C286_C.im',standard='Perley-Taylor 99',<br />
fluxdensity=-1)<br />
</source><br />
<br />
[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]<br />
* 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.<br />
* 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. The location of the model images is <strong>site-dependent</strong>. The above shows the location for the Array Operations Center/Dominici Science Operations Center. (For the <strong>2010 Synthesis Imaging Workshop</strong>, at Weir and Speare, the location is likely to be <tt>/nrao/data/nrao/VLA/CalModels</tt>.)<br />
* 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.<br />
* fluxdensity=-1 : It is possible to specify (i.e., force) the flux density of the source to be a particular value. Setting ''fluxdensity = -1'' (as done here) asks {{setjy}} to calculate the value based on a set of standard models if the source is one of the standard flux calibrators (i.e. 3C 286, 3C 48, or 3C 147).<br />
* spw='0' : The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw, but it will not hurt to do so. Had the spectral window 0 not been split off, as has been done here, we might wish to specify the spectral window because, in this observation, the spectral windows were sufficiently separated that two different model images for 3C 286 would be appropriate; 3C286_C.im at 4.6 GHz and 3C286_X.im at 7.5 GHz. This would require two separate runs of {{setjy}}, one for each spectral window. If the spectral windows were much closer together, it might be possible to calibrate both using the same model.<br />
<br />
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.<br />
<br />
The output from {{setjy}} should look similar to the following.<br />
<pre style="background-color: #ffe4b5;"><br />
INFO taskmanager::::casa ##### async task launch: setjy ########################<br />
INFO setjy::imager::setjy() J1331+3030 spwid= 0 [I=7.747, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
INFO setjy::imager::setjy() Using model image /home/casa/data/nrao/VLA/CalModels/3C286_C.im<br />
INFO setjy::imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
INFO setjy::imager::setjy() Scaling model image to I=7.74664 Jy for visibility prediction.<br />
INFO setjy::imager::data selection Selecting data<br />
</pre><br />
As set, the flux density scale is being set only for spectral window 0 (''spw='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. <br />
<br />
<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass.png|200px|thumb|right|bandpass illustration]]<br />
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 right. 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 as well. The variations with frequency are a reflection of the (slightly) different antenna bandpasses. (<em>Exercise for the reader, reproduce this plot using {{plotms}}.</em>)<br />
<br />
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. While amplitude variations will have little effect on the bandpass solutions, it is important to solve for any phase variations with time to prevent decorrelation when vector averaging the data in computing the bandpass solutions.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G0',field='J1331+3030',<br />
refant='ea21',spw='0:27~36',calmode='p',solint='int',minsnr=5,solnorm=T,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
[[Image:3C391_gaincal0.png|200px|thumb|right|gaincal inputs for first gain solutions]]<br />
* caltable='3c391_ctm_mosaic_10s_spw0.G0' : The gain solutions will be stored in an external table.<br />
* 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.<br />
* 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.<br />
* spw='0: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. Also note that, even though these data have only a single spectral window, the syntax requires specifying the spectral window in order to specify the spectral channels.<br />
* calmode='p' : Solve for only the phase portion of the gain.<br />
* 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)<br />
* 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.<br />
* solnorm=T : Strictly, for a phase-only solution, the amplitudes should be normalized by zero. This setting enforces that.<br />
* gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'] : Having produced antenna position corrections, they should now be applied.<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-R.png')<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.g0',xaxis='time',yaxis='phase',poln='L',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-L.png')<br />
</source><br />
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.<br />
[[Image:plotcal-3C286-G0-phase-R.png|200px|thumb|left|gain phases for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-phase-L.png|200px|thumb|center|gain phases for 3C 286, L polarization]]<br />
<br />
<br />
Alternatively, one can choose to inspect solutions for a single antenna at a time, stepping through each antenna in sequence:<br />
<source lang="python"><br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0_10s_spw0.g0',<br />
xaxis='time',yaxis='phase',poln='R',field='J1331+3030',iteration='antenna',<br />
plotrange=[-1,-1,-180,180],timerange='08:02:00~08:17:00')<br />
</source><br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. Note the phase jump on antenna ea05. You may wish to flag this antenna:<br />
<source lang="python"><br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T,mode='manualflag',selectdata=T,antenna='ea05',field='J1331+3030',timerange='08:02:00~08:17:00')<br />
</source><br />
<br />
Now form the bandpass itself, using the phase solutions just derived.<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.B0',<br />
field='J1331+3030',spw='',refant='ea21',solnorm=True,combine='scan',solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos','3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
[[Image:3C391_bandpass.png|200px|thumb|right|bandpass inputs]]<br />
* caltable='3c391_ctm_mosaic_10s_spw0.B0' : Specify where to store the bandpass corrections.<br />
* solnorm=T : Make sure that the amplitudes of the bandpass corrections are normalized to unity.<br />
* 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.<br />
* 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.<br />
* gaintable=['3c391_ctm_mosaic_10s_spw0.antpos','3c391_ctm_mosaic_10s_spw0_10s_spw0.G0'] : Two sets of corrections need to be applied in determining the bandpass solutions. The first is the set of antenna positions, the second are the phase solutions just derived. By specifying two values, in a python list, both tables will be applied on the fly prior to determining the bandpass solutions.<br />
<br />
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. We use ''iteration='antenna' '' to step through separate plots for each antenna.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-R.png')<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-L.png')<br />
</source><br />
<br />
[[Image:plotcal-3C286-G0-bandpass-R.png|200px|thumb|left|bandpass for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-bandpass-L.png|200px|thumb|center|bandpass for 3C 286, L polarization]]<br />
<br />
=== Gain Calibration ===<br />
<br />
The next step is to derive corrections for the complex antenna gains, <math>g_i</math> and <math>\theta_i</math>. As discussed in the lectures and above, the absolute magnitude of the gain amplitudes <math>g_i</math> are determined by reference to a standard flux density calibrator. In order to determine the appropriate complex gains for the target source, one wants to observe a so-called phase calibrator that is much closer to the target, in order to minimize differences through the atmosphere (neutral and/or ionized) between the lines of sight to the phase calibrator and the target source. If we determine the relative gain amplitudes and phases for different antennas using the phase calibrator, we can later determine the absolute flux density scale by comparing the gain amplitudes <math>g_i</math> derived for 3C 286 with those derived for the phase calibrator. This will eventually be done using the task {{fluxscale}}. Since there is no such thing as absolute phase, we determine a zero phase by selecting a reference antenna for which the gain phase is defined to be zero.<br />
<br />
In principle, one could determine the complex antenna gains for all sources with a single invocation of {{gaincal}}; for clarity here, two separate invocations will be used.<br />
<br />
In the first step, we derive the appropriate complex gains <math>g_i</math> and <math>\theta_i</math> for the flux density calibrator 3C 286.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J1331+3030',spw='0:5~58',<br />
solint='inf',refant='ea21',gaintype='G',calmode='ap',solnorm=F,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos','3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* caltable='3c391_ctm_mosaic_10s_spw0.G1' : Produce a new calibration table containing these gain solutions. In order to make the bookkeeping easier, a '1' is appended to the file name to distinguish it from the earlier set of gain solutions, which are effectively being "thrown away."<br />
* spw='0:5~58' : From the inspection of the bandpass, one can determine the range of edge channels that are affected by the bandpass filter rolloff. Because the amplitude is dropping rapidly in these channels, one does not want to include them in the solution.<br />
* gaintype='G', calmode='ap', solnorm=F : Solve for the complex antenna gains for 3C 286. The objective is to relate the measured data values to the (assumed known) flux density of 3C 286, thus the solution is both amplitude and phase ('ap') and the solutions should not be normalized to unity amplitude.<br />
* solint='inf' : Produce a solution for each scan.<br />
* gaintable=['3c391_ctm_mosaic_10s_spw0.antpos','3c391_ctm_mosaic_10s_spw0.B0'] : Use the antenna position corrections and bandpass solutions determined earlier before solving for the gain amplitudes.<br />
After reviewing the inputs to {{gaincal}} and running it, one could use {{plotcal}} to plot the solutions. While a useful sanity check, the plots themselves will be rather sparse as only a single gain amplitude is being determined for each antenna for each scan.<br />
<br />
<br />
In the second step, the appropriate complex gains for a direction on the sky close to the target source will be determined from the phase calibrator J1822-0938. We also determine the complex gains for the polarization calibrator source J0319+4130.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J1822-0938,J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
append=True,gaintable=['3c391_ctm_mosaic_10s_spw0.antpos','3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* caltable='3c391_ctm_mosaic_10s_spw0.G1' and append=True : In all previous invocations of {{gaincal}}, append has been set to False. Here, the gain solutions from the phase calibrators are going to be appended to the existing set from 3C 286. In following steps, all of these gain solutions will then be used together to derive a set of complex gains that are applied to the science data for the target source.<br />
If one checks the gain phase solutions using {{plotcal}}, one should see several solutions for each antenna as a function of time. In order to track the phases, the phase calibrator is typically observed much more frequently during the course of an observation than is the flux density calibrator. In the examples shown below, note that one of the panels is blank, which corresponds to antenna 13, the one flagged earlier in the process.<br />
<br />
[[Image:plotcal-J1822-0398-phase-R.png|200px|thumb|left|gain phase solutions for J1822-0398, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0398, L polarization]]<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Applying_the_calibration Applying the Calibration]].]</strong> ("Stay on target." Gold Five)<br />
<br />
Having set the complex gains, we now 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).<br />
<br />
Our initial run of {{setjy}} only set the total intensity of our flux calibrator source, 3C 286. This source is known to have a fairly stable fractional polarization of 11.2% at C-band, and a polarization position angle of 66 degrees. NRAO conducted regular monitoring of a number of polarization calibrators (including 3C 286) from 1999 through 2009. If you go to the [http://www.vla.nrao.edu/astro/calib/polar/ polarization calibration webpage] and follow the link for a particular year, then search for '1331+305 C band' (1331+305 is better known as 3C 286), you will see in the table the measured values for the percentage polarization and polarization position angle.<br />
<br />
In order to calibrate the position angle, we need to set the appropriate values for Stokes Q and U. Examining our casapy.log file to find the output of {{setjy}}, we find that the total intensity was set to 7.74664 Jy in spw0. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U.<br />
<br />
<source lang="python"><br />
# In CASA<br />
i0=7.74664 # Stokes I value for spw 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0<br />
</source><br />
<br />
We now set the values of Stokes Q and U for 3C 286, using {{setjy}} as we did before.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',modimage='',spw='0',fluxdensity=[i0,q0,u0,0])<br />
</source><br />
* modimage=' ' : A model image is not used here.<br />
<br />
Note that the Stokes V flux value is set to zero, corresponding to no circular polarization.<br />
<br />
==== Solving for the Leakage Terms ====<br />
<br />
The task we will use to do all the polarization calibration is {{polcal}}. In this data set, we observed the unpolarized calibrator J0319+4130 (a.k.a. 3C 84) in order to solve for the instrumental polarization. {{polcal}} uses the Stokes IQU values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The final function call is:<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D1',<br />
field='J0319+4130',spw='0:5~58',<br />
refant='ea21',poltype='Df',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos','3c391_ctm_mosaic_10s_spw0.B0','3c391_ctm_mosaic_10s_spw0.G1'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* caltable='3c391_ctm_mosaic_10s_spw0.D1' : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the ''caltable'' argument.<br />
* field='J0319+4130' : We use the unpolarized source J0319+4130 (a.k.a. 3C 84) to solve for the leakages.<br />
* poltype='Df' : We will solve for the leakages (''D'') on a per-channel basis (''f''). Had we have 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' '').<br />
* gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.G1'] : All of the previous corrections---antenna positions, bandpass, and complex gain---are to be applied on-the-fly by specifying them in a Python list.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp',spw='',field='',iteration='antenna')<br />
</source><br />
<br />
<br />
[[Image:3c391_ctm_plotcal_Df_solutions.jpg|thumb|{{plotcal}} GUI showing the Df solutions from {{polcal}} ]]<br />
This will produce plots similar to that shown at right.<br />
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.<br />
<br />
<br />
==== Solving for the R-L polarization angle ====<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.X1',<br />
field='J1331+3030',refant='ea21',<br />
poltype='Xf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.G1', '3c391_ctm_mosaic_10s_spw0.D1'])<br />
</source><br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',iteration='antenna')<br />
</source><br />
<br />
[[Image:3c391_ctm_plotcal_Xf_solutions.jpg|thumb|{{plotcal}} GUI showing Xf solutions from {{polcal}} ]]<br />
<br />
At this point, your dataset contains all the necessary polarization calibration, which will shortly be applied to the data.<br />
<br />
== Applying the Calibration ==<br />
<br />
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 ''u''-''v'' 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.<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
reference=['J1331+3030'],transfer=['J1822-0938,J0319+4130'])<br />
</source><br />
<br />
* caltable='3c391_ctm_mosaic_10s_spw0.G1' : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1' : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* reference='J1331+3030' : We specify the source with the known flux density.<br />
* transfer=['J1822-0938,J0319+4130'] : We specify the sources whose amplitude gains are to be rescaled.<br />
<br />
{{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. If one's data set has more than 1 spectral window, depending upon where they are spaced and the spectrum of the source, it is quite possible to find (quite) different flux densities at the different frequencies for the secondary calibrators. Example output would be<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO fluxscale::::casa ##########################################<br />
INFO fluxscale::::casa ##### Begin Task: fluxscale #####<br />
INFO fluxscale::::casa<br />
INFO fluxscale::calibrater::open Opening MS: 3c391_mosaic_10s.ms for calibration.<br />
INFO fluxscale::Calibrater:: Initializing nominal selection to the whole MS.<br />
INFO fluxscale::calibrater::fluxscale Beginning fluxscale--(MSSelection version)-------<br />
INFO fluxscale:::: Found reference field(s): J1331+3030<br />
INFO fluxscale:::: Found transfer field(s): J1822-0938 J0319+4130<br />
INFO fluxscale:::: Flux density for J1822-0938 in SpW=0 is: 2.32824 +/- 0.00706023 (SNR = 329.768, nAnt= 25)<br />
INFO fluxscale:::: Flux density for J0319+4130 in SpW=0 is: 13.7643 +/- 0.0348429 (SNR = 395.04, nAnt= 25)<br />
INFO fluxscale::Calibrater::fluxscale Appending result to 3c391_mosaic.fluxscale1<br />
INFO fluxscale:::: Appending solutions to table: 3c391_mosaic.fluxscale1<br />
INFO fluxscale::::casa<br />
INFO fluxscale::::casa ##### End Task: fluxscale #####<br />
</pre><br />
<br />
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 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.<br />
<br />
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.<br />
<br />
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). The relevant function calls are given below, although as explained presently, the calls to {{applycal}} will differ slightly if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.fluxscale1','3c391_ctm_mosaic_10s_spw0.B0','3c391_ctm_mosaic_10s_spw0.D1','3c391_ctm_mosaic_10s_spw0.X1'],<br />
parang=True,field='J1331+3030',gainfield=['','J1331+3030','','',''],interp=['','nearest','','',''],calwt=F)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.fluxscale1','3c391_ctm_mosaic_10s_spw0.B0','3c391_ctm_mosaic_10s_spw0.D1','3c391_ctm_mosaic_10s_spw0.X1'],<br />
parang=True,field='J0319+4130',gainfield=['','J0319+4130','','',''],interp=['','nearest','','',''],calwt=F)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.fluxscale1','3c391_ctm_mosaic_10s_spw0.B0','3c391_ctm_mosaic_10s_spw0.D1','3c391_ctm_mosaic_10s_spw0.X1'],<br />
parang=True,field='J1822-0938',gainfield=['','J1822-0938','','',''],interp=['','nearest','','',''],calwt=F)<br />
</source><br />
<br />
* gaintable : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in 3c391_ctm_mosaic_10s_spw0.antpos), the properly-scaled gain calibration for the amplitudes and phases (in 3c391_ctm_mosaic_10s_spw0.fluxscale1) which were just made using {{fluxscale}}, the bandpass solutions (in 3c391_ctm_mosaic_10s_spw0.B0), the leakage calibration (in 3c391_ctm_mosaic_10s_spw0.D1), and the R-L phase corrections (in 3c391_ctm_mosaic_10s_spw0.X1). 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.<br />
* gainfield, interp : 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''.<br />
* parang : Since we have performed polarization calibration, we '''must''' set ''parang=True'', or we will discard all that hard work we did earlier. However, if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization_Calibration]] section, the tables 3c391_ctm_mosaic_10s_spw0.D1 and 3c391_ctm_mosaic_10s_spw0.X1 will not exist. In this case, you should leave out the final two tables in the ''gaintable'' list, and the final two sets of empty elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
* calwt=F : At the time of writing, the EVLA is not yet recording real weights, thus trying to calibrate them can produce nonsensical results. In particular, experience has shown that calibrating the weights will lead to problems especially in the self-calibration steps.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. 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.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosiac_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.fluxscale1', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.D1', '3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','',''],<br />
interp=['linear'],<br />
parang=True,calwt=F)<br />
</source><br />
<br />
[[Image:3C391_applycal.png|200px|thumb|right|applycal inputs]]<br />
* field : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* gainfield : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* interp : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
[[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]]<br />
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, for one of the parallel-hand correlations (RR or LL; the signal in the cross-hands, RL and LR is much smaller, and will be noiselike for an unpolarized calibrator). This should then 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.<br />
<br />
Inspecting the data at this stage may well show up previously-unnoticed bad data. Plotting up the '''corrected''' amplitude against UV distance, or against time is a good way to find such issues. If you find bad data, you can remove them via interactive flagging in {{plotms}}, or via manual flagging in {{flagdata}} once you have identified the offending antennas/baselines/channels/times. When you are happy that all data (particularly on your target source) look good, you may proceed.<br />
<br />
Now that the calibration has been applied to the target data, we can split off the science targets, creating a new, calibrated measurement set containing all the target fields.<br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='3c391_ctm_mosaic_10s_spw0.ms',outputvis='3c391_ctm_mosaic_spw0.ms',<br />
datacolumn='corrected',field='2~8')<br />
</source><br />
<br />
* outputvis : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* datacolumn : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* field : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Imaging ==<br />
<br />
Now that we have split off the target data into a separate measurement set with all the calibration applied, it's time to make an image. Recall from the lectures that the visibility data and the sky brightness distribution (a.k.a. image) are Fourier transform pairs<br />
<br />
<math><br />
I(l,m) = \int V(u,v) e^{[2\pi i(ul + vm)]} dudv<br />
</math><br />
<br />
The <math>u</math> and <math>v</math> coordinates are the baselines, measured in units of the observing wavelength while the <math>l</math> and <math>m</math> coordinates are the direction cosines on the sky. For generality, the sky coordinates are written in terms of direction cosines, but for most EVLA (and ALMA) observations they can be related simply to the right ascension (<math>l</math>) and declination (<math>m</math>). Also recall from the lectures that this equation is valid only if the <math>w</math> coordinate of the baselines can be neglected. This assumption is almost always true at high frequencies and smaller EVLA configurations (such as the 4.6 GHz, D-configuration observations here); the <math>w</math> coordinate cannot be neglected at lower frequencies and larger configurations (e.g., 0.33 GHz, A-configuration observations). This expression also neglects other factors, such as the shape of the primary beam. For more information on imaging, see [[http://casa.nrao.edu/docs/userman/UserManch5.html#x236-2330005 Synthesis Imaging]] within the CASA Reference Manual.<br />
<br />
[[Image:3c391_clean_param.png|200px|thumb|left|clean parameters]]<br />
<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image.<br />
Assuming you did the polarization calibration earlier, a command line call to image and deconvolve the dataset would be:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54], smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
If you previously skipped the polarization calibration, you should instead set ''stokes='I' '' and ''psfmode='clark' ''.<br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* mode='mfs' : Use multi-frequency synthesis imaging. The fractional bandwidth of these data is non-zero (128 MHz at a central frequency of 4.6 GHz). Recall that the <math>u</math> and <math>v</math> coordinates are defined as the baseline coordinates, measured in wavelengths. Thus, slight changes in the frequency from channel to channel result in slight changes in <math>u</math> and <math>v</math>. There is a concomitant improvement in <math>u</math>-<math>v</math> coverage if the visibility data from the multiple spectral channels are gridded separately onto the <math>u</math>-<math>v</math> plane, as opposed to treating all spectral channels as having the same frequency.<br />
* niter=5000,gain=0.1,threshold='1.0mJy' : Recall that the CLEAN gain is the amount by which a CLEAN component is subtracted during the CLEANing process. niter and threshold are (coupled) means of determining when to stop the CLEANing process, with niter specifying to find and subtract that many CLEAN components while threshold specifies a minimum flux density threshold a CLEAN component can have before CLEAN stops. See also interactive below. Imaging is an iterative process, and to set the threshold and number of iterations, it is usually wise to CLEAN interactively in the first instance, stopping when spurious emission from sidelobes (arising from gain errors) dominates the residual emission in the field. Here, we have used our experience in interactive mode to set a threshold level based on the rms noise in the resulting image. The number of iterations should then be set high enough to reach this threshold.<br />
* interactive=T : Very often, particularly when one is exploring how a source appears for the first time, it can be valuable to interact with the CLEANing process. If True, interactive causes a {{viewer}} window to appear. One can then set CLEAN regions, restricting where CLEAN searches for CLEAN components, as well as monitor the CLEANing process. A standard procedure is to set a large value for niter, and stop the CLEANing when it visually appears to be approaching the noise level. This procedure also allows one to change the CLEANing region, in cases when low-level intensity becomes visible as the CLEANing process proceeds. For more details, see [[http://casa.nrao.edu/docs/userman/UserMansu254.html#x292-2870005.3.14 Interactive Cleaning]], and also the discussion below.<br />
* imsize=[576], cell=['2.5arcsec'] : See the discussion below regarding the setting of the image size and cell size.<br />
* stokes='IQUV' and psfmode='clarkstokes' : Separate images will be made in all four polarizations (total intensity I, linear polarizations Q and U, and circular polarization V), and, with psfmode='clarkstokes', the Clark CLEAN algorithm will deconvolve each Stokes plane separately thereby making the polarization image more independent of the total intensity.<br />
* weighting='briggs',robust=0.0 : 3C 391 has diffuse, extended emission that is (at least partially) 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, Briggs weighting is used (intermediate between natural and uniform weighting), with a default robust factor of 0.<br />
* imagermode='mosaic', ftmachine='mosaic' : The data consist of a 7-pointing mosaic, since the supernova remnant fills almost the full primary beam at 4.6 GHz. A mosaic combines the data from all of the fields, with imaging and deconvolution being done jointly on all 7 fields. A mosaic both helps compensate for the shape of the primary beam and reduces the amount of large (angular) scale structure that is resolved out by the interferometer.<br />
* multiscale=[0, 6, 18, 54], smallscalebias=0.9 : A multi-scale CLEANing algorithm is used because the supernova remnant contains both diffuse, extended structure on large spatial scales and finer filamentary structure on smaller scales. The settings for multiscale are in units of pixels, with 0 pixels equivalent to the traditional delta-function CLEAN. The scales here are chosen to provide delta functions and then three logarithmically scaled sizes to fit to the data. The first scale (6 pixels) is chosen to be comparable to the size of the beam. The smallscalebias attempts to balance the weight given to larger scales, which often have more flux density, and the smaller scales, which often are brighter. Considerable experimentation is likely to be necessary; one of the authors of this document found that it was useful to CLEAN several rounds with this setting, change multiscale to be multiscale=[] and remove much of the smaller scale structure, then return to this setting.<br />
<br />
Setting the appropriate pixel depends upon basic optics aspects of interferometry. Using [[plotms]] to look at the newly-calibrated, target-only data set,<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_spw0.ms',xaxis='uvdist_l',yaxis='amp')<br />
</source><br />
[[Image:3c391 ctm spw0 uvplt.jpg|thumb|{{plotms}} GUI showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
one should obtain a plot similar to the one shown at the right with the (calibrated) visibility amplitude as a function of <math>u</math>-<math>v</math> distance.<br />
The maximum baseline is about 16,000 wavelengths, i.e., an angular scale of 12 arcseconds (<math>\lambda/D=1/16000</math>). The most effective CLEANing occurs with 3--5 pixels across the synthesized beam. Above, a cell size of 2.5 arcseconds (just under 5 pixels per beam) is specified. If only one value for the cell size is specified (as done here), the same value is used in both directions.<br />
<br />
The supernova remnant itself is known to have a diameter of order 9 arcminutes, corresponding to about 216 pixels for the chosen cell size. The mosaic was set up with 7 fields, 1 centered on the remnant and 6 flanking fields; the spacing of the fields was chosen based on the size of the (antenna) primary beam. In order to prevent image artifacts arising from aliasing due to the mosaicing, the image should be sized such that the supernova remnant is restricted to the inner quarter of the image. CASA also has the feature that its Fourier transform engine does <em>not</em> require a strict power of 2 for the number of pixels in the image (i.e., <math>2^n \times 2^n</math> pixel image).<br />
<!-- 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\times216</math>. We therefore set ''imsize=[576,576]''.<br />
--><br />
<br />
[[Image:3C391 interactive clean.png|thumb|Example of interactive cleaning]]<br />
As mentioned above, we can guide the clean process by allowing it to find clean components only within a user-specified region. The easiest way to do this is via interactive clean. When {{clean}} runs in interactive mode, a viewer window will pop up as shown right. To get a more detailed view of the central regions containing the emission, zoom in by tracing out a rectangle with your left mouse button and double-clicking inside the zoom box you just made. Play with the color scale to bring out the emission better, by holding down the middle mouse button and moving it around. To create a clean box (a region within which components may be found), you can either hold down the right mouse button and trace out a rectangle around the source, then double click inside that rectangle to set it as a box. Alternatively, you can trace out a more generic shape to better enclose the irregular outline of the supernova remnant. To do that, right-click on the icon highlighted in green in the figure shown at right. Then trace out a shape by right-clicking where you want the corners of that shape. Once you have come full circle, the shape will be traced out in green, with small squares at the corners. Double-click inside this region and the green outline will turn white. You have now set your clean region. To toggle back to the rectangle tracer again, right-click on the icon circled in green in the figure at right. If you have made a mistake with your clean box, click on the "Erase" button, trace out a rectangle around your erroneous region, and double click inside that rectangle. You can also set multiple clean regions. By default, all clean regions will apply only to the plane shown. To change this to select all planes, click the "All Channels" button at the top. <br />
<br />
When you are happy with your clean regions, press the green circular arrow button on the far right to continue deconvolution. After completing a cycle, a revised image will come up. As the brightest points are removed from the image ("cleaned" off), fainter emission may show up. You can adjust the clean boxes each cycle, to enclose all real emission. After many cycles, once only noise is left, you can hit the red and white cross icon to stop cleaning.<br />
<br />
<br />
[[Image:3c391_ctm_i_image.jpg|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391 at 4600 MHz]]<br />
{{clean}} will make several output files, all named with the prefix given as ''imagename''. These include:<br />
* .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<br />
* .flux - the effective response of the telescope (the primary beam)<br />
* .flux.pbcoverage - the effective response of the full mosaic image<br />
* .mask - the areas where you have permitted imager to find clean components<br />
* .model - the sum of all the clean components, which has been stored as the model_data column in the measurement set<br />
* .psf - the dirty beam, which is being deconvolved from the true sky brightness during the clean process<br />
* .residual - what is left at the end of the deconvolution process; this is useful to diagnose whether or not to clean more deeply<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
<br />
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).<br />
<br />
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.<br />
<br />
The example above illustrates multi-scale CLEAN. Not all sources or fields will require multi-scale CLEAN; for reference, here is the same data set, but without multi-scale CLEANing.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_no_multiscale_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
== Next Steps ==<br />
<br />
There are a variety of additional analyses that could be done, including extracting the statistics of the images just produced, continuing with the polarization imaging, and self-calibration of the data. Examples of these topics are included in <br />
[[EVLA Advanced Topics 3C391]].<br />
<br />
If one is reading this as part of the Day 1 Summer School Tutorial, and there is time, one could consider beginning one of these advanced topics.</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Main_Page_Old&diff=4059Main Page Old2010-06-10T09:45:43Z<p>Jgallimo: /* Contents */</p>
<hr />
<div>{| style="width: 100%; valign: top; background-color:#CCFFFF; border:1px solid #3366FF;" cellpadding=10 <br />
|- valign="top" <br />
| style="width: 49%; valign:top; " |<br />
<big>'''Welcome to {{SITENAME}}'''</big><br /> [http://casa.nrao.edu/ CASA] (Common Astronomy Software Applications) is a comprehensive software package to calibrate, image, and analyze radioastronomical data from interferometers (such as {{ALMA}} and {{EVLA}}, both shown at right) as well as single dish telescopes. This wiki provides examples and hints for reducing data in CASA. <br />
<br />
| style="width: 2%; valign:top; " |<br />
<br />
| style="width: 49%; valign:top" |<br />
[[File:ALMA-EVLA.png|400px|center]]<br />
|}<br />
<br />
<br />
{| style="width: 100%; valign: top; " cellpadding=10 <br />
|- valign="top"<br />
| style="width: 49%; valign:top; background-color:#CCFFCC;border:1px solid #3366FF;" |<br />
<big>'''CASA Events'''</big><br />
----<br />
{{Events}}<br />
<br />
<br><br />
<br />
<big>'''CASA News'''</big><br />
----<br />
{{News}}<br />
<br />
| style="width: 2%; valign:top; " |<br />
<br />
| style="width: 49%; valign:top; background-color:#CCFFCC;border:1px solid #3366FF;" |<br />
<big>'''Featured article'''</big><br />
----<br />
{{FeaturedArticle}}<br />
<br />
<br />
<br />
|}<br />
<br />
__NOTOC__<br />
[[Category:VLA]] [[Category:CARMA]] [[Category:EVLA]] [[Category:ALMA]] [[Category:Calibration]] [[Category:Imaging]]<br />
<br />
<br />
== Contents ==<br />
<br />
{| style="width: 100%; valign: top"<br />
|- valign="top"<br />
| style="width: 50%; valign:top;" |<br />
=== Using CASA ===<br />
<br />
|- valign="top"<br />
| style="width: 50%; valign:top;" |<br />
* [http://casa.nrao.edu/ CASA Homepage]<br />
* [[What is CASA?]]<br />
* [[Getting Started in CASA]]<br />
* [[Installing CASA]]<br />
* [[CASA Reference Manuals]]<br />
<br />
| style="width: 50%; valign:top;" |<br />
* [[AIPS-to-CASA Cheat Sheet]]<br />
* [[CASA Hints, Tips, and Tricks|Hints, Tips, & Tricks]]<br />
* [[CASA python script list for special applications]]<br />
<br />
|- valign="top"<br />
| style="width: 50%; valign:top;" |<br />
<br />
=== Interactive Tools in CASA ===<br />
<br />
|- valign="top"<br />
| style="width: 50%; valign:top;" |<br />
* [http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html CASA viewer demonstration video]<br />
* [[Data flagging with viewer]]<br />
* [[Data flagging with plotms]]<br />
<br />
| style="width: 50%; valign:top;" |<br />
* [[Averaging data in plotms]]<br />
* [[What's the difference between Antenna1 and Antenna2? Axis definitions in plotms|Axis definitions in plotms]]<br />
<br />
|- valign="top"<br />
| style="width: 50%; valign:top;" |<br />
=== Data Reduction Guides ===<br />
<br />
|- valign="top" style="width: 50%; valign:top;" <br />
| colspan="2" |<br />
* [[Extracting scripts from these tutorials]]<br />
* [[Initial instructions for 2010]] ('''read this before starting any tutorials for the 2010 Imaging Synthesis Workshop!''')<br />
|- valign="top"<br />
| style="width: 50%; valign:top;" |<br />
* ''ALMA Guides''<br />
** [http://science.nrao.edu/alma/ALMA-QuickRef.gif ALMA Quick Reference]<br />
** [http://www.eso.org/sci/facilities/alma/observing/tools/etc/index.html ALMA Sensitivity Calculator]<br />
** [[Current MM/Submm Guides]]<br />
<br />
* ''EVLA Guides''<br />
** [[EVLA Tutorials | Tutorials]]<br />
** [[EVLA Hints, Tips, & Tricks | Hints, Tips, & Tricks]]<br />
<br />
| style="width: 50%; valign:top;" |<br />
* ''VLA Guides''<br />
** [[VLA Tutorials | Tutorials]]<br />
** [[VLA Hints, Tips, & Tricks | Hints, Tips, & Tricks]]<br />
<br />
* ''CARMA Guides''<br />
** [[CARMA Tutorials | Tutorials]]<br />
** [[CARMA Hints, Tips, & Tricks | Hints, Tips, & Tricks]]<br />
<br />
* ''SMA Guides''<br />
** [[SMA Tutorials | Tutorials]]<br />
<br />
|- valign="top"<br />
| style="width: 50%; valign:top;" |<br />
<br />
=== Simulated Observations ===<br />
* [[Simulating Observations in CASA]]<br />
* [[M51 at z = 0.1 and z = 0.3|Simulated ALMA Observation of M51 at z = 0.1 and z = 0.3]]<br />
<br />
|- valign="top"<br />
| style="width: 50%; valign:top;" |<br />
<br />
=== Indices ===<br />
* [[Special:AllPages| List of All Articles]]<br />
* [[Special:Categories|Index by Category]]<br />
<br />
=== Authors ===<br />
* [http://meta.wikimedia.org/wiki/Help:Contents MediaWiki markup language]<br />
* [[Instructions for Authors|CASAGuides Instructions for Authors]]<br />
<br />
|}<br />
<br />
== Useful Links ==<br />
<br />
[http://my.nrao.edu my.nrao.edu - Your Portal to NRAO Services]<br />
<br />
[http://docs.python.org/ Python Documentation]<br />
<br />
[http://evlaguides.nrao.edu/index.php?title=Main_Page EVLA Guides]<br />
<br />
[http://www.splatalogue.net Splatalogue - Astronomical Line Database]<br />
<br />
[http://www.cv.nrao.edu/~rreid/casa/scripts/atoz.html CASA python script repository (temporary)]<br />
<br />
<br />
----<br />
<br />
<br />
[[Special:Allpages|{{NUMBEROFARTICLES}} articles]] since July 2009. <br />
<br />
<div style="clear: left; width: 100%; height: 0; visibility: hidden;"></div><br />
<br />
<hr/><br />
<br />
<div style="text-align:center;">Consult the [http://meta.wikimedia.org/wiki/Help:Contents Wiki User's Guide] for information on using the wiki software.</div></div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Extracting_scripts_from_these_tutorials&diff=4058Extracting scripts from these tutorials2010-06-10T09:35:26Z<p>Jgallimo: /* Version Notes */</p>
<hr />
<div>The series of commands shown in each tutorial can be thought of as a data reduction script that can be run in CASA like so:<br />
<br />
<pre><br />
execfile('scriptname.py')<br />
</pre><br />
<br />
where 'scriptname.py' is the name of an ascii file containing all of the CASA commands you want to run.<br />
<br />
Hopefully the scripts contained in this documentation are (a) useful and (b) work. They were however developed with CASA still a work in progress, and so scripts may break as commands, arguments, and keywords change. We developed this script extractor to allow us to easily extract scripts from these pages and run them. Feel free to try it--it's handy for general users too! <br />
<br />
The only differences you will see between the commands in each tutorial and the extracted script are requests for response from you after each interactive command (plotants, plotcal, plotms, etc.). These are to ensure that the tables you access to make plots are closed properly before they are needed by some following task (otherwise, you may experience the dreaded "table lock" errors, that may cause problems with your script, or in some cases even your CASA session.) <br />
<br />
<div style="background-color: #dddddd;"><br />
'''Note:''' the intention is to extract CASA scripts for testing; commands which are to be run on the command line outside of CASA, or within other software packages, will not be extracted.<br />
</div><br />
<br />
<br />
<br />
__TOC__<br />
<br />
== How to Get the Script Extractor ==<br />
<br />
Download the script extraction code.<br />
<br />
<source lang="bash"><br />
<br />
# in bash<br />
ftp ftp.cv.nrao.edu<br />
# log in anonymously with e-mail as password<br />
cd NRAO-staff/jgallimo<br />
get extractCASAscript.py<br />
</source><br />
<br />
Wget may be even simpler if you have it installed.<br />
<br />
<source lang="bash"><br />
# in bash<br />
wget ftp://ftp.cv.nrao.edu:/NRAO-staff/jgallimo/extractCASAscript.py<br />
</source><br />
<br />
== How to Use the Script Extractor ==<br />
<br />
Make your newly acquired python script executable.<br />
<br />
<source lang="bash"><br />
# in bash<br />
chmod u+x extractCASAscript.py<br />
</source><br />
<br />
To run it, issue the python script name and give the URL as the argument. For example:<br />
<br />
<source lang="bash"><br />
# in bash<br />
./extractCASAscript.py http://casaguides.nrao.edu/index.php?title=Calibrating_a_VLA_5_GHz_continuum_survey<br />
</source><br />
<br />
In csh, you need quotes around the URL:<br />
<br />
<source lang="dos"><br />
# in csh<br />
./extractCASAscript.py 'http://casaguides.nrao.edu/index.php?title=Calibrating_a_VLA_5_GHz_continuum_survey'<br />
</source><br />
<br />
<br />
This command will automatically generate a script called "CalibratingaVLA5GHzcontinuumsurvey.py"<br />
<br />
== Version Notes ==<br />
<br />
* 30 Oct 2009: Script created -- jfg.<br />
* 17 Dec 2009: Fixed a bug that caused the script to drop brackets [] & {} incorrectly. Added script pauses for interactive commands viewer, plotms, plotxy, and plotcal. -- jfg<br />
* 25 Feb 2010: Some minor bug fixes. -- jfg<br />
* 19 Apr 2010: Better handling of interactive commands; allows for multi-line interactive commands.<br />
* 21 May 2010: On-going improvements, mostly handling conversion of html math symbols into usable characters.<br />
* 10 Jun 2010: The script is stable, but I've noticed some characters appear that don't correctly translate from html. The script searches for html codes for symbols and replaces them with ASCII symbols --- for example, translating "&gt;" to ">" --- but it is uncertain whether I have caught all of the html characters produced by the GeSHI plug-in. It should be hopefully obvious how to fix html symbols that leak through to the extracted python script.<br />
<br />
--[[User:Jgallimo|Jack Gallimore]] 21:13, 3 November 2009 (UTC)</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=User:Jgallimo&diff=3759User:Jgallimo2010-06-04T20:39:28Z<p>Jgallimo: </p>
<hr />
<div>Jack Gallimore was here while listening to [http://en.wikipedia.org/wiki/Mott_the_Hoople Mott the Hoople].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Spectral_Line_Imaging_Analysis_IRC%2B10216&diff=3758EVLA Spectral Line Imaging Analysis IRC+102162010-06-04T20:35:31Z<p>Jgallimo: /* Self-Calibration */</p>
<hr />
<div><pre style="background-color: #FFFF00;"><br />
This tutorial is under construction. There are several things still to be added <br />
<br />
For the time being (until release candidate is built) you want to run this on casapy-test<br />
<br />
</pre><br />
<br />
This tutorial picks up where [[EVLA Spectral Line Calibration IRC+10216]] leaves off. <br />
<br />
== UV Continuum Subtraction and Setting Up for Self-Calibration==<br />
<br />
[[Image:irc10216_uvspec.png|thumb|UV-plot of the spectral line signal in both spw for IRC+10216.]]<br />
Now we can make a vector averaged uv-plot of the calibrated target spectral line data. It is important to note that you will only see signal in such a plot if (1) the data are well calibrated, and (2) there is significant signal near the phase center of the observations, or if the line emission (or absorption) is weak but extended. If this isn't true for your data, you won't be able to see the line signal in such a plot and will need to make an initial (dirty or lightly cleaned) line+continuum cube to determine the line-free channels. Generally, this is the recommended course for finding the line-free channels more precisely than is being done here due to time constraints, as weak line signal would not be obvious in this plot. <br />
<br />
<source lang="python"><br />
plotms(vis='IRC10216',field='',ydatacolumn='corrected',<br />
xaxis='channel',yaxis='amp',correlation='RR',<br />
avgtime='1e8',avgscan=T,spw='0~1:4~60',antenna='')<br />
</source><br />
<br />
in the Display tab, choose colorize by spw and change the Unflagged points symbol to custom and Style of 3. <br />
<br />
You should see the "horned profile" typical of a rotation shell. From this plot, you can guess that strong <br />
line emission is restricted to channels 18 to 47 (zoom in if necessary to see exactly what the channel numbers are). <br />
<br />
In the Data tab you can also click on "all baselines" to average all baselines, but this is a little harder to see.<br />
<br />
Now we want to use the line free channels to create a model of the continuum emission that can be subtracted to form a line-only dataset. We want to refrain from going to close to the edges of the band -- these channels are typically noisy, and we don't want to get too close to the line channels because we could only see strong line emission in the vector averaged uv-plot.<br />
<br />
<source lang="python"><br />
uvcontsub2(vis='IRC10216',fitspw='0~1:4~13;52~60',<br />
want_cont=T)<br />
</source><br />
<br />
The "want_cont=T" will produce two new datasets, IRC10216.contsub is the continuum subtracted line data, and IRC10216.cont is the continuum estimate (note however, that it is still a multi-channel dataset).<br />
<br />
'''If you want to try self-cal:''' Unfortunately, at the moment, uvcontsub2 doesn't leave the continuum subtracted line dataset in the state you need *if* you think you might want to self-calibrate the data later. This is because {{clean}} always looks at the "corrected" datacolumn, while {{gaincal}} (also used for self-calibration) always looks at the "data" column. You also need to know that unless the imagename supplied to clean already exists, clean always overwrites the model column with the clean model (this will be the model supplied to the self-calibration process).<br />
<pre style="background-color: #E0FFFF;"><br />
The files produced by uvcontsub2 will have the following in their data columns:<br />
Data Model Corrected<br />
IRC10216.contsub Line+Cont Cont Line<br />
IRC10216.cont Cont Cont Cont<br />
</pre><br />
<br />
Now the imaging task {{clean}} will clean both of these files fine, and correctly overwrite the model data column with the correct clean model. However, if you try to self-cal (i.e. run gaincal) on the continuum subtracted line data (.contsub), it will use the Line+Cont as its input along with the line only clean model. If the line and continuum have significantly different morphology (almost always) the self-cal process will fail. In contrast the continuum dataset (.cont) will work fine because the Data and Corrected columns agree. <br />
<br />
To fix things up, we must {{split}} the "corrected" column (which places "Corrected" in the "Data" column of the new dataset. Then you can either run clearcal to reinitialize the "model" and "corrected" columns or let clean do it for you. We put this step here explicitly for clarity about the process.<br />
<br />
<source lang="python"><br />
split(vis='IRC10216.contsub',outputvis='IRC10216.contsub.data')<br />
</source><br />
<source lang="python"><br />
clearcal(vis='IRC10216.contsub.data')<br />
</source><br />
<br />
Now IRC10216.contsub.data will have the Line in the "data" column, 1 in the "model" column for amplitudes and 0 for phase, and the Line in the "corrected" column as desired. You can always check this using {{plotms}} to <br />
look at the "data", "model", and "corrected" columns.<br />
<br />
We expect that these extra shenanigans will be unnecessary in the future.<br />
<br />
==Image the Spectral Line Data==<br />
<br />
Here we make images from the continuum-subtracted, calibrated spectral line data. Because the spectral line emission from IRC+10216 has significant extended emission, it is very important to run clean interactively, and make a clean mask. To make the cube a bit smaller and stay away from noisy edge channels we restrict the <br />
channel range using the spw parameter.<br />
[[Image:viewer_interactive.png|thumb|Channel 28 shown for the HC3N cube shown in the interactive viewer with the white contour showing the mask contour drawn with the polygon tool.]]<br />
<br />
<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_HC3N.cube_r0.5',<br />
imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='0:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.39232GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
interactive=T,<br />
threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
It will take a little while to grid the data, but the {{viewer}} will open when it's ready to start an interactive clean. Use the "tape deck" at the bottom of the Viewer display GUI to step through to the channel with the most extended (in angular size) emission, select "all channels" for the clean mask, select the polygon tool (second in from the right) and make a single mask that applies to all channels (see example in thumbnail). Once you make the polygon region, you need to double click inside it to save the mask region -- if you see the polygon turn white you will know you succeeded. Note, that if you had the time and patience you could make a clean mask for each channel, and this would create a slightly better result. <br />
<br />
After making the mask you should check that the emission in all the other channels fits within the mask you made using the "tape deck" to move back and forth. If you need to include more area in the mask, you can chose the "erase" toggle at the top, and then encircle your existing mask with a polygon and double click inside. Then go back to "add" toggle at top and make a new mask. Alternatively, you can erase a part of the mask, or you can add to the existing mask by drawing new polygons. Feel free to experiment with this a bit.<br />
<br />
'''note''': If you start an interactive clean, and then do not make a mask, clean will stop when you tell it to go on because it has nothing to clean. There is no default mask. <br />
<br />
To continue with {{clean}} use the "Next action" buttons in the green area on the Viewer Display GUI: The red X will stop {{clean}} where you are, the blue arrow will stop the interactive part of {{clean}}, but continue to clean non-interactively until reaching the stopping niter or threshold (whichever comes first), and the green arrow will clean until it reaches the "iterations" parameter on the left side of the green area. When <br />
the interactive viewer comes back use the tape deck to recheck that your mask encompasses what you think is real emission. The middle mouse button by default controls the image stretch.<br />
<br />
Note that for this example, threshold has been set to threshold='3mJy' to protect you from cleaning too deeply. With a careful clean mask you can clean to close to the thermal noise limit (note here I mean the actual observed rms noise limit and not the theoretical one you calculated for the proposal, as flagging, weather etc can affect what you actually get). It is ALWAYS best to clean each channel in a cube to a specific threshold than to stop by simply using the niter parameter, which can leave each channel cleaned to different levels. There are many ways to determine a suitable threshold. One way is to make a dirty image (niter=0), open the cube using the viewer, go to a line free channel, select the box region tool, make a box near the field center about the size of your source, and double click inside. The rms noise of that channel will appear in a pop-up window (rms noise for whole cube will go to terminal). Try a few different boxes, average the results and this is a good estimate of the rms per channel assuming your data are not dynamic range limited (i.e. noise can be higher in channels with strong signal). This is the absolute minimum for threshold. With no mask you probably shouldn't clean deeper than 3x this rms. <br />
<br />
[[Image:SiS_interactive.png|thumb|Channel 16 shown for the SiS cube in the interactive viewer with the white contour showing the mask contour drawn with the polygon tool.]]<br />
<br />
Keep cleaning, by using the green Next Action arrow until the residual displayed in the viewer looks "noise like". To speed things up, you might change the iteration parameter in the viewer to something like 300. This parameter can also be set in the task command. You will notice that in this particular case, there are residuals that cannot be cleaned -- these are due to the extended resolved out structure on size scales larger than the array is sensitive to (the "Largest Angular Scale" or LAS that the array is sensitive to can be calculated from the shortest baseline length), and potential residual phase and amplitude calibration errors. We will explore this in a few sections with self-calibration. <br />
<br />
Repeat the process for the SiS line using the call below, note that the emission for this line is less extended than the HC3N -- this has to do with the different excitation requirements of the two different lines. The SiS is excited closer to the central star than the HC3N.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_SiS.cube_r0.5',<br />
imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='1:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.30963GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
interactive=T,<br />
threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
You can look at both cubes using the viewer, and the tape deck to play the cube as "movie".<br />
<source lang="python"><br />
# In CASA<br />
viewer<br />
</source><br />
<br />
==Image the Continuum data==<br />
<br />
Below the use of mode='mfs' will make a single multi-frequency synthesis image out of the specified spw/channels. Again you should make an interactive clean mask. Since no threshold is set, you will need to stop cleaning when the residual looks noise like using the red x "Next Action" button (it will be done when the viewer comes back the second time). The continuum for IRC10216 is very weak but interesting -- it is essentially tracing the photosphere of the AGB star. <br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.cont',imagename='IRC10216.36GHzcont',<br />
mode='mfs',imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='0~1:5~59',<br />
weighting='briggs',robust=0.5,<br />
interactive=T)<br />
</source><br />
<br />
Now look at the result in the viewer if you like<br />
<br />
<source lang="python"><br />
# In CASA<br />
Viewer<br />
</source><br />
<br />
==Image Analysis and Viewing==<br />
<br />
Next make integrated intensity maps (moment 0) and integrated velocity maps (moment 1). To do this, we'll want to know what channels the line emission starts and ends on, and also the rms noise in a single channel. So first lets open the viewer:<br />
<br />
<source lang="python"><br />
# In CASA <br />
viewer<br />
</source><br />
<br />
Then use the Viewer tape deck to see which channels have significant line emission. For HC3N, the line channel range in the cube is 11 to 40, and it is the same for SiS. <br />
<br />
Then use the tape deck to go to a line free channel, select the box region tool and make a box. When you double click in the box, the image statistics for the whole cube will print to the terminal and for the channel you are on, it will print to a pop up window. Move the box around a bit to see what the variation in rms noise is. You should get something like 2 mJy. Note that the rms is much worse in channels with strong emission because of the low dynamic range of these data. If you want the box tool to go away (i.e. if you want to make a new one), hit the escape key. <br />
<br />
Now lets make the moment 0 and moment 1 maps. For moment zero, it's best to limit the calculation to image channels with significant signal in them, but not to apply a flux cutoff, as this will bias the derived integrated intensities upward.<br />
<br />
[[Image:irc10216.jpg|thumb|HC3N moment 0 map with white continuum contours superposed.]]<br />
[[Image:irc10216_sismom0.jpg|thumb|SiS moment 0 map with white continuum contours superposed.]]<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_HC3N.cube_r0.5.image',moments=[0],<br />
axis='spectral',<br />
chans='11~40',<br />
outfile='IRC10216_HC3N.cube_r0.5.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_SiS.cube_r0.5.image',moments=[0],<br />
axis='spectral',<br />
chans='11~40',<br />
outfile='IRC10216_SiS.cube_r0.5.image.mom0')<br />
</source><br />
<br />
For moment 1, it is essential to apply a conservative flux cutoff to limit the calculation to high signal-to-noise areas. Here we use about 5sigma.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_HC3N.cube_r0.5.image',moments=[1],<br />
axis='spectral',<br />
chans='11~40',excludepix=[-100,0.01],<br />
outfile='IRC10216_HC3N.cube_r0.5.image.mom1')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_SiS.cube_r0.5.image',moments=[1],<br />
axis='spectral',<br />
chans='11~40',excludepix=[-100,0.01],<br />
outfile='IRC10216_SiS.cube_r0.5.image.mom1')<br />
</source><br />
<br />
Now use the viewer to further explore the images you've made.<br />
<br />
== Self-Calibration ==<br />
<br />
The many different aspects of self-calibration could fill several casaguides. Here we describe a simple process for this particular relatively low S/N data (low S/N per channel at least).<br />
<br />
While running {{clean}} above, the model column for each channel will have been filled with the clean model (if you made a Fourier transform of this model, you would see an image of the clean components). <br />
<br />
We chose to do the self cal on the spw=1 SiS line data because it has the strongest emission in a single channel and is a bit more compact than the HC3N data. We will run {{gaincal}} specifying the channel in the uv-data that has the brightest peak in the image (use the {{viewer}} to figure out which channel this is for spw=1), note down what the peak flux is. Since we started the image with a channel range we need to account for the fact that the image channel numbers do not map exactly to the uv-data channel numbers (they are off by 5 so that channel 13 in the image is roughly channel 19 in the uv-data). <br />
<br />
The next thing we need to understand is the S/N of the data. In particular, to self-cal, you need enough signal on a single baseline over the course of your chosen solint to get a S/N of about 3. Above we calculated an average rms noise of about 2 mJy/beam/channel for the whole timerange (about 95 minutes on source time) and all antennas (16). We can use our knowledge of the radiometer equation (see [http://evlaguides.nrao.edu/index.php?title=Category:Status#Sensitivity EVLA Sensitivity]) where rms scales as 1/sqrt(time * #baselines), and the number of baselines= N(N-1)/2 and N=# of antennas. So the rms noise on one baseline, one 10 second integration is given by:<br />
<br />
<math> {\rm RMS(baseline)} = {\rm 2\ mJy\ beam^{-1}\ channel^{-1}} \sqrt{ \frac{95\times 60\ {\rm sec}}{10\ {\rm sec}}\times\frac{16\times 15}{2\times 1}}</math><br />
<br />
[[Image:timeonsource.png|thumb|Plot to estimate the time on source.]]<br />
<br />
The 95 minutes of on-source time can be estimated from a plot like:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='1:4~60',antenna='')<br />
</source><br />
<br />
This analysis suggests that the rms noise on one baseline, one 10 second integration is about 525 mJy. In contrast the peak flux density in the strongest SiS channel is only about 200 mJy (you can check using the {{viewer}}). Because the emission is fairly compact, most baselines will see about this peak flux, this is why we chose the more compact of the two possible lines. This peak flux density tells us that we need to use a solint large enough so that the rms noise is not worse than about 1/3 of 200 mJy. Thus, a solint of 10 minutes is about the shortest we can use and be reasonably confident of the solutions. <br />
<br />
Now we run {{gaincal}} with the solint we have determined. Note that because our desired solint is more <br />
than the scan time, we need to include combine='scan'.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='IRC10216.contsub.data',caltable='pcal_ch19one_10min',<br />
spw='1:19~19',calmode='p',solint='10min',combine='scan',<br />
refant='ea02',minsnr=3.0)<br />
</source><br />
<br />
[[Image:selfcalone.png|thumb|Phase-only self-calibration solutions with 10 minute solint.]]<br />
Now let's look at the solutions:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='pcal_ch19one_10min',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-50,50])<br />
</source><br />
<br />
For some antennas you can see clear global trends away from zero: ea08, ea21,ea24 are examples, and you can also see some smaller variations with time.<br />
<br />
Now let's explore whether applying this solution actually improves matters. To do this we need to run {{applycal}} to apply the solutions to the line dataset, both spw. We need to use spwmap to tell it that the solutions derived for spw=1 should be applied to both spw=0 and spw=1. Again it's important to set calwt=F here.<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='IRC10216.contsub.data',field='',spw='0,1',<br />
gaintable=['pcal_ch19one_10min'],spwmap=[[1,1]],calwt=F)<br />
</source><br />
<br />
'''Note:''' in this example we ran the self-cal steps on the full uv continuum subtracted spectral line data set. For a more complex iterative self-calibration proceedure, you may find it easier to split off the channel/spw you want to experiment on with {{split}}, and then do all the imaging ({{clean}}) and {{gaincal}} steps with it. The {{gaincal}} tables created on the single channel can still be applied with {{applycal}} to the multi-channel/spw dataset. If you do this though, keep in mind that once split, the single-channel data will have its spw id reset to 0 (you can check with {{listobs}}), no matter what spw it came from. Thus in order to applycal with it you would need <nowiki>spwmap=[[0,0]]</nowiki>.<br />
<br />
To save time we can use the clean mask we made before and run in a non-interactive mode. You can use a mask over again as long as the number of channels in the {{clean}} call haven't changed. You can change cell or imsize and it will still do the right thing.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_HC3N.cube_r0.5.pselfcal',<br />
imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='0:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.39232GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
mask='IRC10216_HC3N.cube_r0.5.mask',<br />
interactive=F,threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_SiS.cube_r0.5.pselfcal',<br />
imagermode='csclean',calready=T,<br />
imsize=300,cell=['0.4arcsec'],spw='1:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.30963GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
mask='IRC10216_SiS.cube_r0.5.mask', <br />
interactive=F,threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
Now investigate the original and self-cal'ed images in the viewer. You will find that even this single self-cal step significantly improves the images. Try opening both versions of the SiS image cubes. <br />
Then select a bright channel from the tape deck like channel 37, then use the "wrench" and "pwrench" guis to make a plot like below setting the same image range for both cubes, and two panels in x, then to see both images of that channel side-by-side click the blink toggle (see image below for more tips on setup.)<br />
<br />
[[Image:compareselfcal.png|600px|Original and self-cal SiS images for channel 37, notice the decrease in <br />
residuals.]]<br />
<br />
Repeat for HC3N:<br />
<br />
[[Image:compareselfcal2.png|600px|Original and self-cal HC3N images for channel 13, notice the decrease in <br />
residuals.]]<br />
<br />
[[Main Page | &#8629; '''CASAguides''']]<br />
<br />
--[[User:Cbrogan|Crystal Brogan]]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Spectral_Line_Imaging_Analysis_IRC%2B10216&diff=3757EVLA Spectral Line Imaging Analysis IRC+102162010-06-04T20:33:27Z<p>Jgallimo: /* Self-Calibration */</p>
<hr />
<div><pre style="background-color: #FFFF00;"><br />
This tutorial is under construction. There are several things still to be added <br />
<br />
For the time being (until release candidate is built) you want to run this on casapy-test<br />
<br />
</pre><br />
<br />
This tutorial picks up where [[EVLA Spectral Line Calibration IRC+10216]] leaves off. <br />
<br />
== UV Continuum Subtraction and Setting Up for Self-Calibration==<br />
<br />
[[Image:irc10216_uvspec.png|thumb|UV-plot of the spectral line signal in both spw for IRC+10216.]]<br />
Now we can make a vector averaged uv-plot of the calibrated target spectral line data. It is important to note that you will only see signal in such a plot if (1) the data are well calibrated, and (2) there is significant signal near the phase center of the observations, or if the line emission (or absorption) is weak but extended. If this isn't true for your data, you won't be able to see the line signal in such a plot and will need to make an initial (dirty or lightly cleaned) line+continuum cube to determine the line-free channels. Generally, this is the recommended course for finding the line-free channels more precisely than is being done here due to time constraints, as weak line signal would not be obvious in this plot. <br />
<br />
<source lang="python"><br />
plotms(vis='IRC10216',field='',ydatacolumn='corrected',<br />
xaxis='channel',yaxis='amp',correlation='RR',<br />
avgtime='1e8',avgscan=T,spw='0~1:4~60',antenna='')<br />
</source><br />
<br />
in the Display tab, choose colorize by spw and change the Unflagged points symbol to custom and Style of 3. <br />
<br />
You should see the "horned profile" typical of a rotation shell. From this plot, you can guess that strong <br />
line emission is restricted to channels 18 to 47 (zoom in if necessary to see exactly what the channel numbers are). <br />
<br />
In the Data tab you can also click on "all baselines" to average all baselines, but this is a little harder to see.<br />
<br />
Now we want to use the line free channels to create a model of the continuum emission that can be subtracted to form a line-only dataset. We want to refrain from going to close to the edges of the band -- these channels are typically noisy, and we don't want to get too close to the line channels because we could only see strong line emission in the vector averaged uv-plot.<br />
<br />
<source lang="python"><br />
uvcontsub2(vis='IRC10216',fitspw='0~1:4~13;52~60',<br />
want_cont=T)<br />
</source><br />
<br />
The "want_cont=T" will produce two new datasets, IRC10216.contsub is the continuum subtracted line data, and IRC10216.cont is the continuum estimate (note however, that it is still a multi-channel dataset).<br />
<br />
'''If you want to try self-cal:''' Unfortunately, at the moment, uvcontsub2 doesn't leave the continuum subtracted line dataset in the state you need *if* you think you might want to self-calibrate the data later. This is because {{clean}} always looks at the "corrected" datacolumn, while {{gaincal}} (also used for self-calibration) always looks at the "data" column. You also need to know that unless the imagename supplied to clean already exists, clean always overwrites the model column with the clean model (this will be the model supplied to the self-calibration process).<br />
<pre style="background-color: #E0FFFF;"><br />
The files produced by uvcontsub2 will have the following in their data columns:<br />
Data Model Corrected<br />
IRC10216.contsub Line+Cont Cont Line<br />
IRC10216.cont Cont Cont Cont<br />
</pre><br />
<br />
Now the imaging task {{clean}} will clean both of these files fine, and correctly overwrite the model data column with the correct clean model. However, if you try to self-cal (i.e. run gaincal) on the continuum subtracted line data (.contsub), it will use the Line+Cont as its input along with the line only clean model. If the line and continuum have significantly different morphology (almost always) the self-cal process will fail. In contrast the continuum dataset (.cont) will work fine because the Data and Corrected columns agree. <br />
<br />
To fix things up, we must {{split}} the "corrected" column (which places "Corrected" in the "Data" column of the new dataset. Then you can either run clearcal to reinitialize the "model" and "corrected" columns or let clean do it for you. We put this step here explicitly for clarity about the process.<br />
<br />
<source lang="python"><br />
split(vis='IRC10216.contsub',outputvis='IRC10216.contsub.data')<br />
</source><br />
<source lang="python"><br />
clearcal(vis='IRC10216.contsub.data')<br />
</source><br />
<br />
Now IRC10216.contsub.data will have the Line in the "data" column, 1 in the "model" column for amplitudes and 0 for phase, and the Line in the "corrected" column as desired. You can always check this using {{plotms}} to <br />
look at the "data", "model", and "corrected" columns.<br />
<br />
We expect that these extra shenanigans will be unnecessary in the future.<br />
<br />
==Image the Spectral Line Data==<br />
<br />
Here we make images from the continuum-subtracted, calibrated spectral line data. Because the spectral line emission from IRC+10216 has significant extended emission, it is very important to run clean interactively, and make a clean mask. To make the cube a bit smaller and stay away from noisy edge channels we restrict the <br />
channel range using the spw parameter.<br />
[[Image:viewer_interactive.png|thumb|Channel 28 shown for the HC3N cube shown in the interactive viewer with the white contour showing the mask contour drawn with the polygon tool.]]<br />
<br />
<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_HC3N.cube_r0.5',<br />
imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='0:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.39232GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
interactive=T,<br />
threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
It will take a little while to grid the data, but the {{viewer}} will open when it's ready to start an interactive clean. Use the "tape deck" at the bottom of the Viewer display GUI to step through to the channel with the most extended (in angular size) emission, select "all channels" for the clean mask, select the polygon tool (second in from the right) and make a single mask that applies to all channels (see example in thumbnail). Once you make the polygon region, you need to double click inside it to save the mask region -- if you see the polygon turn white you will know you succeeded. Note, that if you had the time and patience you could make a clean mask for each channel, and this would create a slightly better result. <br />
<br />
After making the mask you should check that the emission in all the other channels fits within the mask you made using the "tape deck" to move back and forth. If you need to include more area in the mask, you can chose the "erase" toggle at the top, and then encircle your existing mask with a polygon and double click inside. Then go back to "add" toggle at top and make a new mask. Alternatively, you can erase a part of the mask, or you can add to the existing mask by drawing new polygons. Feel free to experiment with this a bit.<br />
<br />
'''note''': If you start an interactive clean, and then do not make a mask, clean will stop when you tell it to go on because it has nothing to clean. There is no default mask. <br />
<br />
To continue with {{clean}} use the "Next action" buttons in the green area on the Viewer Display GUI: The red X will stop {{clean}} where you are, the blue arrow will stop the interactive part of {{clean}}, but continue to clean non-interactively until reaching the stopping niter or threshold (whichever comes first), and the green arrow will clean until it reaches the "iterations" parameter on the left side of the green area. When <br />
the interactive viewer comes back use the tape deck to recheck that your mask encompasses what you think is real emission. The middle mouse button by default controls the image stretch.<br />
<br />
Note that for this example, threshold has been set to threshold='3mJy' to protect you from cleaning too deeply. With a careful clean mask you can clean to close to the thermal noise limit (note here I mean the actual observed rms noise limit and not the theoretical one you calculated for the proposal, as flagging, weather etc can affect what you actually get). It is ALWAYS best to clean each channel in a cube to a specific threshold than to stop by simply using the niter parameter, which can leave each channel cleaned to different levels. There are many ways to determine a suitable threshold. One way is to make a dirty image (niter=0), open the cube using the viewer, go to a line free channel, select the box region tool, make a box near the field center about the size of your source, and double click inside. The rms noise of that channel will appear in a pop-up window (rms noise for whole cube will go to terminal). Try a few different boxes, average the results and this is a good estimate of the rms per channel assuming your data are not dynamic range limited (i.e. noise can be higher in channels with strong signal). This is the absolute minimum for threshold. With no mask you probably shouldn't clean deeper than 3x this rms. <br />
<br />
[[Image:SiS_interactive.png|thumb|Channel 16 shown for the SiS cube in the interactive viewer with the white contour showing the mask contour drawn with the polygon tool.]]<br />
<br />
Keep cleaning, by using the green Next Action arrow until the residual displayed in the viewer looks "noise like". To speed things up, you might change the iteration parameter in the viewer to something like 300. This parameter can also be set in the task command. You will notice that in this particular case, there are residuals that cannot be cleaned -- these are due to the extended resolved out structure on size scales larger than the array is sensitive to (the "Largest Angular Scale" or LAS that the array is sensitive to can be calculated from the shortest baseline length), and potential residual phase and amplitude calibration errors. We will explore this in a few sections with self-calibration. <br />
<br />
Repeat the process for the SiS line using the call below, note that the emission for this line is less extended than the HC3N -- this has to do with the different excitation requirements of the two different lines. The SiS is excited closer to the central star than the HC3N.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_SiS.cube_r0.5',<br />
imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='1:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.30963GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
interactive=T,<br />
threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
You can look at both cubes using the viewer, and the tape deck to play the cube as "movie".<br />
<source lang="python"><br />
# In CASA<br />
viewer<br />
</source><br />
<br />
==Image the Continuum data==<br />
<br />
Below the use of mode='mfs' will make a single multi-frequency synthesis image out of the specified spw/channels. Again you should make an interactive clean mask. Since no threshold is set, you will need to stop cleaning when the residual looks noise like using the red x "Next Action" button (it will be done when the viewer comes back the second time). The continuum for IRC10216 is very weak but interesting -- it is essentially tracing the photosphere of the AGB star. <br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.cont',imagename='IRC10216.36GHzcont',<br />
mode='mfs',imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='0~1:5~59',<br />
weighting='briggs',robust=0.5,<br />
interactive=T)<br />
</source><br />
<br />
Now look at the result in the viewer if you like<br />
<br />
<source lang="python"><br />
# In CASA<br />
Viewer<br />
</source><br />
<br />
==Image Analysis and Viewing==<br />
<br />
Next make integrated intensity maps (moment 0) and integrated velocity maps (moment 1). To do this, we'll want to know what channels the line emission starts and ends on, and also the rms noise in a single channel. So first lets open the viewer:<br />
<br />
<source lang="python"><br />
# In CASA <br />
viewer<br />
</source><br />
<br />
Then use the Viewer tape deck to see which channels have significant line emission. For HC3N, the line channel range in the cube is 11 to 40, and it is the same for SiS. <br />
<br />
Then use the tape deck to go to a line free channel, select the box region tool and make a box. When you double click in the box, the image statistics for the whole cube will print to the terminal and for the channel you are on, it will print to a pop up window. Move the box around a bit to see what the variation in rms noise is. You should get something like 2 mJy. Note that the rms is much worse in channels with strong emission because of the low dynamic range of these data. If you want the box tool to go away (i.e. if you want to make a new one), hit the escape key. <br />
<br />
Now lets make the moment 0 and moment 1 maps. For moment zero, it's best to limit the calculation to image channels with significant signal in them, but not to apply a flux cutoff, as this will bias the derived integrated intensities upward.<br />
<br />
[[Image:irc10216.jpg|thumb|HC3N moment 0 map with white continuum contours superposed.]]<br />
[[Image:irc10216_sismom0.jpg|thumb|SiS moment 0 map with white continuum contours superposed.]]<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_HC3N.cube_r0.5.image',moments=[0],<br />
axis='spectral',<br />
chans='11~40',<br />
outfile='IRC10216_HC3N.cube_r0.5.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_SiS.cube_r0.5.image',moments=[0],<br />
axis='spectral',<br />
chans='11~40',<br />
outfile='IRC10216_SiS.cube_r0.5.image.mom0')<br />
</source><br />
<br />
For moment 1, it is essential to apply a conservative flux cutoff to limit the calculation to high signal-to-noise areas. Here we use about 5sigma.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_HC3N.cube_r0.5.image',moments=[1],<br />
axis='spectral',<br />
chans='11~40',excludepix=[-100,0.01],<br />
outfile='IRC10216_HC3N.cube_r0.5.image.mom1')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_SiS.cube_r0.5.image',moments=[1],<br />
axis='spectral',<br />
chans='11~40',excludepix=[-100,0.01],<br />
outfile='IRC10216_SiS.cube_r0.5.image.mom1')<br />
</source><br />
<br />
Now use the viewer to further explore the images you've made.<br />
<br />
== Self-Calibration ==<br />
<br />
The many different aspects of self-calibration could fill several casaguides. Here we describe a simple process for this particular relatively low S/N data (low S/N per channel at least).<br />
<br />
While running {{clean}} above, the model column for each channel will have been filled with the clean model (if you made a Fourier transform of this model, you would see an image of the clean components). <br />
<br />
We chose to do the self cal on the spw=1 SiS line data because it has the strongest emission in a single channel and is a bit more compact than the HC3N data. We will run {{gaincal}} specifying the channel in the uv-data that has the brightest peak in the image (use the {{viewer}} to figure out which channel this is for spw=1), note down what the peak flux is. Since we started the image with a channel range we need to account for the fact that the image channel numbers do not map exactly to the uv-data channel numbers (they are off by 5 so that channel 13 in the image is roughly channel 19 in the uv-data). <br />
<br />
The next thing we need to understand is the S/N of the data. In particular, to self-cal, you need enough signal on a single baseline over the course of your chosen solint to get a S/N of about 3. Above we calculated an average rms noise of about 2 mJy/beam/channel for the whole timerange (about 95 minutes on source time) and all antennas (16). We can use our knowledge of the radiometer equation (see [http://evlaguides.nrao.edu/index.php?title=Category:Status#Sensitivity EVLA Sensitivity]) where rms scales as 1/sqrt(time * #baselines), and the number of baselines= N(N-1)/2 and N=# of antennas. So the rms noise on one baseline, one 10 second integration is given by:<br />
<br />
<math> {\rm RMS(baseline)} = {\rm 2\ mJy\ beam^{-1}\ channel^{-1}} \sqrt{95\times \frac{60}{10}\times\frac{16\times 15}{2\times 1}}</math><br />
<br />
[[Image:timeonsource.png|thumb|Plot to estimate the time on source.]]<br />
<br />
The 95 minutes of on-source time can be estimated from a plot like:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='1:4~60',antenna='')<br />
</source><br />
<br />
This analysis suggests that the rms noise on one baseline, one 10 second integration is about 525 mJy. In contrast the peak flux density in the strongest SiS channel is only about 200 mJy (you can check using the {{viewer}}). Because the emission is fairly compact, most baselines will see about this peak flux, this is why we chose the more compact of the two possible lines. This peak flux density tells us that we need to use a solint large enough so that the rms noise is not worse than about 1/3 of 200 mJy. Thus, a solint of 10 minutes is about the shortest we can use and be reasonably confident of the solutions. <br />
<br />
Now we run {{gaincal}} with the solint we have determined. Note that because our desired solint is more <br />
than the scan time, we need to include combine='scan'.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='IRC10216.contsub.data',caltable='pcal_ch19one_10min',<br />
spw='1:19~19',calmode='p',solint='10min',combine='scan',<br />
refant='ea02',minsnr=3.0)<br />
</source><br />
<br />
[[Image:selfcalone.png|thumb|Phase-only self-calibration solutions with 10 minute solint.]]<br />
Now let's look at the solutions:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='pcal_ch19one_10min',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-50,50])<br />
</source><br />
<br />
For some antennas you can see clear global trends away from zero: ea08, ea21,ea24 are examples, and you can also see some smaller variations with time.<br />
<br />
Now let's explore whether applying this solution actually improves matters. To do this we need to run {{applycal}} to apply the solutions to the line dataset, both spw. We need to use spwmap to tell it that the solutions derived for spw=1 should be applied to both spw=0 and spw=1. Again it's important to set calwt=F here.<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='IRC10216.contsub.data',field='',spw='0,1',<br />
gaintable=['pcal_ch19one_10min'],spwmap=[[1,1]],calwt=F)<br />
</source><br />
<br />
'''Note:''' in this example we ran the self-cal steps on the full uv continuum subtracted spectral line data set. For a more complex iterative self-calibration proceedure, you may find it easier to split off the channel/spw you want to experiment on with {{split}}, and then do all the imaging ({{clean}}) and {{gaincal}} steps with it. The {{gaincal}} tables created on the single channel can still be applied with {{applycal}} to the multi-channel/spw dataset. If you do this though, keep in mind that once split, the single-channel data will have its spw id reset to 0 (you can check with {{listobs}}), no matter what spw it came from. Thus in order to applycal with it you would need <nowiki>spwmap=[[0,0]]</nowiki>.<br />
<br />
To save time we can use the clean mask we made before and run in a non-interactive mode. You can use a mask over again as long as the number of channels in the {{clean}} call haven't changed. You can change cell or imsize and it will still do the right thing.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_HC3N.cube_r0.5.pselfcal',<br />
imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='0:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.39232GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
mask='IRC10216_HC3N.cube_r0.5.mask',<br />
interactive=F,threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_SiS.cube_r0.5.pselfcal',<br />
imagermode='csclean',calready=T,<br />
imsize=300,cell=['0.4arcsec'],spw='1:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.30963GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
mask='IRC10216_SiS.cube_r0.5.mask', <br />
interactive=F,threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
Now investigate the original and self-cal'ed images in the viewer. You will find that even this single self-cal step significantly improves the images. Try opening both versions of the SiS image cubes. <br />
Then select a bright channel from the tape deck like channel 37, then use the "wrench" and "pwrench" guis to make a plot like below setting the same image range for both cubes, and two panels in x, then to see both images of that channel side-by-side click the blink toggle (see image below for more tips on setup.)<br />
<br />
[[Image:compareselfcal.png|600px|Original and self-cal SiS images for channel 37, notice the decrease in <br />
residuals.]]<br />
<br />
Repeat for HC3N:<br />
<br />
[[Image:compareselfcal2.png|600px|Original and self-cal HC3N images for channel 13, notice the decrease in <br />
residuals.]]<br />
<br />
[[Main Page | &#8629; '''CASAguides''']]<br />
<br />
--[[User:Cbrogan|Crystal Brogan]]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=M51_at_z_%3D_0.1_and_z_%3D_0.3_(CASA_3.1)&diff=3703M51 at z = 0.1 and z = 0.3 (CASA 3.1)2010-06-03T20:26:10Z<p>Jgallimo: /* Angular Size Scaling */</p>
<hr />
<div>[[Category: Simulations]] [[Category:ALMA]]<br />
<br />
=== Overview ===<br />
<br />
[[File:M51sim-5and6.png|thumb|CO 1-0 Moment maps of the original BIMA SONG measurements of M51. ''Left'': Moment 0 (integrated intensity). ''Right'': Moment 1 (velocity field).]]<br />
<br />
This tutorial presents a simulation of ALMA observations of the well-known galaxy M51 in the CO 1-0 transition. This galaxy is located relatively nearby (luminosity distance = 9 Mpc), but, in this simulation, we will model how it would appear at redshift z = 0.1 (luminosity distance = 460 Mpc). <br />
<br />
The goal of this tutorial is to provide a ''complete'' run-through of a relatively simple simulation. Included in this simulation are the effects of (''u'', ''v'') sampling of a 50-antenna ALMA, the primary beam of the ALMA, and thermal noise. Neither calibration overheads nor errors are included, and so this simulation should be viewed as optimistic.<br />
<br />
For this tutorial, we'll use the [http://nedwww.ipac.caltech.edu/level5/March02/SONG/SONG.html BIMA SONG] ([http://adsabs.harvard.edu//abs/2003ApJS..145..259H Helfer et al. 2003]) observations of M51 as the basis for the model. Grab the file [http://nedwww.ipac.caltech.edu/level5/March02/SONG/NGC5194.bima12m.cm.fits.gz NGC5194.bima12m.cm.fits.gz] and uncompress it in a working directory.<br />
<br />
<source lang="bash"><br />
# in bash (or other unix shell)<br />
gunzip NGC5194.bima.12m.cm.fits.gz<br />
</source><br />
<br />
Load these data into CASA. For convenience, store the name of the resulting measurement set into the python global <tt>cubeName</tt>. <br />
<br />
<source lang="python"><br />
cubeName = 'm51-song'<br />
importfits(fitsimage='NGC5194.bima12m.cm.fits', imagename=cubeName)<br />
<br />
# initialize simdata2<br />
default("simdata2")<br />
skymodel=cubeName<br />
modifymodel=True<br />
</source><br />
<br />
=== Noise in the Input Model ===<br />
<br />
The input model is actually an observation and, as such, certainly contains noise. We're OK as long as the noise in the model falls below the expected thermal noise of the ALMA observation. Here's a quick, back-of-the-envelope calculation.<br />
<br />
The noise on the BIMA SONG channels measures roughly 0.1 Jy/beam, which scales to 0.04 mJy/beam at z = 0.1 (to within factors of powers of 1+z for cosmology and root-small-integer for the to-be-degraded beam; see below). For comparison, the expected thermal noise of the ALMA observation is 0.1 mJy / beam (using the [http://www.eso.org/sci/facilities/alma/observing/tools/etc/index.html ALMA Sensitivity Calculator], assuming 8 hrs integration, and, to match roughly the BIMA SONG observation, a 4 MHz channel width), a factor of 2.5 greater than the anticipated contribution of noise from the model. Added in quadrature, the noise components total 0.108 mJy, and so we can expect that the input model noise degrades the simulation noise by about 8%.<br />
<br />
=== Cosmology Calculations ===<br />
<br />
Next we'll set up some python globals to handle the scaling of the model coordinates and flux densities appropriate for new redshift. We'll primarily need the angular size and luminosity distances for a given cosmology. To keep things simple, we'll use [http://www.astro.ucla.edu/~wright/CosmoCalc.html Ned Wright's CosmoCalc] ([http://adsabs.harvard.edu/abs/2006PASP..118.1711W 2006]) with the default cosmology; redshifts were collected from [http://nedwww.ipac.caltech.edu/cgi-bin/nph-objsearch?objname=NGC5194&extend=no&hconst=73&omegam=0.27&omegav=0.73&corr_z=1&out_csys=Equatorial&out_equinox=J2000.0&obj_sort=RA+or+Longitude&of=pre_text&zv_breaker=30000.0&list_limit=5&img_stamp=YES NED]. <br />
<br />
<source lang="python"><br />
#z's <br />
# Distinguish between z_lsrk, which sets the observed frequency for scaling, from z_cmb, <br />
# which is needed to get cosmological distances.<br />
z_old_cmb = 0.002122 # CMB-referenced z for cosmological distances from NED<br />
z_old_lsrk = 0.001544 # from NED<br />
z_new = 0.1<br />
<br />
# angular size distances from CosmoCalc<br />
da_old = 9.0<br />
da_new = 375.9<br />
<br />
# luminosity distances from CosmoCalc<br />
dl_old = 8.937<br />
dl_new = 454.8<br />
</source><br />
<br />
The convention is ''old'' refers to M51 as observed at its proper redshift, and ''new'' refers to the new, higher redshift for our model.<br />
<br />
=== Preparing the Model ===<br />
<br />
The next step is to scale the M51 data cube into a model cube appropriate for [[simdata2]]. First, we'll set up some globals to establish some file naming conventions.<br />
<br />
<source lang="python"><br />
suffix = "-p1" # z = 0.1, or point-1; useful to distinguish from repeated simulations at different z's<br />
project = "M51-ATZ" + suffix # project ID to assign output filenames (simdata2 parameter)<br />
</source><br />
<br />
<br />
==== Flux Density Scaling ====<br />
<br />
Our goal in this step is to set the '''inbright''' parameter of [[simdata2]], which will scale the data cube appropriately for its new luminosity distance.<br />
<br />
[[simdata2|Simdata2]] wants models in units of Jy / pixel, but the BIMA SONG cube is in units of Jy / beam. That's an easy conversion.<br />
<br />
<source lang="python"><br />
# BIMA SONG beam <br />
bmaj = imhead(imagename=cubeName,mode='get',hdkey='beammajor')<br />
bmin = imhead(imagename=cubeName,mode='get',hdkey='beamminor')<br />
<br />
# use qa tool to convert beam in radians to (1 arcsec) pixels:<br />
bmaj = qa.convert(bmaj,'arcsec')['value']<br />
bmin = qa.convert(bmin,'arcsec')['value']<br />
<br />
toJyPerPix = 1.0 / (1.1331 * bmaj * bmin) # gaussian beam conversion = beams / pixel<br />
</source><br />
<br />
Next, scale the flux for the new luminosity distance. Make the approximation that each pixel is a point source, and use the inverse square law to scale. [[simdata2|Simdata2]] can scale the peak surface brightness using the parameter '''inbright'''.<br />
<br />
<source lang="python"><br />
# correct flux density for luminosity distance<br />
fluxScale = (dl_old/dl_new)**2 * (1.0 + z_new) / (1.0 + z_old_cmb)<br />
# current peak flux:<br />
peak = imstat(cubeName)['max'][0] * toJyPerPix # need to convert to Jy / pixel<br />
# desired peak flux in Jy / pixel:<br />
inbright = "%fJy/pixel" % (peak*fluxScale) # use python formatting convention<br />
# inbright is a simdata2 parameter<br />
</source><br />
<br />
Notice that there is an additional (1+z) correction because we are scaling flux densities rather than bolometric fluxes.<br />
<br />
==== Angular Size Scaling ====<br />
<br />
The sky coordinates axes of the model need to be adjusted (1) to place M51 in the southern hemisphere and (2) to correct for the new angular size distance. These tasks can be accomplished by the [[simdata2]] parameters '''indirection''' (change the location of M51 on the sky) and '''incell''' (change the angular scale of an input pixel).<br />
a<br />
To perform task (1), we'll just flip the sign of the declination using [[imhead]]. Notice the use of the [http://casa.nrao.edu/docs/casaref/quanta-Module.html#x409-4100001.4 qa] tool to convert radians to sexagesimal.<br />
<br />
<source lang="python"><br />
# Move to southern hemisphere.<br />
# Use qa.formxxx tool to convert rad to sexagesimal.<br />
# For clarity, build up "indirection" string one term at a time.<br />
# Epoch<br />
indirection = "J2000 " # parameter for simdata<br />
# RA<br />
indirection += qa.formxxx(imhead(imagename=cubeName,mode='get',hdkey='crval1')['value']+'rad',format='hms') + " " <br />
# Dec * -1<br />
indirection += qa.formxxx('%frad' % (-1*float(imhead(imagename=cubeName,mode='get',hdkey='crval2')['value'])),format='dms')<br />
</source><br />
<br />
<br />
<br />
Next, adjust the pixel scale for the new angular size distance. To perform this adjustment, we'll use [[imhead]] with <tt>mode = "get"</tt> to read in the original pixel scale, and <tt>mode="put"</tt> to store the new pixel scale in the model header.<br />
<br />
<source lang="python"><br />
# scale pixel size: imhead returns things in rad, so convert to arcsec<br />
oldCell = float(imhead(imagename=cubeName,mode='get',hdkey='cdelt2')['value']) * 206265 <br />
# scale for new angular size distance<br />
newCell = oldCell * da_old / da_new <br />
# Format the new pixel size for input to simdata<br />
incell = "%farcsec" % (newCell) # parameter for simdata2<br />
</source><br />
<br />
==== Adjusting the Frequency Axis ====<br />
<br />
Changing the frequency axis of the model header is just a straightforward (1+''z'') correction. [[simdata2|Simdata2]] adjusts the channelwidth using the '''inwidth''' parameter and the observing frequency using '''incenter'''. <br />
<br />
Notice that the absolute value of the BIMA SONG channel width is used. The noise calculation in [[simdata2|Simdata2]] needs positive channel widths, but the input cube is ordered in increasing velocity rather than increasing frequency. We could transpose the cube; on the other hand, the only penalty of changing the sign is that the sense of rotation will be flipped. Since this simulation is a simple detection experiment, the rotation sense is irrelevant, and so we'll take the easy way out.<br />
<br />
<source lang="python"><br />
# move freq to z_new<br />
oldFreq = float(imhead(imagename=cubeName,mode='get',hdkey='crval3')['value']) # Hz<br />
newFreq = oldFreq * (1.0 + z_old_lsrk) / (1.0 + z_new)<br />
nchan = imstat("NGC5194.bima12m.cm.fits")['trc'][2]<br />
<br />
# Adjust frequency channelwidth for new z<br />
oldDnu = float(imhead(imagename=cubeName,mode='get',hdkey='cdelt3')['value']) # Hz<br />
newDnu = abs((1.0+z_old_lsrk) /(1.0+z_new)*oldDnu) # need positive channel widths to ensure noise calc goes well<br />
inwidth = "%fHz" % newDnu # parameter for simdata<br />
<br />
# Specify the observing frequency at the center of the observing band:<br />
incenter = "%fHz" % (newFreq + 0.5*nchan*newDnu)<br />
</source><br />
<br />
=== Simdata2 ===<br />
<br />
The CASA task [[simdata2]] will monolithically simulate an ALMA observation, produce measurement sets with and without thermal noise, and finally produce a CLEANed image cube based on the simulated observation. Details can be found in the [[Simulating Observations in CASA]] tutorial.<br />
<br />
The original BIMA SONG image is about 480 arcseconds across; scale this image size to the new redshift.<br />
<br />
<source lang="python"><br />
# estimate final image size<br />
imSize = 480.0 * (da_old / da_new) # in arcseconds<br />
</source><br />
<br />
For relatively high redshifts, there should be no need to mosaic the observations. We'll nevertheless allow for mosaicking in case we want to repeat the simulation for lower redshift. [[simdata2|Simdata2]] needs the spacing between pointings in the mosaic; we'll require pointings spaced by half of the primary beam. <br />
<br />
<source lang="python"><br />
# mosaicking info<br />
primaryBeam = 17.0 * (300e9 / newFreq) # in arcseconds; ALMA primary beam = 17 arcsec at 300 GHz<br />
pointingspacing = "%farcsec" % (primaryBeam / 2.0) <br />
mapsize = "%farcsec" % imSize # how big to make the mosaic<br />
</source><br />
<br />
We also need to estimate the desired synthesized beam size. We don't want the new beam to be so large so that we cannot resolve a rotation curve, but we also don't want it to be so small that we effectively resolve out the BIMA SONG data. The BIMA SONG beam was 5 arcsec, and so as a reasonable guess we'll adopt the equivalent of a 15" beam at its true distance(3 times coarser than the BIMA SONG beam) and then scale appropriately to z = 0.1.<br />
<br />
<source lang="python"><br />
# Estimate desired beam size. BIMA SONG has 5": use 15" projected to new redshift<br />
beamNew = 15.0 * (da_old / da_new)<br />
</source><br />
<br />
We want pixels that sample the beam at least 3 times for stable deconvolution; we'll use 4 times sampling, rounded off to the nearest milliarcsec.<br />
<br />
<source lang="python"><br />
pixelSize = round(beamNew * 1000.0 / 4.0) / 1000.0<br />
</source><br />
<br />
Now, to guard against undersampling the beam as a result of rounding error, reset the desired beam to 4 times the pixel size.<br />
<br />
<source lang="python"><br />
beamNew = 4.0 * pixelSize<br />
</source><br />
<br />
Now we know both the image size and pixel size in arcseconds, but [[simdata2]] wants the ratio: the number of pixels along the RA or Dec axis. To keep the image from becoming too small, set the minimum image size to be 256 pixels.<br />
<br />
<source lang="python"><br />
imSizePix = int(round(imSize / pixelSize))<br />
if imSizePix < 256: imSizePix = 256<br />
</source><br />
<br />
Let [[simdata2]] decide on an appropriate ALMA configuration based on the desired beam size. Set the parameter '''antennalist''' as follows (but see [[#Other Antenna Configurations|Other Antenna Configurations]] below).<br />
<br />
<source lang="python"><br />
predict=True<br />
antennalist = "alma;%farcsec" % beamNew<br />
</source><br />
<br />
Now we have enough information to run [[simdata2]], and hopefully some of the python global variables that were defined above will start to make sense. The following CASA and python commands set up the remaining parameters for the [[simdata2]] task. <br />
<br />
<source lang="python"><br />
modelimage = cubeName<br />
integration = '10s' # watch out for memory limits vs. ability to complete mosaic here<br />
# 10s is usually safe for large mosaics, but will require more memory<br />
totaltime = '28800s' # 8 hr integration<br />
<br />
# make simulated images/cubes<br />
image=True<br />
thermalnoise="tsys-atm" # add thermal noise, produce noisy.ms measurement set<br />
vis = '$project.noisy.ms' # clean the data with *thermal noise added* <br />
cell = "%farcsec" % pixelSize<br />
imsize = [imSizePix,imSizePix]<br />
threshold = "1.0mJy"<br />
weighting = "natural"<br />
stokes = 'I'<br />
<br />
verbose = True<br />
graphics="both"<br />
overwrite = True<br />
<br />
inp("simdata2")<br />
simdata2()<br />
</source><br />
<br />
<br />
==== Other Antenna Configurations ====<br />
<br />
<br />
[[file:Beamsummary.png|thumb|ALMA synthetic beam size as a function of array configuration number]]<br />
Finally, we need to know which ALMA configuration number based on the desired angular resolution. [[simdata2|Simdata2]] makes this easy by allowing users to specify the desired angular resolution in the parameter '''antennalist'''.<br />
<br />
This tutorial is somewhat automated to produce a decent cube of M51 as viewed at z = 0.1. The selection of the {{ALMA}} antenna configuration is automated, but, for other simulations (or this one, for that matter), it will be worth playing with the configurations, or perhaps evaluating the possibility of detections in CSV or early science.<br />
<br />
Notice from the [[simdata2]] inputs that CASA comes with stock antenna configurations in the directory $CASAPATH/data/alma/simmos/ (the python task '''os.getenv''' is used to look up CASAPATH automatically). For CASA 3.0.1, here is a list of included antenna configurations.<br />
<br />
{| border = 1<br />
|+ '''ALMA Configuration Files'''<br />
|- <br />
| alma.csv.late.cfg<br />
|- <br />
| alma.csv.mid.cfg<br />
|- <br />
| alma.early.large.cfg<br />
|- <br />
| alma.early.med.cfg<br />
|- <br />
| alma.out01.cfg<br />
|- <br />
| alma.out02.cfg<br />
|- <br />
| alma.out03.cfg<br />
|- <br />
| ...<br />
|- <br />
| alma.out27.cfg<br />
|- <br />
| alma.out28.cfg<br />
|}<br />
<br />
There are also configuration data for the [http://www.narrabri.atnf.csiro.au/ ACA], {{EVLA}}, and [http://www.cfa.harvard.edu/sma/ SMA].<br />
<br />
=== Take a Break ===<br />
<br />
If you have got this far, you've earned it. [[simdata2|Simdata2]] will be running for a while, and coffee sure sounds good right now.<br />
<br />
=== Results ===<br />
<br />
[[File:M51sim-09.png|thumb|Channel 16 of the M51 at z=0.1 simulation. The rms noise is about 0.25 mJy/beam, and the peak flux density on this channel is about 2 mJy/beam.]]<br />
<br />
Here is an inventory of some of the [[simdata2]] products. <br />
<br />
{| border="1"<br />
! Filename<br />
! Description<br />
|-<br />
| M51-ATZ-p1.ms<br />
| Model measurement set ''sans'' noise<br />
|- <br />
| M51-ATZ-p1.noisy.ms<br />
| Model measurement set with thermal noise<br />
|-<br />
| M51-ATZ-p1.clean.image<br />
| CLEAN-deconvolved cube of M51-ATZ-p1.noisy.ms<br />
|}<br />
<br />
And there are plenty of other auxiliary files.<br />
<br />
The rest frequency will have been lost in the simulation, and it's worth restoring to the header.<br />
<br />
<source lang="python"><br />
imhead(imagename="M51-ATZ-p1.image", mode="put", hdkey="restfreq", hdvalue="115.27120180GHz")<br />
</source><br />
<br />
The simulated data cube can be analyzed just like any other CASA image -- examples are given in the [[Imaging a Mosaicked Spectral Line Dataset|CARMA tutorial]] and the [[NGC 5921: red-shifted HI emission#Cube Moments|VLA 21cm tutorial]].<br />
<br />
==== Moment Maps ====<br />
[[File:M51simnew.png|thumb|Moment maps of the M51 CO 1-0 at z=0.1 simulation. ''Left'': Moment 0 (integrated intensity) map. ''Right'': Moment 1 (velocity field) map. Note that the rotation sense has been flipped, exactly [[#Adjusting the Frequency Axis | as expected]].]]<br />
<br />
Use [[immoments]] to calculate the integrated intensity and velocity field maps from the simulated cube. The '''excludepix''' option applies a 3&sigma; cut.<br />
<br />
<source lang="python"><br />
immoments(imagename='M51-ATZ-p1.image',moments=[0,1],axis='spectral',<br />
excludepix=[-100,0.0006],outfile='M51-ATZ-p1.moments')<br />
</source><br />
<br />
The results are shown at right.<br />
<br />
=== Pushing M51 out to z = 0.3 ===<br />
<br />
We'll leave it as an exercise how to tune this simulation to push M51 all the way out to z = 0.3 (luminosity distance = 1540 Mpc). [[simdata2|Simdata2]] produces a reasonable detection in 8 hrs integration, but you'll need to consider more carefully the antenna configuration needed to produce the requisite sensitivity. To conclude, here are the moment maps for the z = 0.3 simulation.<br />
<br />
[[File:M51sim78.png|400px|Simulation of M51 CO 1-0 at z = 0.3. ''Left'': integrated intensity map. ''Right'': (marginally resolved) velocity field.]]<br />
<br />
{{Checked 3.0.2}}<br />
<br />
--[[User:Jgallimo|Jack Gallimore]] 15:55, 30 April 2010 (UTC)</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=M51_at_z_%3D_0.1_and_z_%3D_0.3_(CASA_3.1)&diff=3702M51 at z = 0.1 and z = 0.3 (CASA 3.1)2010-06-03T20:25:44Z<p>Jgallimo: /* Flux Density Scaling */</p>
<hr />
<div>[[Category: Simulations]] [[Category:ALMA]]<br />
<br />
=== Overview ===<br />
<br />
[[File:M51sim-5and6.png|thumb|CO 1-0 Moment maps of the original BIMA SONG measurements of M51. ''Left'': Moment 0 (integrated intensity). ''Right'': Moment 1 (velocity field).]]<br />
<br />
This tutorial presents a simulation of ALMA observations of the well-known galaxy M51 in the CO 1-0 transition. This galaxy is located relatively nearby (luminosity distance = 9 Mpc), but, in this simulation, we will model how it would appear at redshift z = 0.1 (luminosity distance = 460 Mpc). <br />
<br />
The goal of this tutorial is to provide a ''complete'' run-through of a relatively simple simulation. Included in this simulation are the effects of (''u'', ''v'') sampling of a 50-antenna ALMA, the primary beam of the ALMA, and thermal noise. Neither calibration overheads nor errors are included, and so this simulation should be viewed as optimistic.<br />
<br />
For this tutorial, we'll use the [http://nedwww.ipac.caltech.edu/level5/March02/SONG/SONG.html BIMA SONG] ([http://adsabs.harvard.edu//abs/2003ApJS..145..259H Helfer et al. 2003]) observations of M51 as the basis for the model. Grab the file [http://nedwww.ipac.caltech.edu/level5/March02/SONG/NGC5194.bima12m.cm.fits.gz NGC5194.bima12m.cm.fits.gz] and uncompress it in a working directory.<br />
<br />
<source lang="bash"><br />
# in bash (or other unix shell)<br />
gunzip NGC5194.bima.12m.cm.fits.gz<br />
</source><br />
<br />
Load these data into CASA. For convenience, store the name of the resulting measurement set into the python global <tt>cubeName</tt>. <br />
<br />
<source lang="python"><br />
cubeName = 'm51-song'<br />
importfits(fitsimage='NGC5194.bima12m.cm.fits', imagename=cubeName)<br />
<br />
# initialize simdata2<br />
default("simdata2")<br />
skymodel=cubeName<br />
modifymodel=True<br />
</source><br />
<br />
=== Noise in the Input Model ===<br />
<br />
The input model is actually an observation and, as such, certainly contains noise. We're OK as long as the noise in the model falls below the expected thermal noise of the ALMA observation. Here's a quick, back-of-the-envelope calculation.<br />
<br />
The noise on the BIMA SONG channels measures roughly 0.1 Jy/beam, which scales to 0.04 mJy/beam at z = 0.1 (to within factors of powers of 1+z for cosmology and root-small-integer for the to-be-degraded beam; see below). For comparison, the expected thermal noise of the ALMA observation is 0.1 mJy / beam (using the [http://www.eso.org/sci/facilities/alma/observing/tools/etc/index.html ALMA Sensitivity Calculator], assuming 8 hrs integration, and, to match roughly the BIMA SONG observation, a 4 MHz channel width), a factor of 2.5 greater than the anticipated contribution of noise from the model. Added in quadrature, the noise components total 0.108 mJy, and so we can expect that the input model noise degrades the simulation noise by about 8%.<br />
<br />
=== Cosmology Calculations ===<br />
<br />
Next we'll set up some python globals to handle the scaling of the model coordinates and flux densities appropriate for new redshift. We'll primarily need the angular size and luminosity distances for a given cosmology. To keep things simple, we'll use [http://www.astro.ucla.edu/~wright/CosmoCalc.html Ned Wright's CosmoCalc] ([http://adsabs.harvard.edu/abs/2006PASP..118.1711W 2006]) with the default cosmology; redshifts were collected from [http://nedwww.ipac.caltech.edu/cgi-bin/nph-objsearch?objname=NGC5194&extend=no&hconst=73&omegam=0.27&omegav=0.73&corr_z=1&out_csys=Equatorial&out_equinox=J2000.0&obj_sort=RA+or+Longitude&of=pre_text&zv_breaker=30000.0&list_limit=5&img_stamp=YES NED]. <br />
<br />
<source lang="python"><br />
#z's <br />
# Distinguish between z_lsrk, which sets the observed frequency for scaling, from z_cmb, <br />
# which is needed to get cosmological distances.<br />
z_old_cmb = 0.002122 # CMB-referenced z for cosmological distances from NED<br />
z_old_lsrk = 0.001544 # from NED<br />
z_new = 0.1<br />
<br />
# angular size distances from CosmoCalc<br />
da_old = 9.0<br />
da_new = 375.9<br />
<br />
# luminosity distances from CosmoCalc<br />
dl_old = 8.937<br />
dl_new = 454.8<br />
</source><br />
<br />
The convention is ''old'' refers to M51 as observed at its proper redshift, and ''new'' refers to the new, higher redshift for our model.<br />
<br />
=== Preparing the Model ===<br />
<br />
The next step is to scale the M51 data cube into a model cube appropriate for [[simdata2]]. First, we'll set up some globals to establish some file naming conventions.<br />
<br />
<source lang="python"><br />
suffix = "-p1" # z = 0.1, or point-1; useful to distinguish from repeated simulations at different z's<br />
project = "M51-ATZ" + suffix # project ID to assign output filenames (simdata2 parameter)<br />
</source><br />
<br />
<br />
==== Flux Density Scaling ====<br />
<br />
Our goal in this step is to set the '''inbright''' parameter of [[simdata2]], which will scale the data cube appropriately for its new luminosity distance.<br />
<br />
[[simdata2|Simdata2]] wants models in units of Jy / pixel, but the BIMA SONG cube is in units of Jy / beam. That's an easy conversion.<br />
<br />
<source lang="python"><br />
# BIMA SONG beam <br />
bmaj = imhead(imagename=cubeName,mode='get',hdkey='beammajor')<br />
bmin = imhead(imagename=cubeName,mode='get',hdkey='beamminor')<br />
<br />
# use qa tool to convert beam in radians to (1 arcsec) pixels:<br />
bmaj = qa.convert(bmaj,'arcsec')['value']<br />
bmin = qa.convert(bmin,'arcsec')['value']<br />
<br />
toJyPerPix = 1.0 / (1.1331 * bmaj * bmin) # gaussian beam conversion = beams / pixel<br />
</source><br />
<br />
Next, scale the flux for the new luminosity distance. Make the approximation that each pixel is a point source, and use the inverse square law to scale. [[simdata2|Simdata2]] can scale the peak surface brightness using the parameter '''inbright'''.<br />
<br />
<source lang="python"><br />
# correct flux density for luminosity distance<br />
fluxScale = (dl_old/dl_new)**2 * (1.0 + z_new) / (1.0 + z_old_cmb)<br />
# current peak flux:<br />
peak = imstat(cubeName)['max'][0] * toJyPerPix # need to convert to Jy / pixel<br />
# desired peak flux in Jy / pixel:<br />
inbright = "%fJy/pixel" % (peak*fluxScale) # use python formatting convention<br />
# inbright is a simdata2 parameter<br />
</source><br />
<br />
Notice that there is an additional (1+z) correction because we are scaling flux densities rather than bolometric fluxes.<br />
<br />
==== Angular Size Scaling ====<br />
<br />
The sky coordinates axes of the model need to be adjusted (1) to place M51 in the southern hemisphere and (2) to correct for the new angular size distance. These tasks can be accomplished by the [[simdata2]] parameters '''indirection''' (change the location of M51 on the sky) and '''incell''' (change the angular scale of an input pixel).<br />
<br />
To perform task (1), we'll just flip the sign of the declination using [[imhead]]. Notice the use of the [[qa]] tool to convert radians to sexagesimal.<br />
<br />
<source lang="python"><br />
# Move to southern hemisphere.<br />
# Use qa.formxxx tool to convert rad to sexagesimal.<br />
# For clarity, build up "indirection" string one term at a time.<br />
# Epoch<br />
indirection = "J2000 " # parameter for simdata<br />
# RA<br />
indirection += qa.formxxx(imhead(imagename=cubeName,mode='get',hdkey='crval1')['value']+'rad',format='hms') + " " <br />
# Dec * -1<br />
indirection += qa.formxxx('%frad' % (-1*float(imhead(imagename=cubeName,mode='get',hdkey='crval2')['value'])),format='dms')<br />
</source><br />
<br />
<br />
<br />
Next, adjust the pixel scale for the new angular size distance. To perform this adjustment, we'll use [[imhead]] with <tt>mode = "get"</tt> to read in the original pixel scale, and <tt>mode="put"</tt> to store the new pixel scale in the model header.<br />
<br />
<source lang="python"><br />
# scale pixel size: imhead returns things in rad, so convert to arcsec<br />
oldCell = float(imhead(imagename=cubeName,mode='get',hdkey='cdelt2')['value']) * 206265 <br />
# scale for new angular size distance<br />
newCell = oldCell * da_old / da_new <br />
# Format the new pixel size for input to simdata<br />
incell = "%farcsec" % (newCell) # parameter for simdata2<br />
</source><br />
<br />
==== Adjusting the Frequency Axis ====<br />
<br />
Changing the frequency axis of the model header is just a straightforward (1+''z'') correction. [[simdata2|Simdata2]] adjusts the channelwidth using the '''inwidth''' parameter and the observing frequency using '''incenter'''. <br />
<br />
Notice that the absolute value of the BIMA SONG channel width is used. The noise calculation in [[simdata2|Simdata2]] needs positive channel widths, but the input cube is ordered in increasing velocity rather than increasing frequency. We could transpose the cube; on the other hand, the only penalty of changing the sign is that the sense of rotation will be flipped. Since this simulation is a simple detection experiment, the rotation sense is irrelevant, and so we'll take the easy way out.<br />
<br />
<source lang="python"><br />
# move freq to z_new<br />
oldFreq = float(imhead(imagename=cubeName,mode='get',hdkey='crval3')['value']) # Hz<br />
newFreq = oldFreq * (1.0 + z_old_lsrk) / (1.0 + z_new)<br />
nchan = imstat("NGC5194.bima12m.cm.fits")['trc'][2]<br />
<br />
# Adjust frequency channelwidth for new z<br />
oldDnu = float(imhead(imagename=cubeName,mode='get',hdkey='cdelt3')['value']) # Hz<br />
newDnu = abs((1.0+z_old_lsrk) /(1.0+z_new)*oldDnu) # need positive channel widths to ensure noise calc goes well<br />
inwidth = "%fHz" % newDnu # parameter for simdata<br />
<br />
# Specify the observing frequency at the center of the observing band:<br />
incenter = "%fHz" % (newFreq + 0.5*nchan*newDnu)<br />
</source><br />
<br />
=== Simdata2 ===<br />
<br />
The CASA task [[simdata2]] will monolithically simulate an ALMA observation, produce measurement sets with and without thermal noise, and finally produce a CLEANed image cube based on the simulated observation. Details can be found in the [[Simulating Observations in CASA]] tutorial.<br />
<br />
The original BIMA SONG image is about 480 arcseconds across; scale this image size to the new redshift.<br />
<br />
<source lang="python"><br />
# estimate final image size<br />
imSize = 480.0 * (da_old / da_new) # in arcseconds<br />
</source><br />
<br />
For relatively high redshifts, there should be no need to mosaic the observations. We'll nevertheless allow for mosaicking in case we want to repeat the simulation for lower redshift. [[simdata2|Simdata2]] needs the spacing between pointings in the mosaic; we'll require pointings spaced by half of the primary beam. <br />
<br />
<source lang="python"><br />
# mosaicking info<br />
primaryBeam = 17.0 * (300e9 / newFreq) # in arcseconds; ALMA primary beam = 17 arcsec at 300 GHz<br />
pointingspacing = "%farcsec" % (primaryBeam / 2.0) <br />
mapsize = "%farcsec" % imSize # how big to make the mosaic<br />
</source><br />
<br />
We also need to estimate the desired synthesized beam size. We don't want the new beam to be so large so that we cannot resolve a rotation curve, but we also don't want it to be so small that we effectively resolve out the BIMA SONG data. The BIMA SONG beam was 5 arcsec, and so as a reasonable guess we'll adopt the equivalent of a 15" beam at its true distance(3 times coarser than the BIMA SONG beam) and then scale appropriately to z = 0.1.<br />
<br />
<source lang="python"><br />
# Estimate desired beam size. BIMA SONG has 5": use 15" projected to new redshift<br />
beamNew = 15.0 * (da_old / da_new)<br />
</source><br />
<br />
We want pixels that sample the beam at least 3 times for stable deconvolution; we'll use 4 times sampling, rounded off to the nearest milliarcsec.<br />
<br />
<source lang="python"><br />
pixelSize = round(beamNew * 1000.0 / 4.0) / 1000.0<br />
</source><br />
<br />
Now, to guard against undersampling the beam as a result of rounding error, reset the desired beam to 4 times the pixel size.<br />
<br />
<source lang="python"><br />
beamNew = 4.0 * pixelSize<br />
</source><br />
<br />
Now we know both the image size and pixel size in arcseconds, but [[simdata2]] wants the ratio: the number of pixels along the RA or Dec axis. To keep the image from becoming too small, set the minimum image size to be 256 pixels.<br />
<br />
<source lang="python"><br />
imSizePix = int(round(imSize / pixelSize))<br />
if imSizePix < 256: imSizePix = 256<br />
</source><br />
<br />
Let [[simdata2]] decide on an appropriate ALMA configuration based on the desired beam size. Set the parameter '''antennalist''' as follows (but see [[#Other Antenna Configurations|Other Antenna Configurations]] below).<br />
<br />
<source lang="python"><br />
predict=True<br />
antennalist = "alma;%farcsec" % beamNew<br />
</source><br />
<br />
Now we have enough information to run [[simdata2]], and hopefully some of the python global variables that were defined above will start to make sense. The following CASA and python commands set up the remaining parameters for the [[simdata2]] task. <br />
<br />
<source lang="python"><br />
modelimage = cubeName<br />
integration = '10s' # watch out for memory limits vs. ability to complete mosaic here<br />
# 10s is usually safe for large mosaics, but will require more memory<br />
totaltime = '28800s' # 8 hr integration<br />
<br />
# make simulated images/cubes<br />
image=True<br />
thermalnoise="tsys-atm" # add thermal noise, produce noisy.ms measurement set<br />
vis = '$project.noisy.ms' # clean the data with *thermal noise added* <br />
cell = "%farcsec" % pixelSize<br />
imsize = [imSizePix,imSizePix]<br />
threshold = "1.0mJy"<br />
weighting = "natural"<br />
stokes = 'I'<br />
<br />
verbose = True<br />
graphics="both"<br />
overwrite = True<br />
<br />
inp("simdata2")<br />
simdata2()<br />
</source><br />
<br />
<br />
==== Other Antenna Configurations ====<br />
<br />
<br />
[[file:Beamsummary.png|thumb|ALMA synthetic beam size as a function of array configuration number]]<br />
Finally, we need to know which ALMA configuration number based on the desired angular resolution. [[simdata2|Simdata2]] makes this easy by allowing users to specify the desired angular resolution in the parameter '''antennalist'''.<br />
<br />
This tutorial is somewhat automated to produce a decent cube of M51 as viewed at z = 0.1. The selection of the {{ALMA}} antenna configuration is automated, but, for other simulations (or this one, for that matter), it will be worth playing with the configurations, or perhaps evaluating the possibility of detections in CSV or early science.<br />
<br />
Notice from the [[simdata2]] inputs that CASA comes with stock antenna configurations in the directory $CASAPATH/data/alma/simmos/ (the python task '''os.getenv''' is used to look up CASAPATH automatically). For CASA 3.0.1, here is a list of included antenna configurations.<br />
<br />
{| border = 1<br />
|+ '''ALMA Configuration Files'''<br />
|- <br />
| alma.csv.late.cfg<br />
|- <br />
| alma.csv.mid.cfg<br />
|- <br />
| alma.early.large.cfg<br />
|- <br />
| alma.early.med.cfg<br />
|- <br />
| alma.out01.cfg<br />
|- <br />
| alma.out02.cfg<br />
|- <br />
| alma.out03.cfg<br />
|- <br />
| ...<br />
|- <br />
| alma.out27.cfg<br />
|- <br />
| alma.out28.cfg<br />
|}<br />
<br />
There are also configuration data for the [http://www.narrabri.atnf.csiro.au/ ACA], {{EVLA}}, and [http://www.cfa.harvard.edu/sma/ SMA].<br />
<br />
=== Take a Break ===<br />
<br />
If you have got this far, you've earned it. [[simdata2|Simdata2]] will be running for a while, and coffee sure sounds good right now.<br />
<br />
=== Results ===<br />
<br />
[[File:M51sim-09.png|thumb|Channel 16 of the M51 at z=0.1 simulation. The rms noise is about 0.25 mJy/beam, and the peak flux density on this channel is about 2 mJy/beam.]]<br />
<br />
Here is an inventory of some of the [[simdata2]] products. <br />
<br />
{| border="1"<br />
! Filename<br />
! Description<br />
|-<br />
| M51-ATZ-p1.ms<br />
| Model measurement set ''sans'' noise<br />
|- <br />
| M51-ATZ-p1.noisy.ms<br />
| Model measurement set with thermal noise<br />
|-<br />
| M51-ATZ-p1.clean.image<br />
| CLEAN-deconvolved cube of M51-ATZ-p1.noisy.ms<br />
|}<br />
<br />
And there are plenty of other auxiliary files.<br />
<br />
The rest frequency will have been lost in the simulation, and it's worth restoring to the header.<br />
<br />
<source lang="python"><br />
imhead(imagename="M51-ATZ-p1.image", mode="put", hdkey="restfreq", hdvalue="115.27120180GHz")<br />
</source><br />
<br />
The simulated data cube can be analyzed just like any other CASA image -- examples are given in the [[Imaging a Mosaicked Spectral Line Dataset|CARMA tutorial]] and the [[NGC 5921: red-shifted HI emission#Cube Moments|VLA 21cm tutorial]].<br />
<br />
==== Moment Maps ====<br />
[[File:M51simnew.png|thumb|Moment maps of the M51 CO 1-0 at z=0.1 simulation. ''Left'': Moment 0 (integrated intensity) map. ''Right'': Moment 1 (velocity field) map. Note that the rotation sense has been flipped, exactly [[#Adjusting the Frequency Axis | as expected]].]]<br />
<br />
Use [[immoments]] to calculate the integrated intensity and velocity field maps from the simulated cube. The '''excludepix''' option applies a 3&sigma; cut.<br />
<br />
<source lang="python"><br />
immoments(imagename='M51-ATZ-p1.image',moments=[0,1],axis='spectral',<br />
excludepix=[-100,0.0006],outfile='M51-ATZ-p1.moments')<br />
</source><br />
<br />
The results are shown at right.<br />
<br />
=== Pushing M51 out to z = 0.3 ===<br />
<br />
We'll leave it as an exercise how to tune this simulation to push M51 all the way out to z = 0.3 (luminosity distance = 1540 Mpc). [[simdata2|Simdata2]] produces a reasonable detection in 8 hrs integration, but you'll need to consider more carefully the antenna configuration needed to produce the requisite sensitivity. To conclude, here are the moment maps for the z = 0.3 simulation.<br />
<br />
[[File:M51sim78.png|400px|Simulation of M51 CO 1-0 at z = 0.3. ''Left'': integrated intensity map. ''Right'': (marginally resolved) velocity field.]]<br />
<br />
{{Checked 3.0.2}}<br />
<br />
--[[User:Jgallimo|Jack Gallimore]] 15:55, 30 April 2010 (UTC)</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=M51_at_z_%3D_0.1_and_z_%3D_0.3_(CASA_3.1)&diff=3701M51 at z = 0.1 and z = 0.3 (CASA 3.1)2010-06-03T20:24:47Z<p>Jgallimo: </p>
<hr />
<div>[[Category: Simulations]] [[Category:ALMA]]<br />
<br />
=== Overview ===<br />
<br />
[[File:M51sim-5and6.png|thumb|CO 1-0 Moment maps of the original BIMA SONG measurements of M51. ''Left'': Moment 0 (integrated intensity). ''Right'': Moment 1 (velocity field).]]<br />
<br />
This tutorial presents a simulation of ALMA observations of the well-known galaxy M51 in the CO 1-0 transition. This galaxy is located relatively nearby (luminosity distance = 9 Mpc), but, in this simulation, we will model how it would appear at redshift z = 0.1 (luminosity distance = 460 Mpc). <br />
<br />
The goal of this tutorial is to provide a ''complete'' run-through of a relatively simple simulation. Included in this simulation are the effects of (''u'', ''v'') sampling of a 50-antenna ALMA, the primary beam of the ALMA, and thermal noise. Neither calibration overheads nor errors are included, and so this simulation should be viewed as optimistic.<br />
<br />
For this tutorial, we'll use the [http://nedwww.ipac.caltech.edu/level5/March02/SONG/SONG.html BIMA SONG] ([http://adsabs.harvard.edu//abs/2003ApJS..145..259H Helfer et al. 2003]) observations of M51 as the basis for the model. Grab the file [http://nedwww.ipac.caltech.edu/level5/March02/SONG/NGC5194.bima12m.cm.fits.gz NGC5194.bima12m.cm.fits.gz] and uncompress it in a working directory.<br />
<br />
<source lang="bash"><br />
# in bash (or other unix shell)<br />
gunzip NGC5194.bima.12m.cm.fits.gz<br />
</source><br />
<br />
Load these data into CASA. For convenience, store the name of the resulting measurement set into the python global <tt>cubeName</tt>. <br />
<br />
<source lang="python"><br />
cubeName = 'm51-song'<br />
importfits(fitsimage='NGC5194.bima12m.cm.fits', imagename=cubeName)<br />
<br />
# initialize simdata2<br />
default("simdata2")<br />
skymodel=cubeName<br />
modifymodel=True<br />
</source><br />
<br />
=== Noise in the Input Model ===<br />
<br />
The input model is actually an observation and, as such, certainly contains noise. We're OK as long as the noise in the model falls below the expected thermal noise of the ALMA observation. Here's a quick, back-of-the-envelope calculation.<br />
<br />
The noise on the BIMA SONG channels measures roughly 0.1 Jy/beam, which scales to 0.04 mJy/beam at z = 0.1 (to within factors of powers of 1+z for cosmology and root-small-integer for the to-be-degraded beam; see below). For comparison, the expected thermal noise of the ALMA observation is 0.1 mJy / beam (using the [http://www.eso.org/sci/facilities/alma/observing/tools/etc/index.html ALMA Sensitivity Calculator], assuming 8 hrs integration, and, to match roughly the BIMA SONG observation, a 4 MHz channel width), a factor of 2.5 greater than the anticipated contribution of noise from the model. Added in quadrature, the noise components total 0.108 mJy, and so we can expect that the input model noise degrades the simulation noise by about 8%.<br />
<br />
=== Cosmology Calculations ===<br />
<br />
Next we'll set up some python globals to handle the scaling of the model coordinates and flux densities appropriate for new redshift. We'll primarily need the angular size and luminosity distances for a given cosmology. To keep things simple, we'll use [http://www.astro.ucla.edu/~wright/CosmoCalc.html Ned Wright's CosmoCalc] ([http://adsabs.harvard.edu/abs/2006PASP..118.1711W 2006]) with the default cosmology; redshifts were collected from [http://nedwww.ipac.caltech.edu/cgi-bin/nph-objsearch?objname=NGC5194&extend=no&hconst=73&omegam=0.27&omegav=0.73&corr_z=1&out_csys=Equatorial&out_equinox=J2000.0&obj_sort=RA+or+Longitude&of=pre_text&zv_breaker=30000.0&list_limit=5&img_stamp=YES NED]. <br />
<br />
<source lang="python"><br />
#z's <br />
# Distinguish between z_lsrk, which sets the observed frequency for scaling, from z_cmb, <br />
# which is needed to get cosmological distances.<br />
z_old_cmb = 0.002122 # CMB-referenced z for cosmological distances from NED<br />
z_old_lsrk = 0.001544 # from NED<br />
z_new = 0.1<br />
<br />
# angular size distances from CosmoCalc<br />
da_old = 9.0<br />
da_new = 375.9<br />
<br />
# luminosity distances from CosmoCalc<br />
dl_old = 8.937<br />
dl_new = 454.8<br />
</source><br />
<br />
The convention is ''old'' refers to M51 as observed at its proper redshift, and ''new'' refers to the new, higher redshift for our model.<br />
<br />
=== Preparing the Model ===<br />
<br />
The next step is to scale the M51 data cube into a model cube appropriate for [[simdata2]]. First, we'll set up some globals to establish some file naming conventions.<br />
<br />
<source lang="python"><br />
suffix = "-p1" # z = 0.1, or point-1; useful to distinguish from repeated simulations at different z's<br />
project = "M51-ATZ" + suffix # project ID to assign output filenames (simdata2 parameter)<br />
</source><br />
<br />
<br />
==== Flux Density Scaling ====<br />
<br />
Our goal in this step is to set the '''inbright''' parameter of [[simdata2]], which will scale the data cube appropriately for its new luminosity distance.<br />
<br />
[[simdata2|Simdata2]] wants models in units of Jy / pixel, but the BIMA SONG cube is in units of Jy / beam. That's an easy conversion.<br />
<br />
<source lang="python"><br />
# BIMA SONG beam <br />
bmaj = imhead(imagename=cubeName,mode='get',hdkey='beammajor')<br />
bmin = imhead(imagename=cubeName,mode='get',hdkey='beamminor')<br />
<br />
# use [http://casa.nrao.edu/docs/casaref/quanta-Module.html#x409-4100001.4 qa] tool to convert beam in radians to (1 arcsec) pixels:<br />
bmaj = qa.convert(bmaj,'arcsec')['value']<br />
bmin = qa.convert(bmin,'arcsec')['value']<br />
<br />
toJyPerPix = 1.0 / (1.1331 * bmaj * bmin) # gaussian beam conversion = beams / pixel<br />
</source><br />
<br />
Next, scale the flux for the new luminosity distance. Make the approximation that each pixel is a point source, and use the inverse square law to scale. [[simdata2|Simdata2]] can scale the peak surface brightness using the parameter '''inbright'''.<br />
<br />
<source lang="python"><br />
# correct flux density for luminosity distance<br />
fluxScale = (dl_old/dl_new)**2 * (1.0 + z_new) / (1.0 + z_old_cmb)<br />
# current peak flux:<br />
peak = imstat(cubeName)['max'][0] * toJyPerPix # need to convert to Jy / pixel<br />
# desired peak flux in Jy / pixel:<br />
inbright = "%fJy/pixel" % (peak*fluxScale) # use python formatting convention<br />
# inbright is a simdata2 parameter<br />
</source><br />
<br />
Notice that there is an additional (1+z) correction because we are scaling flux densities rather than bolometric fluxes. <br />
<br />
==== Angular Size Scaling ====<br />
<br />
The sky coordinates axes of the model need to be adjusted (1) to place M51 in the southern hemisphere and (2) to correct for the new angular size distance. These tasks can be accomplished by the [[simdata2]] parameters '''indirection''' (change the location of M51 on the sky) and '''incell''' (change the angular scale of an input pixel).<br />
<br />
To perform task (1), we'll just flip the sign of the declination using [[imhead]]. Notice the use of the [[qa]] tool to convert radians to sexagesimal.<br />
<br />
<source lang="python"><br />
# Move to southern hemisphere.<br />
# Use qa.formxxx tool to convert rad to sexagesimal.<br />
# For clarity, build up "indirection" string one term at a time.<br />
# Epoch<br />
indirection = "J2000 " # parameter for simdata<br />
# RA<br />
indirection += qa.formxxx(imhead(imagename=cubeName,mode='get',hdkey='crval1')['value']+'rad',format='hms') + " " <br />
# Dec * -1<br />
indirection += qa.formxxx('%frad' % (-1*float(imhead(imagename=cubeName,mode='get',hdkey='crval2')['value'])),format='dms')<br />
</source><br />
<br />
<br />
<br />
Next, adjust the pixel scale for the new angular size distance. To perform this adjustment, we'll use [[imhead]] with <tt>mode = "get"</tt> to read in the original pixel scale, and <tt>mode="put"</tt> to store the new pixel scale in the model header.<br />
<br />
<source lang="python"><br />
# scale pixel size: imhead returns things in rad, so convert to arcsec<br />
oldCell = float(imhead(imagename=cubeName,mode='get',hdkey='cdelt2')['value']) * 206265 <br />
# scale for new angular size distance<br />
newCell = oldCell * da_old / da_new <br />
# Format the new pixel size for input to simdata<br />
incell = "%farcsec" % (newCell) # parameter for simdata2<br />
</source><br />
<br />
==== Adjusting the Frequency Axis ====<br />
<br />
Changing the frequency axis of the model header is just a straightforward (1+''z'') correction. [[simdata2|Simdata2]] adjusts the channelwidth using the '''inwidth''' parameter and the observing frequency using '''incenter'''. <br />
<br />
Notice that the absolute value of the BIMA SONG channel width is used. The noise calculation in [[simdata2|Simdata2]] needs positive channel widths, but the input cube is ordered in increasing velocity rather than increasing frequency. We could transpose the cube; on the other hand, the only penalty of changing the sign is that the sense of rotation will be flipped. Since this simulation is a simple detection experiment, the rotation sense is irrelevant, and so we'll take the easy way out.<br />
<br />
<source lang="python"><br />
# move freq to z_new<br />
oldFreq = float(imhead(imagename=cubeName,mode='get',hdkey='crval3')['value']) # Hz<br />
newFreq = oldFreq * (1.0 + z_old_lsrk) / (1.0 + z_new)<br />
nchan = imstat("NGC5194.bima12m.cm.fits")['trc'][2]<br />
<br />
# Adjust frequency channelwidth for new z<br />
oldDnu = float(imhead(imagename=cubeName,mode='get',hdkey='cdelt3')['value']) # Hz<br />
newDnu = abs((1.0+z_old_lsrk) /(1.0+z_new)*oldDnu) # need positive channel widths to ensure noise calc goes well<br />
inwidth = "%fHz" % newDnu # parameter for simdata<br />
<br />
# Specify the observing frequency at the center of the observing band:<br />
incenter = "%fHz" % (newFreq + 0.5*nchan*newDnu)<br />
</source><br />
<br />
=== Simdata2 ===<br />
<br />
The CASA task [[simdata2]] will monolithically simulate an ALMA observation, produce measurement sets with and without thermal noise, and finally produce a CLEANed image cube based on the simulated observation. Details can be found in the [[Simulating Observations in CASA]] tutorial.<br />
<br />
The original BIMA SONG image is about 480 arcseconds across; scale this image size to the new redshift.<br />
<br />
<source lang="python"><br />
# estimate final image size<br />
imSize = 480.0 * (da_old / da_new) # in arcseconds<br />
</source><br />
<br />
For relatively high redshifts, there should be no need to mosaic the observations. We'll nevertheless allow for mosaicking in case we want to repeat the simulation for lower redshift. [[simdata2|Simdata2]] needs the spacing between pointings in the mosaic; we'll require pointings spaced by half of the primary beam. <br />
<br />
<source lang="python"><br />
# mosaicking info<br />
primaryBeam = 17.0 * (300e9 / newFreq) # in arcseconds; ALMA primary beam = 17 arcsec at 300 GHz<br />
pointingspacing = "%farcsec" % (primaryBeam / 2.0) <br />
mapsize = "%farcsec" % imSize # how big to make the mosaic<br />
</source><br />
<br />
We also need to estimate the desired synthesized beam size. We don't want the new beam to be so large so that we cannot resolve a rotation curve, but we also don't want it to be so small that we effectively resolve out the BIMA SONG data. The BIMA SONG beam was 5 arcsec, and so as a reasonable guess we'll adopt the equivalent of a 15" beam at its true distance(3 times coarser than the BIMA SONG beam) and then scale appropriately to z = 0.1.<br />
<br />
<source lang="python"><br />
# Estimate desired beam size. BIMA SONG has 5": use 15" projected to new redshift<br />
beamNew = 15.0 * (da_old / da_new)<br />
</source><br />
<br />
We want pixels that sample the beam at least 3 times for stable deconvolution; we'll use 4 times sampling, rounded off to the nearest milliarcsec.<br />
<br />
<source lang="python"><br />
pixelSize = round(beamNew * 1000.0 / 4.0) / 1000.0<br />
</source><br />
<br />
Now, to guard against undersampling the beam as a result of rounding error, reset the desired beam to 4 times the pixel size.<br />
<br />
<source lang="python"><br />
beamNew = 4.0 * pixelSize<br />
</source><br />
<br />
Now we know both the image size and pixel size in arcseconds, but [[simdata2]] wants the ratio: the number of pixels along the RA or Dec axis. To keep the image from becoming too small, set the minimum image size to be 256 pixels.<br />
<br />
<source lang="python"><br />
imSizePix = int(round(imSize / pixelSize))<br />
if imSizePix < 256: imSizePix = 256<br />
</source><br />
<br />
Let [[simdata2]] decide on an appropriate ALMA configuration based on the desired beam size. Set the parameter '''antennalist''' as follows (but see [[#Other Antenna Configurations|Other Antenna Configurations]] below).<br />
<br />
<source lang="python"><br />
predict=True<br />
antennalist = "alma;%farcsec" % beamNew<br />
</source><br />
<br />
Now we have enough information to run [[simdata2]], and hopefully some of the python global variables that were defined above will start to make sense. The following CASA and python commands set up the remaining parameters for the [[simdata2]] task. <br />
<br />
<source lang="python"><br />
modelimage = cubeName<br />
integration = '10s' # watch out for memory limits vs. ability to complete mosaic here<br />
# 10s is usually safe for large mosaics, but will require more memory<br />
totaltime = '28800s' # 8 hr integration<br />
<br />
# make simulated images/cubes<br />
image=True<br />
thermalnoise="tsys-atm" # add thermal noise, produce noisy.ms measurement set<br />
vis = '$project.noisy.ms' # clean the data with *thermal noise added* <br />
cell = "%farcsec" % pixelSize<br />
imsize = [imSizePix,imSizePix]<br />
threshold = "1.0mJy"<br />
weighting = "natural"<br />
stokes = 'I'<br />
<br />
verbose = True<br />
graphics="both"<br />
overwrite = True<br />
<br />
inp("simdata2")<br />
simdata2()<br />
</source><br />
<br />
<br />
==== Other Antenna Configurations ====<br />
<br />
<br />
[[file:Beamsummary.png|thumb|ALMA synthetic beam size as a function of array configuration number]]<br />
Finally, we need to know which ALMA configuration number based on the desired angular resolution. [[simdata2|Simdata2]] makes this easy by allowing users to specify the desired angular resolution in the parameter '''antennalist'''.<br />
<br />
This tutorial is somewhat automated to produce a decent cube of M51 as viewed at z = 0.1. The selection of the {{ALMA}} antenna configuration is automated, but, for other simulations (or this one, for that matter), it will be worth playing with the configurations, or perhaps evaluating the possibility of detections in CSV or early science.<br />
<br />
Notice from the [[simdata2]] inputs that CASA comes with stock antenna configurations in the directory $CASAPATH/data/alma/simmos/ (the python task '''os.getenv''' is used to look up CASAPATH automatically). For CASA 3.0.1, here is a list of included antenna configurations.<br />
<br />
{| border = 1<br />
|+ '''ALMA Configuration Files'''<br />
|- <br />
| alma.csv.late.cfg<br />
|- <br />
| alma.csv.mid.cfg<br />
|- <br />
| alma.early.large.cfg<br />
|- <br />
| alma.early.med.cfg<br />
|- <br />
| alma.out01.cfg<br />
|- <br />
| alma.out02.cfg<br />
|- <br />
| alma.out03.cfg<br />
|- <br />
| ...<br />
|- <br />
| alma.out27.cfg<br />
|- <br />
| alma.out28.cfg<br />
|}<br />
<br />
There are also configuration data for the [http://www.narrabri.atnf.csiro.au/ ACA], {{EVLA}}, and [http://www.cfa.harvard.edu/sma/ SMA].<br />
<br />
=== Take a Break ===<br />
<br />
If you have got this far, you've earned it. [[simdata2|Simdata2]] will be running for a while, and coffee sure sounds good right now.<br />
<br />
=== Results ===<br />
<br />
[[File:M51sim-09.png|thumb|Channel 16 of the M51 at z=0.1 simulation. The rms noise is about 0.25 mJy/beam, and the peak flux density on this channel is about 2 mJy/beam.]]<br />
<br />
Here is an inventory of some of the [[simdata2]] products. <br />
<br />
{| border="1"<br />
! Filename<br />
! Description<br />
|-<br />
| M51-ATZ-p1.ms<br />
| Model measurement set ''sans'' noise<br />
|- <br />
| M51-ATZ-p1.noisy.ms<br />
| Model measurement set with thermal noise<br />
|-<br />
| M51-ATZ-p1.clean.image<br />
| CLEAN-deconvolved cube of M51-ATZ-p1.noisy.ms<br />
|}<br />
<br />
And there are plenty of other auxiliary files.<br />
<br />
The rest frequency will have been lost in the simulation, and it's worth restoring to the header.<br />
<br />
<source lang="python"><br />
imhead(imagename="M51-ATZ-p1.image", mode="put", hdkey="restfreq", hdvalue="115.27120180GHz")<br />
</source><br />
<br />
The simulated data cube can be analyzed just like any other CASA image -- examples are given in the [[Imaging a Mosaicked Spectral Line Dataset|CARMA tutorial]] and the [[NGC 5921: red-shifted HI emission#Cube Moments|VLA 21cm tutorial]].<br />
<br />
==== Moment Maps ====<br />
[[File:M51simnew.png|thumb|Moment maps of the M51 CO 1-0 at z=0.1 simulation. ''Left'': Moment 0 (integrated intensity) map. ''Right'': Moment 1 (velocity field) map. Note that the rotation sense has been flipped, exactly [[#Adjusting the Frequency Axis | as expected]].]]<br />
<br />
Use [[immoments]] to calculate the integrated intensity and velocity field maps from the simulated cube. The '''excludepix''' option applies a 3&sigma; cut.<br />
<br />
<source lang="python"><br />
immoments(imagename='M51-ATZ-p1.image',moments=[0,1],axis='spectral',<br />
excludepix=[-100,0.0006],outfile='M51-ATZ-p1.moments')<br />
</source><br />
<br />
The results are shown at right.<br />
<br />
=== Pushing M51 out to z = 0.3 ===<br />
<br />
We'll leave it as an exercise how to tune this simulation to push M51 all the way out to z = 0.3 (luminosity distance = 1540 Mpc). [[simdata2|Simdata2]] produces a reasonable detection in 8 hrs integration, but you'll need to consider more carefully the antenna configuration needed to produce the requisite sensitivity. To conclude, here are the moment maps for the z = 0.3 simulation.<br />
<br />
[[File:M51sim78.png|400px|Simulation of M51 CO 1-0 at z = 0.3. ''Left'': integrated intensity map. ''Right'': (marginally resolved) velocity field.]]<br />
<br />
{{Checked 3.0.2}}<br />
<br />
--[[User:Jgallimo|Jack Gallimore]] 15:55, 30 April 2010 (UTC)</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Spectral_Line_Calibration_IRC%2B10216&diff=3700EVLA Spectral Line Calibration IRC+102162010-06-03T20:16:15Z<p>Jgallimo: /* Setup the Model for the Flux Calibrator */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]][[Category:Spectral Line]]<br />
<br />
<br />
<pre style="background-color: #FFFF00;"><br />
This tutorial is under construction. There are several things still to be added <br />
<br />
For the time being (until release candidate is built) you want to run this on casapy-test<br />
<br />
</pre><br />
<br />
== Overview ==<br />
This tutorial describes the data reduction for two spectral lines observed toward the AGB star IRC+10216. This carbon star, which is a few times more massive than our sun, is nearing the end of its life and is thought to be in the process of forming a planetary nebula. <br />
<br />
In this EVLA OSRO1 mode observation one subband was observed in each of two basebands, the subbands were centered on the HC3N and SiS lines near 36 GHz. The raw data were loaded into CASA with {{importevla}}, where zero and shadowed data were flagged. Then the data were "{{split}}", so we could average from the native 1 second integrations to 10 seconds, select only antennas with Ka-band receivers, and select only spectral windows (called spw in CASA) with Ka-band data. This produces a significantly smaller dataset for processing.<br />
<br />
The post-split averaged data can be downloaded from http://casa.nrao.edu/Data/EVLA/IRC10216/day2_TDEM0003_10s_norx.tar<br />
<br />
Once the download is complete, unpack the file:<br />
<br />
<source lang='bash'><br />
# in a terminal, outside of CASA:<br />
tar -xvf day2_TDEM0003_10s_norx.tar<br />
</source><br />
<br />
== The Observing Log, Antenna Position Corrections, and other Calibration "Priors"==<br />
<br />
For all EVLA observations, the operators keep an observing log. You can look at<br />
the observing logs at the observing log [[http://www.vla.nrao.edu/cgi-bin/oplogs.cgi website]]. Pertinent information from this observation are repeated below. <br />
<pre style="background-color: #E0FFFF;"><br />
INFORMATION FROM OBSERVING LOG:<br />
Date of the observation: 26-April-2010<br />
There are no Ka-band receivers on ea11, ea13, ea14, ea16, ea17, ea18, ea26 <br />
Antennas ea10, ea06 are out of the array<br />
Antenna ea12 is newly back<br />
The pointing is often bad on ea15<br />
Antennas ea10, ea12, ea22 do not have good baseline positions<br />
</pre><br />
<br />
As mentioned in the log, antennas ea10, ea12, and ea22 do not have good baseline positions.<br />
Antenna ea10 was not in the array, but for the other two antennas we need to check for<br />
any improved baseline positions that were derived after the observations were taken.<br />
<br />
In CASA, we need to insert these corrections by hand using '''{{gencal}}'''. The resulting table will need to be supplied as a "prior" calibration to all subsequent calibration steps. The corrections can be ascertained from the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections page]. Be sure to carefully read to the bottom of that <br />
webpage to see how to calculate the additive corrections. The current case is simple as there is only a single correction for each antenna. In the future we will implement an automated lookup of the corrections. <br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='day2_TDEM0003_10s_norx',caltable='antpos.cal',<br />
caltype='antpos',<br />
antenna='ea12,ea22',<br />
parameter=[-0.0072,0.0045,-0.0017, -0.0220,0.0040,-0.0190])<br />
</source><br />
<br />
'''Please note: '''if you are reducing VLA data taken before March 1, 2010, you need to set caltype='antposvla'.<br />
<br />
<br />
<br />
There are two other types of "priors" that we will need to apply at each calibration stage described below:<br />
<br />
(1) Opacity correction -- in the near future the opacity will be calculated from the weather<br />
data and an atmospheric model, or alternatively from a tipping scan, or a combination of<br />
both. For now we use a cannonical value for the zenith opacity based on the weather on that day, which at this<br />
frequency (36 GHz) is about 0.03 on the best days. We will use a zenith opacity of <math>\tau_z</math>=0.04. The zenith opacity is then corrected for <br />
the elevation of the data automatically using <math>e^{[-\csc(el)\tau_z]}</math>.<br />
<br />
(2) Gaincurve -- the gaincurve describes how each antenna behaves as a function of elevation, for each receiver band. Currently only gaincurves for the VLA/EVLA are available. This option should not be used <br />
with any other telescopes.<br />
<br />
==Initial Inspection and Flagging==<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='day2_TDEM0003_10s_norx')<br />
</source><br />
<br />
Below we have cut and pasted the most relevant output from the logger.<br />
<br />
<pre style="background-color: #fffacd;"><br />
Fields: 4<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
2 D J0954+1743 09:54:56.8236 +17.43.31.2224 J2000 2 65326 <br />
3 NONE IRC+10216 09:47:57.3820 +13.16.40.6600 J2000 3 208242 <br />
5 F J1229+0203 12:29:06.6997 +02.03.08.5982 J2000 5 10836 <br />
7 E J1331+3030 13:31:08.2880 +30.30.32.9589 J2000 7 5814 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (2 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
0 64 TOPO 36387.2295 125 8000 36387.2295 RR RL LR LL <br />
1 64 TOPO 36304.542 125 8000 36304.542 RR RL LR LL <br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1008+0730 0 0.03639232 -0.026 <br />
0 J1008+0730 1 0.03639232 -0.026 <br />
2 J0954+1743 0 0.03639232 -0.026 <br />
2 J0954+1743 1 0.03639232 -0.026 <br />
3 IRC+10216 0 0.03639232 -0.026 <br />
3 IRC+10216 1 0.03639232 -0.026 <br />
5 J1229+0203 0 0.03639232 -0.026 <br />
5 J1229+0203 1 0.03639232 -0.026 <br />
7 J1331+3030 0 0.03639232 -0.026 <br />
7 J1331+3030 1 0.03639232 -0.026 <br />
Antennas: 19:<br />
ID Name Station Diam. Long. Lat. <br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
8 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
9 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
10 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
11 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
12 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
13 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
14 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
15 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
16 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
17 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
18 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
</pre><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Summary of Observing Strategy<br />
Gain Calibrator: J0954+1743 field id=2<br />
Bandpass Calibrator: J1229+0203 field id=5<br />
Flux Calibrator: J1331+3030 (3C286) field id=7<br />
Target: IRC+10216 field id=3<br />
Ka-band spws = 0,1<br />
</pre> <br />
<br />
[[Image:Ant_locations.png|thumb|Antenna locations from running plotants ]]<br />
Look at a graphical plot of the antenna locations and save hardcopy<br />
in case you want it later. This will be useful for picking a reference antenna --<br />
typically a good choice is an antenna close to the center of the array. Unless it <br />
shows problems after inspection of the data, we provisionally chose ea02.<br />
<br />
[[Image:elevationvstime.png|thumb|Elevation as a function of time (after selecting colorize by field).]]<br />
<source lang="python"><br />
# In CASA<br />
plotants(vis='day2_TDEM0003_10s_norx',figfile='ant_locations.png')<br />
</source><br />
<br />
Next, let's look at the elevation as a function of time for all sources. It's not the case for these data, but if the elevation is very low (usually at start or end of track) you may want to flag. Also, how near in elevation your flux calibrator is to your target will impact your ultimate absolute flux calibration accuracy. Unfortunately, the target and flux calibrator are not particularly well-matched for this observation, as y ou can show by plotting the elevation for each source:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',<br />
xaxis='time',yaxis='elevation',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60')<br />
</source><br />
<br />
Thus we are strongly dependent on the opacity and gaincurve corrections to get the flux scale right for these data. (This is something to keep in mind when planning observations!)<br />
<br />
[[Image:plotallfields.png|thumb|Result of plotms after selecting colorize by field]]<br />
[[Image:Zoom1_mark.png|thumb|Zooming in and marking region (hatched box)]]<br />
<br />
Next,let's look at all the source amplitudes as a function of time.<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60')<br />
</source><br />
<br />
Select the "Display" tab and colorize by field, and click Plot button. <br />
<br />
<br />
Now zoom in on the region very near zero amplitude for sources J0954+1743 and IRC+10216. To zoom, select the <br />
Zoom tool in lower left corner of the {{plotms}} GUI, then you can left click to draw a box. <br />
Look for the low values (you may want to zoom a few times to really see the suspect points clearly). Now use the Mark Region and Locate buttons (located along the bottom of the GUI) to see which antenna is causing problems. Since all the "located" baselines include ea12, this is the responsible antenna.<br />
<br />
<pre style="background-color: #98FB98;"><br />
IMPORTANT NOTES ON PLOTMS:<br />
<br />
* When using the locate button it is important to have only selected a modest number <br />
of points with the mark region tool (see example of marked region in the thumnail), <br />
otherwise the response will be very slow and possibly hang the tool <br />
(all of the information will be output to your terminal window, not the logger). <br />
<br />
* Throughout the tutorial, when you are done marking/locate use the Clear Regions <br />
tool to get rid of the marked box before plotting other things. <br />
<br />
* After flagdata command flagging, you have to force a complete reload of the cache <br />
to look at the same plot again with the new flags applied. To do this change anything <br />
in the plotms GUI (the colorize parameter, antenna, spw, anything) and hit the <br />
plot button.<br />
<br />
* If the plotms tool does get hung during a plot try clicking the cancel button on the <br />
load progress GUI, and/or if you see a "table locked" message try typing <br />
clearstat on the CASA command line.<br />
<br />
* Occasionally plotms will get into a strange state that you cannot clear from inside. <br />
We are working on these issues, but for now, when all else fails, exit from casapy and <br />
restart. <br />
<br />
</pre> <br />
<br />
Now click the unmark region button, and then go back to the zoom button to zoom in further to note exactly what the time range is: 03:41:00~04:10:00.<br />
<br />
Check the other sideband by changing spw to 1:4~60. You will have to<br />
rezoom. If you have trouble, click on the Mark icon and then back to<br />
zoom. In spw=1, ea07 is bad from the beginning until after next<br />
pointing run: 03:21:40~04:10:00. To see this, compare the amplitudes when antenna is set to 'ea07' and when it is set to one of the other antennas, such as 'ea08'.<br />
<br />
If you set antenna to 'ea12' and zoom in on this intial timerange, you can also see that ea12 is bad during the same time range as for spw 0. You can also see this by entering '!ea07' for antenna, which removes ea07 from the plot (in CASA selection, ! deselects). <br />
<br />
We can set up a flagging command to get both bad antennas for the<br />
appropriate time and spw:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='day2_TDEM0003_10s_norx',<br />
field=['2,3','2,3'],<br />
spw=['','1'],<br />
antenna=['ea12','ea07'],<br />
timerange=['03:41:00~04:10:00','03:21:40~04:10:00'])<br />
</source><br />
<br />
Note that because the chosen timerange is limited to fields 2 and 3,the field parameter is not really<br />
needed; however, flagdata will run fastest if you put as many constraints as possible.<br />
<br />
Now remove the !ea07 from antenna and replot both spw, zooming in to<br />
be sure that all obviously low points are gone. Also zoom in and<br />
check 3C286 (J1229+0203 is already obvious because it is so bright!). <br />
<br />
[[Image:IRC10216_uvdist1.png|thumb|Amplitude vs. uv-distance for IRC+10216, both spw (after colorize by spw)]]<br />
<br />
Lets look more closely at IRC+10216:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0~1:4~60')<br />
</source><br />
<br />
Go to the "display" tab and choose colorize by spw. You can see a<br />
that there are some noisy high points. But now try<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0~1:4~60')<br />
</source><br />
<br />
Most of the high points on IRC+10216 are due to large scale emission on short baselines, but there is still some noisy stuff -- for a target like this with extended emission its best to wait until later to decide what to do about it. We will not be able to get adequate calibration for antennas that are truly bad (even if they don't stand out here) so these will be obvious later.<br />
<br />
==Set Up the Model for the Flux Calibrator==<br />
<br />
Next, we set the model for the flux calibrator. Depending on your observing frequency and angular resolution you can do this several ways. In the past, one typically used a point source (constant flux) model for <br />
the flux calibrator, possibly with a uvrange cutoff if necessary. More recently for the VLA/EVLA, model images for the most common flux calibrators have been made available for use in cases where the sources are somewhat resolved. This is most likely to be true at higher frequencies and at higher resolutions (more extended arrays). Thus below we use the K-band model image for these Ka-band observations. Because one model image is typically available per receiver band (in this case the model for Ka-band is the same as that of K-band), the frequency of the model image probably does not match exactly the frequency of your observations, as is certainly the case here. In that case, the task scales the total flux in the model image to that appropriate for your observing frequency according to the calibrators flux as a function of frequency model, and reports this number in the logger -- it is a good idea to save this information for your records.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='day2_TDEM0003_10s_norx',field='7',spw='0~1',<br />
modimage='/usr/lib64/casapy/data/nrao/VLA/CalModels/3C286_K.im')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
The logger output for each spw is:<br />
setjy J1331+3030 spwid= 0 [I=1.692, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
setjy J1331+3030 spwid= 1 [I=1.695, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
</pre><br />
<br />
The modimage location used in the command is appropriate for running CASA at the AOC. If you are running elsewhere (laptop or Mac), in a terminal type<br />
<br />
<source lang='bash'><br />
# in a terminal, outside of CASA:<br />
locate 3C286_K.im <br />
</source><br />
<br />
to find where the models live (the models are always shipped with CASA).<br />
<br />
==Bandpass==<br />
<br />
Before determining the bandpass solution, we need to inspect phase and amplitude<br />
variations with time and frequency on the bandpass calibrator to<br />
decide how best to proceed. We limit the number of antennas to make<br />
the plot easier to see. We chose ea02 as it seems like a good<br />
candidate for the reference antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='phase',correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02&ea23')<br />
</source><br />
[[Image:Nobandpass_phase.png|thumb|Phase as a function of channel for ea02 (after colorize by Antenna2, and Custom and upping "Style" to 3.)]]<br />
The phase variation is modest ~10 degrees. Now expand to all antennas with ea02 and <br />
select colorize by Antenna2, then hit the "Plot" button.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='phase',correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02')<br />
</source><br />
[[Image:Nobandpass_phasetime.png|thumb|Phase as a function of time for all baselines with antenna ea02 (after colorize by Antenna2, and Custom and upping "Style" to 3.)]]<br />
Go to the "display" tab and chose colorize by antenna2. From this<br />
you can see that the phase variation across the bandpass is<br />
modest. Next check LL, and spw=1, both correlations. Also check<br />
other antennas if you like.<br />
<br />
Now look at the phase as a function of time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='time',yaxis='phase',correlation='RR',<br />
avgchannel='64',spw='0:4~60',antenna='ea02&ea23')<br />
</source><br />
<br />
<br />
Expand to all antennas with ea02<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='time',yaxis='phase',correlation='RR',<br />
avgchannel='64',spw='0:4~60',antenna='ea02')<br />
</source><br />
<br />
Go to the "display" tab and chose colorize by antenna2, you may also want to select "Custom" under "unflagged points symbol" and then change Style from "2" to "3".<br />
<br />
You can see that the phase variations are smooth, but do vary<br />
significantly over the 5 minutes of observation -- in most cases by<br />
a few 10s of degrees. Zoom in to see this better if you want.<br />
<br />
The conclusion from this investigation is that you need to correct<br />
the phase variations with time before solving for the bandpass to<br />
prevent decorrelation of the vector averaged bandpass<br />
solution. Since the phase variation as a function of channel is<br />
modest, you can average over several channels to increase the signal<br />
to noise of the phase vs. time solution. If the phase variation as a<br />
function of channel is larger you may need to use only a few<br />
channels to prevent introducing delay-based closure errors as can happen from averaging over<br />
non-bandpass corrected channels with large phase variations.<br />
<br />
<br />
Since the bandpass calibrator is quite strong we do the phase-only<br />
solution on the integration time of 10 seconds (solint='int').<br />
<br />
[[Image:Prebp_phasecal2.png|thumb|Phase only calibration before bandpass. The 4 lines are both polarizations in both spw, unfortunately two of them get the same color green at the moment.]]<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='bpphase.gcal',<br />
field='5',spw='0~1:20~40',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
gaintable=['antpos.cal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
Plot the solutions<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='bpphase.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
These solutions will appear in the CASA plotter gui. If you closed it after plotting the antennas above, it should reopen. If it is still open from before, the new plots should just appear. After you are done looking at the first set of plots, push the "Next" button on the GUI to see the next set of antennas.<br />
<br />
Next we can apply this phase solution on the fly while determining<br />
the bandpass solutions on the timescale of the bandpass calibrator scan (solint='inf'). <br />
<br />
[[Image:Bandpass_amp.png|thumb|Amplitude Bandpass solutions]]<br />
[[Image:Bandpass_phase1.png|thumb|Phase Bandpass solutions]]<br />
<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='day2_TDEM0003_10s_norx',caltable='bandpass.bcal',field='5',<br />
refant='ea02',solint='inf',solnorm=T,<br />
gaintable=['antpos.cal','bpphase.gcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
'''A few words about solint and combine:'''<br />
<br />
The use of solint='inf' in {{bandpass}} will derive one bandpass<br />
solution for the whole J1229+0203 scan. Note that if there had been two observations of the bandpass calibrator (for example), this command would have combined the data from both scans to form one bandpass solution, because the default of the combine parameter '''for {{bandpass}}''' is combine='scan'. To solve for one bandpass for each bandpass calibrator scan you would also need to include combine='''' '''' in the bandpass call. In all calibration tasks, regardless of solint, scan boundaries are only crossed when combine='scan'. Likewise, field (spw) boundaries are only crossed if combine='field' (combine='spw'), the latter two are not generally good ideas for bandpass solutions. <br />
<br />
Plot the solutions, amplitude and phase:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='bandpass.bcal',xaxis='chan',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='bandpass.bcal',xaxis='chan',yaxis='phase',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
Note that phases on ea12 look noiser than on other antennas. This<br />
jitter could indicate bad pointing; note that ea12 had just come back in<br />
the array.<br />
<br />
This step isn't necessary from a calibration perspective, but if you<br />
want to go ahead and check the bandpass calibration on the bandpass<br />
calibrator you can run applycal here. In future we hope to plot<br />
corrected data on-the-fly without this applycal step. Later applycals<br />
will overwrite this one, so no need to worry.<br />
<br />
[[Image:Applybandpass_phase.png|thumb|Phase as a function of channel, plotting the corrected data (after colorize by Antenna2, and Custom and upping "Style" to 3.)]]<br />
<br />
<source lang="python"><br />
applycal(vis='day2_TDEM0003_10s_norx',field='5',<br />
gaintable=['antpos.cal','bandpass.bcal'],<br />
spwmap=[[]],gainfield=['','5'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02')<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02')<br />
</source><br />
<br />
Note that the phase and amplitude as a function of channel are very flat now.<br />
<br />
==Gain Calibration==<br />
<br />
Now that we have a bandpass solution to apply we can solve for the antenna-based phase and amplitude gain calibration. Since the phase changes on a much shorter timescale than the amplitude, we will solve for them separately. In particular, if the phase changes significantly over a scan time, the amplitude would be decorrelated, if the un-corrected phase were averaged over this timescale. Note that we re-solve for the gain solutions of the bandpass calibrator, so we can derive new solutions that are corrected for the bandpass shape. Since the bandpass calibrator will not be used again, this is not strictly necessary, but is useful to check its calibrated flux density for example.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='intphase.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
[[Image:allcal_phaseint2.png|thumb|Plot of phase solutions on an integration time.]]<br />
<br />
Here solint='int' coupled with calmode='p' will derive a single phase solution for each 10 second integration. Note that the bandpass table is applied on-the-fly before solving for the phase solutions, however the bandpass is NOT applied to the data permanently until applycal is run later on.<br />
<br />
Note that quite a few solutions are rejected due to SNR<2 (printed to terminal). For the most part it <br />
is only one or two solutions out of >30 so this isn't too worrying. Take note if you see large numbers of rejected solutions per integration. This is likely an indication that solint is too short for the S/N of the data.<br />
<br />
Now look at the phase solution, and note the obvious scatter within a scan time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='intphase.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
Although solint='int' (i.e. the integration time of 10 seconds) is the best choice to apply before for solving for the amplitude solutions, it is not a good idea to use this to apply to the target. This is because the phase-scatter within a scan can dominate the interpolation between calibrator scans. Instead, we also solve for the phase on the scan time, solint='inf' (but combine='''' '''', since we want one solution per scan) for application to the target later on. '''Unlike the bandpass task,''' for gaincal, the default of the combine parameter is combine='''' ''''.<br />
[[Image:allcal_phaseinf2.png|thumb|Plot of phase solutions on a scan time.]]<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='scanphase.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='scanphase.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
Note that there are no failed solutions here because of the added S/N afforded by the longer solint.<br />
Alternatively, instead of making a separate phase solution for application to the target, one can also run {{smoothcal}} to smooth the solutions derived on the integration time.<br />
<br />
Next we apply the bandpass and solint='int' phase-only calibration solutions on-the-fly to derive amplitude solutions. <br />
Here the use of solint='inf', but combine='''' '''' will result in one solution per scan interval.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='amp.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='ap',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal'],spwmap=[[],[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
[[Image:allcal_ampphase.png|thumb|Plot of residual phase solutions on a scan time]]<br />
<br />
Now let's look at the resulting phase solutions. Since we have taken out the phase as best we can by applying the solint='int' phase-only solution, this plot will give a good idea of the residual phase error. If you see scatter of more than a few degrees here, you should consider going back and looking for more data to flag, particularly bad timeranges etc.<br />
<br />
<source lang="python"><br />
# In CASA <br />
plotcal(caltable='amp.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
Indeed, both antenna ea12 (all times) and ea23 (first 1/3 of observation) show particularly large residual phase noise.<br />
[[Image:allcal_amp.png|thumb|Plot of amplitude solutions on a scan time]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='amp.gcal',xaxis='time',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
Note that the amplitude solutions for ea12 are very low; this is another indication that this antenna is dubious.<br />
<br />
Next we use the flux calibrator (whose flux density was set in {{setjy}} above) to derive the flux of the other calibrators. Note that the flux table REPLACES the amp.gcal in terms of future application of the calibration to the data, i.e. the flux table contains both the amp.gcal and flux scaling. Unlike the gain calibration steps, this is not an incremental table. <br />
<br />
<source lang="python"><br />
# In CASA<br />
fluxscale(vis='day2_TDEM0003_10s_norx',caltable='amp.gcal',<br />
fluxtable='flux.cal',reference='7')<br />
</source><br />
<br />
[[Image:allcal_flux.png|thumb|Plot of flux corrected amplitude solutions.]]<br />
It is a good idea to note down for your records the derived flux densities:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Flux density for J0954+1743 in SpW=0 is: 0.225863 +/- 0.000817704 <br />
(SNR = 276.217, nAnt= 19)<br />
Flux density for J0954+1743 in SpW=1 is: 0.235866 +/- 0.000604897 <br />
(SNR = 389.928, nAnt= 19)<br />
Flux density for J1229+0203 in SpW=0 is: 25.248 +/- 0 <br />
(SNR = inf, nAnt= 19)<br />
Flux density for J1229+0203 in SpW=1 is: 25.008 +/- 0 <br />
(SNR = inf, nAnt= 19)<br />
<br />
</pre><br />
<br />
Obviously, the signal-to-noise for J1229+0203 can't be infinity! This is just an indication that their is only one scan for this source, and we derived a scan based amplitude solution, so there is no variation to calculate. <br />
<br />
Next, check that the flux.cal table looks as expected.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='flux.cal',xaxis='time',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
==Applycal and Inspect==<br />
<br />
Now we apply the calibration to each source, according to which tables are appropriate, and which source should be used to do that particular calibration. For the calibrators, all bandpass solutions come from the bandpass calibrator (id=5), and the phase and amplitude calibration comes from their own solutions. <br />
<br />
'''Note:''' In applycal we set calwt=F. It is very important to turn off this parameter which determines if the weights are calibrated along with the data. Data from antennas with better receiver performance and/or longer integration times should have higher weights, and it can be advantageous to factor this information into the calibration. During the VLA era, meaningful weights were available for each visibility. However, EVLA is not yet recording the information necessary to calculate meaningful weights. Since these data weights are used at the imaging stage you can get strange results from having calwt=T when the input weights are themselves not meaningful, especially for self-calibration on resolved sources (your flux calibrator and target for example). In a few months EVLA data will again have meaningful weights and the default calwt=T will likely again be the best option.<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='2',<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='5',<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','5','5'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='7',<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','7','7'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
For the target we apply the bandpass from id=5, and the calibration from the gain calibrator (id=2):<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='3',<br />
gaintable=['antpos.cal','bandpass.bcal','scanphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
Now inspect the corrected data:<br />
[[Image:applycal_inspect.png|thumb|Plot of calibrated amplitudes over time.]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='')<br />
</source><br />
<br />
This plot shows some data deviating from the average amplitudes. Use methods described above to <br />
mark a region for a small number of deviant data points, and click "Locate". You will find that ea12 is responsible.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='')<br />
</source><br />
<br />
Here we see some problems, with high points. Mark some regions<br />
and locate in {{plotms}} to find out which antennas and in which spws. Pay special<br />
attention to antennas that have been called out already as showing some dubious behavior.<br />
<br />
What you find is that ea07 which we flagged spw=1 above, is also bad for the same timerange in spw=0. This was not obvious in the raw data, because spw=0 was adjusted in the on-line system by a gain attenuator, while spw=1 wasn't. So a lack of power on this antenna can look like very low (and obvious) amplitudes in spw=1 but not for spw=0. Looking carefully you'll see that ea07 is actually pretty noisy throughout.<br />
[[Image:ea12.png|thumb|Plot of antenna ea12 by itself]]<br />
[[Image:ea23.png|thumb|Plot of antenna ea23 by itself]]<br />
<br />
From the locate we also find that ea12 and ea23 show some high points; to see this, replot baselines using each of them alone:<br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='ea12')<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='ea23')<br />
</source><br />
<br />
ea12 needs to be flagged completely its just a bit noisy all around and ea23 is pretty noisy during the first scans between initial and second pointing. Recall that these are antennas we became suspicious of while inspecting the calibration solutions.<br />
<br />
[[Image:target_uvdist.png|thumb|IRC+12216 as a function of uv-distance (after colorize by Antenna2).]]<br />
Now lets see how the target looks. Because the target has resolved structure, its best to look at it as<br />
a function of uvdistance. We'll go ahead and exclude the three antennas we already know have problems.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='!ea07;!ea12;!ea23')<br />
</source><br />
<br />
in "display" tab choose colorize by antenna2; then you can see that the spikes<br />
are caused by a single antenna. Use, zoom, mark, and locate to see which one.<br />
Also look at spw=1.<br />
<br />
Turns out to be ea28; to confirm, replot with antenna=!ea28, and<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='!ea07;!ea12;!ea23;!ea28')<br />
</source><br />
<br />
To see if it's restricted to a certain time<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='ea28')<br />
</source><br />
<br />
<br />
Baselines with ea28 clearly show issues until about two-thirds of the way through the observation. <br />
Plot another distant antenna to compare. We will go ahead and flag it all, since its hanging far out on the north<br />
arm by itself.<br />
<br />
The additional data we've identified as bad need to be flagged, and then all the calibration steps will need to be run<br />
again.<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='day2_TDEM0003_10s_norx',<br />
field=['',''],<br />
spw=['',''],<br />
antenna=['ea07,ea12,ea28','ea07,ea23'],<br />
timerange=['','03:21:40~04:10:00'])<br />
</source><br />
<br />
==Redo Calibration after more Flagging==<br />
<br />
After flagging, you'll need to repeat the calibration steps above. Here, we append _redo to the table names to distinguish them from the first round, in case we want to compare with previous versions. <br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='bpphase_redo.gcal',<br />
field='5',spw='0~1:20~40',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='day2_TDEM0003_10s_norx',caltable='bandpass_redo.bcal',<br />
field='5',<br />
refant='ea02',solint='inf',solnorm=T,<br />
gaintable=['bpphase_redo.gcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='intphase_redo.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass_redo.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='scanphase_redo.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass_redo.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='amp_redo.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='ap',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal'],<br />
spwmap=[[],[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA <br />
fluxscale(vis='day2_TDEM0003_10s_norx',caltable='amp_redo.gcal',<br />
fluxtable='flux_redo.cal',reference='7')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
Flux density for J0954+1743 in SpW=0 is: 0.235345 +/- 0.000879422 <br />
(SNR = 267.613, nAnt= 16)<br />
Flux density for J0954+1743 in SpW=1 is: 0.241996 +/- 0.000930228 <br />
(SNR = 260.147, nAnt= 16)<br />
Flux density for J1229+0203 in SpW=0 is: 25.2479 +/- 0 <br />
(SNR = inf, nAnt= 16)<br />
Flux density for J1229+0203 in SpW=1 is: 24.9907 +/- 0 <br />
(SNR = inf, nAnt= 16)<br />
</pre><br />
<br />
Feel free to pause here and remake the calibration solution plots from above, just be sure to put in the revised table names.<br />
<br />
==Redo Applycal and Inspect==<br />
<br />
Now, apply all the new calibrations, which will overwrite the old ones. These commands are identical to those above, with the exception of the _redo part of each calibration filename.<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='2',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='5',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','5','5'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
[[Image:gaincal_corrflag.png|thumb|Gain calibrator after further flagging and recalibration]]<br />
[[Image:target_corrflag.png|thumb|IRC+10216 after further flagging and recalibration (after selecting colorize by spw).]]<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='7',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','7','7'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='3',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','scanphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
Now you can inspect the calibrated data again. Except for random scatter things look pretty good.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='')<br />
</source><br />
<br />
Lets check the target again, looking at both spws, and selecting "Display" colorize by spw. You can use the Mark and Locate buttons to assess that the remaining scatter seems random, i.e. no particular antenna or time range appears to be responsible.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0~1:4~60',antenna='')<br />
</source><br />
<br />
==Split==<br />
<br />
Now we split the data into individual files. This is not strictly necessary, as you can select the appropriate fields in later clean stages, but it is safer in case for example you get confused with later processing and want to fall back to this point (this is especially a good idea if you plan to do continuum subtraction or self calibration later on). It also makes smaller individual files in case you want to copy to another machine or colleague.<br />
<br />
Here, we split off the data for the phase calibrator and the target:<br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='day2_TDEM0003_10s_norx',outputvis='J0954',<br />
field='2')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='day2_TDEM0003_10s_norx',outputvis='IRC10216',<br />
field='3')<br />
</source><br />
<br />
To reinitialize the scratch columns for use by later tasks, we need to run clearcal for both new datasets<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='J0954')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='IRC10216')<br />
</source><br />
<br />
This concludes the calibration phase of the data reductions. The tutorial continues with continuum subtraction, imaging, and image analysis in <br />
[[EVLA Spectral Line Imaging Analysis IRC+10216]].<br />
<br />
[[Main Page | &#8629; '''CASAguides''']]<br />
<br />
--[[User:Cbrogan|Crystal Brogan]]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Spectral_Line_Calibration_IRC%2B10216&diff=3699EVLA Spectral Line Calibration IRC+102162010-06-03T20:15:15Z<p>Jgallimo: /* The Observing Log, Antenna Position Corrections, and other Calibration "Priors" */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]][[Category:Spectral Line]]<br />
<br />
<br />
<pre style="background-color: #FFFF00;"><br />
This tutorial is under construction. There are several things still to be added <br />
<br />
For the time being (until release candidate is built) you want to run this on casapy-test<br />
<br />
</pre><br />
<br />
== Overview ==<br />
This tutorial describes the data reduction for two spectral lines observed toward the AGB star IRC+10216. This carbon star, which is a few times more massive than our sun, is nearing the end of its life and is thought to be in the process of forming a planetary nebula. <br />
<br />
In this EVLA OSRO1 mode observation one subband was observed in each of two basebands, the subbands were centered on the HC3N and SiS lines near 36 GHz. The raw data were loaded into CASA with {{importevla}}, where zero and shadowed data were flagged. Then the data were "{{split}}", so we could average from the native 1 second integrations to 10 seconds, select only antennas with Ka-band receivers, and select only spectral windows (called spw in CASA) with Ka-band data. This produces a significantly smaller dataset for processing.<br />
<br />
The post-split averaged data can be downloaded from http://casa.nrao.edu/Data/EVLA/IRC10216/day2_TDEM0003_10s_norx.tar<br />
<br />
Once the download is complete, unpack the file:<br />
<br />
<source lang='bash'><br />
# in a terminal, outside of CASA:<br />
tar -xvf day2_TDEM0003_10s_norx.tar<br />
</source><br />
<br />
== The Observing Log, Antenna Position Corrections, and other Calibration "Priors"==<br />
<br />
For all EVLA observations, the operators keep an observing log. You can look at<br />
the observing logs at the observing log [[http://www.vla.nrao.edu/cgi-bin/oplogs.cgi website]]. Pertinent information from this observation are repeated below. <br />
<pre style="background-color: #E0FFFF;"><br />
INFORMATION FROM OBSERVING LOG:<br />
Date of the observation: 26-April-2010<br />
There are no Ka-band receivers on ea11, ea13, ea14, ea16, ea17, ea18, ea26 <br />
Antennas ea10, ea06 are out of the array<br />
Antenna ea12 is newly back<br />
The pointing is often bad on ea15<br />
Antennas ea10, ea12, ea22 do not have good baseline positions<br />
</pre><br />
<br />
As mentioned in the log, antennas ea10, ea12, and ea22 do not have good baseline positions.<br />
Antenna ea10 was not in the array, but for the other two antennas we need to check for<br />
any improved baseline positions that were derived after the observations were taken.<br />
<br />
In CASA, we need to insert these corrections by hand using '''{{gencal}}'''. The resulting table will need to be supplied as a "prior" calibration to all subsequent calibration steps. The corrections can be ascertained from the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections page]. Be sure to carefully read to the bottom of that <br />
webpage to see how to calculate the additive corrections. The current case is simple as there is only a single correction for each antenna. In the future we will implement an automated lookup of the corrections. <br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='day2_TDEM0003_10s_norx',caltable='antpos.cal',<br />
caltype='antpos',<br />
antenna='ea12,ea22',<br />
parameter=[-0.0072,0.0045,-0.0017, -0.0220,0.0040,-0.0190])<br />
</source><br />
<br />
'''Please note: '''if you are reducing VLA data taken before March 1, 2010, you need to set caltype='antposvla'.<br />
<br />
<br />
<br />
There are two other types of "priors" that we will need to apply at each calibration stage described below:<br />
<br />
(1) Opacity correction -- in the near future the opacity will be calculated from the weather<br />
data and an atmospheric model, or alternatively from a tipping scan, or a combination of<br />
both. For now we use a cannonical value for the zenith opacity based on the weather on that day, which at this<br />
frequency (36 GHz) is about 0.03 on the best days. We will use a zenith opacity of <math>\tau_z</math>=0.04. The zenith opacity is then corrected for <br />
the elevation of the data automatically using <math>e^{[-\csc(el)\tau_z]}</math>.<br />
<br />
(2) Gaincurve -- the gaincurve describes how each antenna behaves as a function of elevation, for each receiver band. Currently only gaincurves for the VLA/EVLA are available. This option should not be used <br />
with any other telescopes.<br />
<br />
==Initial Inspection and Flagging==<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='day2_TDEM0003_10s_norx')<br />
</source><br />
<br />
Below we have cut and pasted the most relevant output from the logger.<br />
<br />
<pre style="background-color: #fffacd;"><br />
Fields: 4<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
2 D J0954+1743 09:54:56.8236 +17.43.31.2224 J2000 2 65326 <br />
3 NONE IRC+10216 09:47:57.3820 +13.16.40.6600 J2000 3 208242 <br />
5 F J1229+0203 12:29:06.6997 +02.03.08.5982 J2000 5 10836 <br />
7 E J1331+3030 13:31:08.2880 +30.30.32.9589 J2000 7 5814 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (2 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
0 64 TOPO 36387.2295 125 8000 36387.2295 RR RL LR LL <br />
1 64 TOPO 36304.542 125 8000 36304.542 RR RL LR LL <br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1008+0730 0 0.03639232 -0.026 <br />
0 J1008+0730 1 0.03639232 -0.026 <br />
2 J0954+1743 0 0.03639232 -0.026 <br />
2 J0954+1743 1 0.03639232 -0.026 <br />
3 IRC+10216 0 0.03639232 -0.026 <br />
3 IRC+10216 1 0.03639232 -0.026 <br />
5 J1229+0203 0 0.03639232 -0.026 <br />
5 J1229+0203 1 0.03639232 -0.026 <br />
7 J1331+3030 0 0.03639232 -0.026 <br />
7 J1331+3030 1 0.03639232 -0.026 <br />
Antennas: 19:<br />
ID Name Station Diam. Long. Lat. <br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
8 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
9 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
10 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
11 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
12 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
13 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
14 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
15 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
16 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
17 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
18 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
</pre><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Summary of Observing Strategy<br />
Gain Calibrator: J0954+1743 field id=2<br />
Bandpass Calibrator: J1229+0203 field id=5<br />
Flux Calibrator: J1331+3030 (3C286) field id=7<br />
Target: IRC+10216 field id=3<br />
Ka-band spws = 0,1<br />
</pre> <br />
<br />
[[Image:Ant_locations.png|thumb|Antenna locations from running plotants ]]<br />
Look at a graphical plot of the antenna locations and save hardcopy<br />
in case you want it later. This will be useful for picking a reference antenna --<br />
typically a good choice is an antenna close to the center of the array. Unless it <br />
shows problems after inspection of the data, we provisionally chose ea02.<br />
<br />
[[Image:elevationvstime.png|thumb|Elevation as a function of time (after selecting colorize by field).]]<br />
<source lang="python"><br />
# In CASA<br />
plotants(vis='day2_TDEM0003_10s_norx',figfile='ant_locations.png')<br />
</source><br />
<br />
Next, let's look at the elevation as a function of time for all sources. It's not the case for these data, but if the elevation is very low (usually at start or end of track) you may want to flag. Also, how near in elevation your flux calibrator is to your target will impact your ultimate absolute flux calibration accuracy. Unfortunately, the target and flux calibrator are not particularly well-matched for this observation, as y ou can show by plotting the elevation for each source:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',<br />
xaxis='time',yaxis='elevation',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60')<br />
</source><br />
<br />
Thus we are strongly dependent on the opacity and gaincurve corrections to get the flux scale right for these data. (This is something to keep in mind when planning observations!)<br />
<br />
[[Image:plotallfields.png|thumb|Result of plotms after selecting colorize by field]]<br />
[[Image:Zoom1_mark.png|thumb|Zooming in and marking region (hatched box)]]<br />
<br />
Next,let's look at all the source amplitudes as a function of time.<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60')<br />
</source><br />
<br />
Select the "Display" tab and colorize by field, and click Plot button. <br />
<br />
<br />
Now zoom in on the region very near zero amplitude for sources J0954+1743 and IRC+10216. To zoom, select the <br />
Zoom tool in lower left corner of the {{plotms}} GUI, then you can left click to draw a box. <br />
Look for the low values (you may want to zoom a few times to really see the suspect points clearly). Now use the Mark Region and Locate buttons (located along the bottom of the GUI) to see which antenna is causing problems. Since all the "located" baselines include ea12, this is the responsible antenna.<br />
<br />
<pre style="background-color: #98FB98;"><br />
IMPORTANT NOTES ON PLOTMS:<br />
<br />
* When using the locate button it is important to have only selected a modest number <br />
of points with the mark region tool (see example of marked region in the thumnail), <br />
otherwise the response will be very slow and possibly hang the tool <br />
(all of the information will be output to your terminal window, not the logger). <br />
<br />
* Throughout the tutorial, when you are done marking/locate use the Clear Regions <br />
tool to get rid of the marked box before plotting other things. <br />
<br />
* After flagdata command flagging, you have to force a complete reload of the cache <br />
to look at the same plot again with the new flags applied. To do this change anything <br />
in the plotms GUI (the colorize parameter, antenna, spw, anything) and hit the <br />
plot button.<br />
<br />
* If the plotms tool does get hung during a plot try clicking the cancel button on the <br />
load progress GUI, and/or if you see a "table locked" message try typing <br />
clearstat on the CASA command line.<br />
<br />
* Occasionally plotms will get into a strange state that you cannot clear from inside. <br />
We are working on these issues, but for now, when all else fails, exit from casapy and <br />
restart. <br />
<br />
</pre> <br />
<br />
Now click the unmark region button, and then go back to the zoom button to zoom in further to note exactly what the time range is: 03:41:00~04:10:00.<br />
<br />
Check the other sideband by changing spw to 1:4~60. You will have to<br />
rezoom. If you have trouble, click on the Mark icon and then back to<br />
zoom. In spw=1, ea07 is bad from the beginning until after next<br />
pointing run: 03:21:40~04:10:00. To see this, compare the amplitudes when antenna is set to 'ea07' and when it is set to one of the other antennas, such as 'ea08'.<br />
<br />
If you set antenna to 'ea12' and zoom in on this intial timerange, you can also see that ea12 is bad during the same time range as for spw 0. You can also see this by entering '!ea07' for antenna, which removes ea07 from the plot (in CASA selection, ! deselects). <br />
<br />
We can set up a flagging command to get both bad antennas for the<br />
appropriate time and spw:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='day2_TDEM0003_10s_norx',<br />
field=['2,3','2,3'],<br />
spw=['','1'],<br />
antenna=['ea12','ea07'],<br />
timerange=['03:41:00~04:10:00','03:21:40~04:10:00'])<br />
</source><br />
<br />
Note that because the chosen timerange is limited to fields 2 and 3,the field parameter is not really<br />
needed; however, flagdata will run fastest if you put as many constraints as possible.<br />
<br />
Now remove the !ea07 from antenna and replot both spw, zooming in to<br />
be sure that all obviously low points are gone. Also zoom in and<br />
check 3C286 (J1229+0203 is already obvious because it is so bright!). <br />
<br />
[[Image:IRC10216_uvdist1.png|thumb|Amplitude vs. uv-distance for IRC+10216, both spw (after colorize by spw)]]<br />
<br />
Lets look more closely at IRC+10216:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0~1:4~60')<br />
</source><br />
<br />
Go to the "display" tab and choose colorize by spw. You can see a<br />
that there are some noisy high points. But now try<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0~1:4~60')<br />
</source><br />
<br />
Most of the high points on IRC+10216 are due to large scale emission on short baselines, but there is still some noisy stuff -- for a target like this with extended emission its best to wait until later to decide what to do about it. We will not be able to get adequate calibration for antennas that are truly bad (even if they don't stand out here) so these will be obvious later.<br />
<br />
==Setup the Model for the Flux Calibrator==<br />
<br />
Next, we set the model for the flux calibrator. Depending on your observing frequency and angular resolution you can do this several ways. In the past, one typically used a point source (constant flux) model for <br />
the flux calibrator, possibly with a uvrange cutoff if necessary. More recently for the VLA/EVLA, model images for the most common flux calibrators have been made available for use in cases where the sources are somewhat resolved. This is most likely to be true at higher frequencies and at higher resolutions (more extended arrays). Thus below we use the K-band model image for these Ka-band observations. Because one model image is typically available per receiver band (in this case the model for Ka-band is the same as that of K-band), the frequency of the model image probably does not match exactly the frequency of your observations, as is certainly the case here. In that case, the task scales the total flux in the model image to that appropriate for your observing frequency according to the calibrators flux as a function of frequency model, and reports this number in the logger -- it is a good idea to save this information for your records.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='day2_TDEM0003_10s_norx',field='7',spw='0~1',<br />
modimage='/usr/lib64/casapy/data/nrao/VLA/CalModels/3C286_K.im')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
The logger output for each spw is:<br />
setjy J1331+3030 spwid= 0 [I=1.692, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
setjy J1331+3030 spwid= 1 [I=1.695, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
</pre><br />
<br />
The modimage location used in the command is appropriate for running CASA at the AOC. If you are running elsewhere (laptop or Mac), in a terminal type<br />
<br />
<source lang='bash'><br />
# in a terminal, outside of CASA:<br />
locate 3C286_K.im <br />
</source><br />
<br />
to find where the models live (the models are always shipped with CASA).<br />
<br />
==Bandpass==<br />
<br />
Before determining the bandpass solution, we need to inspect phase and amplitude<br />
variations with time and frequency on the bandpass calibrator to<br />
decide how best to proceed. We limit the number of antennas to make<br />
the plot easier to see. We chose ea02 as it seems like a good<br />
candidate for the reference antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='phase',correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02&ea23')<br />
</source><br />
[[Image:Nobandpass_phase.png|thumb|Phase as a function of channel for ea02 (after colorize by Antenna2, and Custom and upping "Style" to 3.)]]<br />
The phase variation is modest ~10 degrees. Now expand to all antennas with ea02 and <br />
select colorize by Antenna2, then hit the "Plot" button.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='phase',correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02')<br />
</source><br />
[[Image:Nobandpass_phasetime.png|thumb|Phase as a function of time for all baselines with antenna ea02 (after colorize by Antenna2, and Custom and upping "Style" to 3.)]]<br />
Go to the "display" tab and chose colorize by antenna2. From this<br />
you can see that the phase variation across the bandpass is<br />
modest. Next check LL, and spw=1, both correlations. Also check<br />
other antennas if you like.<br />
<br />
Now look at the phase as a function of time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='time',yaxis='phase',correlation='RR',<br />
avgchannel='64',spw='0:4~60',antenna='ea02&ea23')<br />
</source><br />
<br />
<br />
Expand to all antennas with ea02<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='time',yaxis='phase',correlation='RR',<br />
avgchannel='64',spw='0:4~60',antenna='ea02')<br />
</source><br />
<br />
Go to the "display" tab and chose colorize by antenna2, you may also want to select "Custom" under "unflagged points symbol" and then change Style from "2" to "3".<br />
<br />
You can see that the phase variations are smooth, but do vary<br />
significantly over the 5 minutes of observation -- in most cases by<br />
a few 10s of degrees. Zoom in to see this better if you want.<br />
<br />
The conclusion from this investigation is that you need to correct<br />
the phase variations with time before solving for the bandpass to<br />
prevent decorrelation of the vector averaged bandpass<br />
solution. Since the phase variation as a function of channel is<br />
modest, you can average over several channels to increase the signal<br />
to noise of the phase vs. time solution. If the phase variation as a<br />
function of channel is larger you may need to use only a few<br />
channels to prevent introducing delay-based closure errors as can happen from averaging over<br />
non-bandpass corrected channels with large phase variations.<br />
<br />
<br />
Since the bandpass calibrator is quite strong we do the phase-only<br />
solution on the integration time of 10 seconds (solint='int').<br />
<br />
[[Image:Prebp_phasecal2.png|thumb|Phase only calibration before bandpass. The 4 lines are both polarizations in both spw, unfortunately two of them get the same color green at the moment.]]<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='bpphase.gcal',<br />
field='5',spw='0~1:20~40',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
gaintable=['antpos.cal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
Plot the solutions<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='bpphase.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
These solutions will appear in the CASA plotter gui. If you closed it after plotting the antennas above, it should reopen. If it is still open from before, the new plots should just appear. After you are done looking at the first set of plots, push the "Next" button on the GUI to see the next set of antennas.<br />
<br />
Next we can apply this phase solution on the fly while determining<br />
the bandpass solutions on the timescale of the bandpass calibrator scan (solint='inf'). <br />
<br />
[[Image:Bandpass_amp.png|thumb|Amplitude Bandpass solutions]]<br />
[[Image:Bandpass_phase1.png|thumb|Phase Bandpass solutions]]<br />
<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='day2_TDEM0003_10s_norx',caltable='bandpass.bcal',field='5',<br />
refant='ea02',solint='inf',solnorm=T,<br />
gaintable=['antpos.cal','bpphase.gcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
'''A few words about solint and combine:'''<br />
<br />
The use of solint='inf' in {{bandpass}} will derive one bandpass<br />
solution for the whole J1229+0203 scan. Note that if there had been two observations of the bandpass calibrator (for example), this command would have combined the data from both scans to form one bandpass solution, because the default of the combine parameter '''for {{bandpass}}''' is combine='scan'. To solve for one bandpass for each bandpass calibrator scan you would also need to include combine='''' '''' in the bandpass call. In all calibration tasks, regardless of solint, scan boundaries are only crossed when combine='scan'. Likewise, field (spw) boundaries are only crossed if combine='field' (combine='spw'), the latter two are not generally good ideas for bandpass solutions. <br />
<br />
Plot the solutions, amplitude and phase:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='bandpass.bcal',xaxis='chan',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='bandpass.bcal',xaxis='chan',yaxis='phase',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
Note that phases on ea12 look noiser than on other antennas. This<br />
jitter could indicate bad pointing; note that ea12 had just come back in<br />
the array.<br />
<br />
This step isn't necessary from a calibration perspective, but if you<br />
want to go ahead and check the bandpass calibration on the bandpass<br />
calibrator you can run applycal here. In future we hope to plot<br />
corrected data on-the-fly without this applycal step. Later applycals<br />
will overwrite this one, so no need to worry.<br />
<br />
[[Image:Applybandpass_phase.png|thumb|Phase as a function of channel, plotting the corrected data (after colorize by Antenna2, and Custom and upping "Style" to 3.)]]<br />
<br />
<source lang="python"><br />
applycal(vis='day2_TDEM0003_10s_norx',field='5',<br />
gaintable=['antpos.cal','bandpass.bcal'],<br />
spwmap=[[]],gainfield=['','5'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02')<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02')<br />
</source><br />
<br />
Note that the phase and amplitude as a function of channel are very flat now.<br />
<br />
==Gain Calibration==<br />
<br />
Now that we have a bandpass solution to apply we can solve for the antenna-based phase and amplitude gain calibration. Since the phase changes on a much shorter timescale than the amplitude, we will solve for them separately. In particular, if the phase changes significantly over a scan time, the amplitude would be decorrelated, if the un-corrected phase were averaged over this timescale. Note that we re-solve for the gain solutions of the bandpass calibrator, so we can derive new solutions that are corrected for the bandpass shape. Since the bandpass calibrator will not be used again, this is not strictly necessary, but is useful to check its calibrated flux density for example.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='intphase.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
[[Image:allcal_phaseint2.png|thumb|Plot of phase solutions on an integration time.]]<br />
<br />
Here solint='int' coupled with calmode='p' will derive a single phase solution for each 10 second integration. Note that the bandpass table is applied on-the-fly before solving for the phase solutions, however the bandpass is NOT applied to the data permanently until applycal is run later on.<br />
<br />
Note that quite a few solutions are rejected due to SNR<2 (printed to terminal). For the most part it <br />
is only one or two solutions out of >30 so this isn't too worrying. Take note if you see large numbers of rejected solutions per integration. This is likely an indication that solint is too short for the S/N of the data.<br />
<br />
Now look at the phase solution, and note the obvious scatter within a scan time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='intphase.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
Although solint='int' (i.e. the integration time of 10 seconds) is the best choice to apply before for solving for the amplitude solutions, it is not a good idea to use this to apply to the target. This is because the phase-scatter within a scan can dominate the interpolation between calibrator scans. Instead, we also solve for the phase on the scan time, solint='inf' (but combine='''' '''', since we want one solution per scan) for application to the target later on. '''Unlike the bandpass task,''' for gaincal, the default of the combine parameter is combine='''' ''''.<br />
[[Image:allcal_phaseinf2.png|thumb|Plot of phase solutions on a scan time.]]<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='scanphase.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='scanphase.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
Note that there are no failed solutions here because of the added S/N afforded by the longer solint.<br />
Alternatively, instead of making a separate phase solution for application to the target, one can also run {{smoothcal}} to smooth the solutions derived on the integration time.<br />
<br />
Next we apply the bandpass and solint='int' phase-only calibration solutions on-the-fly to derive amplitude solutions. <br />
Here the use of solint='inf', but combine='''' '''' will result in one solution per scan interval.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='amp.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='ap',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal'],spwmap=[[],[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
[[Image:allcal_ampphase.png|thumb|Plot of residual phase solutions on a scan time]]<br />
<br />
Now let's look at the resulting phase solutions. Since we have taken out the phase as best we can by applying the solint='int' phase-only solution, this plot will give a good idea of the residual phase error. If you see scatter of more than a few degrees here, you should consider going back and looking for more data to flag, particularly bad timeranges etc.<br />
<br />
<source lang="python"><br />
# In CASA <br />
plotcal(caltable='amp.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
Indeed, both antenna ea12 (all times) and ea23 (first 1/3 of observation) show particularly large residual phase noise.<br />
[[Image:allcal_amp.png|thumb|Plot of amplitude solutions on a scan time]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='amp.gcal',xaxis='time',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
Note that the amplitude solutions for ea12 are very low; this is another indication that this antenna is dubious.<br />
<br />
Next we use the flux calibrator (whose flux density was set in {{setjy}} above) to derive the flux of the other calibrators. Note that the flux table REPLACES the amp.gcal in terms of future application of the calibration to the data, i.e. the flux table contains both the amp.gcal and flux scaling. Unlike the gain calibration steps, this is not an incremental table. <br />
<br />
<source lang="python"><br />
# In CASA<br />
fluxscale(vis='day2_TDEM0003_10s_norx',caltable='amp.gcal',<br />
fluxtable='flux.cal',reference='7')<br />
</source><br />
<br />
[[Image:allcal_flux.png|thumb|Plot of flux corrected amplitude solutions.]]<br />
It is a good idea to note down for your records the derived flux densities:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Flux density for J0954+1743 in SpW=0 is: 0.225863 +/- 0.000817704 <br />
(SNR = 276.217, nAnt= 19)<br />
Flux density for J0954+1743 in SpW=1 is: 0.235866 +/- 0.000604897 <br />
(SNR = 389.928, nAnt= 19)<br />
Flux density for J1229+0203 in SpW=0 is: 25.248 +/- 0 <br />
(SNR = inf, nAnt= 19)<br />
Flux density for J1229+0203 in SpW=1 is: 25.008 +/- 0 <br />
(SNR = inf, nAnt= 19)<br />
<br />
</pre><br />
<br />
Obviously, the signal-to-noise for J1229+0203 can't be infinity! This is just an indication that their is only one scan for this source, and we derived a scan based amplitude solution, so there is no variation to calculate. <br />
<br />
Next, check that the flux.cal table looks as expected.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='flux.cal',xaxis='time',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
==Applycal and Inspect==<br />
<br />
Now we apply the calibration to each source, according to which tables are appropriate, and which source should be used to do that particular calibration. For the calibrators, all bandpass solutions come from the bandpass calibrator (id=5), and the phase and amplitude calibration comes from their own solutions. <br />
<br />
'''Note:''' In applycal we set calwt=F. It is very important to turn off this parameter which determines if the weights are calibrated along with the data. Data from antennas with better receiver performance and/or longer integration times should have higher weights, and it can be advantageous to factor this information into the calibration. During the VLA era, meaningful weights were available for each visibility. However, EVLA is not yet recording the information necessary to calculate meaningful weights. Since these data weights are used at the imaging stage you can get strange results from having calwt=T when the input weights are themselves not meaningful, especially for self-calibration on resolved sources (your flux calibrator and target for example). In a few months EVLA data will again have meaningful weights and the default calwt=T will likely again be the best option.<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='2',<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='5',<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','5','5'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='7',<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','7','7'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
For the target we apply the bandpass from id=5, and the calibration from the gain calibrator (id=2):<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='3',<br />
gaintable=['antpos.cal','bandpass.bcal','scanphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
Now inspect the corrected data:<br />
[[Image:applycal_inspect.png|thumb|Plot of calibrated amplitudes over time.]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='')<br />
</source><br />
<br />
This plot shows some data deviating from the average amplitudes. Use methods described above to <br />
mark a region for a small number of deviant data points, and click "Locate". You will find that ea12 is responsible.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='')<br />
</source><br />
<br />
Here we see some problems, with high points. Mark some regions<br />
and locate in {{plotms}} to find out which antennas and in which spws. Pay special<br />
attention to antennas that have been called out already as showing some dubious behavior.<br />
<br />
What you find is that ea07 which we flagged spw=1 above, is also bad for the same timerange in spw=0. This was not obvious in the raw data, because spw=0 was adjusted in the on-line system by a gain attenuator, while spw=1 wasn't. So a lack of power on this antenna can look like very low (and obvious) amplitudes in spw=1 but not for spw=0. Looking carefully you'll see that ea07 is actually pretty noisy throughout.<br />
[[Image:ea12.png|thumb|Plot of antenna ea12 by itself]]<br />
[[Image:ea23.png|thumb|Plot of antenna ea23 by itself]]<br />
<br />
From the locate we also find that ea12 and ea23 show some high points; to see this, replot baselines using each of them alone:<br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='ea12')<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='ea23')<br />
</source><br />
<br />
ea12 needs to be flagged completely its just a bit noisy all around and ea23 is pretty noisy during the first scans between initial and second pointing. Recall that these are antennas we became suspicious of while inspecting the calibration solutions.<br />
<br />
[[Image:target_uvdist.png|thumb|IRC+12216 as a function of uv-distance (after colorize by Antenna2).]]<br />
Now lets see how the target looks. Because the target has resolved structure, its best to look at it as<br />
a function of uvdistance. We'll go ahead and exclude the three antennas we already know have problems.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='!ea07;!ea12;!ea23')<br />
</source><br />
<br />
in "display" tab choose colorize by antenna2; then you can see that the spikes<br />
are caused by a single antenna. Use, zoom, mark, and locate to see which one.<br />
Also look at spw=1.<br />
<br />
Turns out to be ea28; to confirm, replot with antenna=!ea28, and<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='!ea07;!ea12;!ea23;!ea28')<br />
</source><br />
<br />
To see if it's restricted to a certain time<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='ea28')<br />
</source><br />
<br />
<br />
Baselines with ea28 clearly show issues until about two-thirds of the way through the observation. <br />
Plot another distant antenna to compare. We will go ahead and flag it all, since its hanging far out on the north<br />
arm by itself.<br />
<br />
The additional data we've identified as bad need to be flagged, and then all the calibration steps will need to be run<br />
again.<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='day2_TDEM0003_10s_norx',<br />
field=['',''],<br />
spw=['',''],<br />
antenna=['ea07,ea12,ea28','ea07,ea23'],<br />
timerange=['','03:21:40~04:10:00'])<br />
</source><br />
<br />
==Redo Calibration after more Flagging==<br />
<br />
After flagging, you'll need to repeat the calibration steps above. Here, we append _redo to the table names to distinguish them from the first round, in case we want to compare with previous versions. <br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='bpphase_redo.gcal',<br />
field='5',spw='0~1:20~40',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='day2_TDEM0003_10s_norx',caltable='bandpass_redo.bcal',<br />
field='5',<br />
refant='ea02',solint='inf',solnorm=T,<br />
gaintable=['bpphase_redo.gcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='intphase_redo.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass_redo.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='scanphase_redo.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass_redo.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='amp_redo.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='ap',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal'],<br />
spwmap=[[],[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA <br />
fluxscale(vis='day2_TDEM0003_10s_norx',caltable='amp_redo.gcal',<br />
fluxtable='flux_redo.cal',reference='7')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
Flux density for J0954+1743 in SpW=0 is: 0.235345 +/- 0.000879422 <br />
(SNR = 267.613, nAnt= 16)<br />
Flux density for J0954+1743 in SpW=1 is: 0.241996 +/- 0.000930228 <br />
(SNR = 260.147, nAnt= 16)<br />
Flux density for J1229+0203 in SpW=0 is: 25.2479 +/- 0 <br />
(SNR = inf, nAnt= 16)<br />
Flux density for J1229+0203 in SpW=1 is: 24.9907 +/- 0 <br />
(SNR = inf, nAnt= 16)<br />
</pre><br />
<br />
Feel free to pause here and remake the calibration solution plots from above, just be sure to put in the revised table names.<br />
<br />
==Redo Applycal and Inspect==<br />
<br />
Now, apply all the new calibrations, which will overwrite the old ones. These commands are identical to those above, with the exception of the _redo part of each calibration filename.<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='2',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='5',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','5','5'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
[[Image:gaincal_corrflag.png|thumb|Gain calibrator after further flagging and recalibration]]<br />
[[Image:target_corrflag.png|thumb|IRC+10216 after further flagging and recalibration (after selecting colorize by spw).]]<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='7',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','7','7'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='3',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','scanphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
Now you can inspect the calibrated data again. Except for random scatter things look pretty good.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='')<br />
</source><br />
<br />
Lets check the target again, looking at both spws, and selecting "Display" colorize by spw. You can use the Mark and Locate buttons to assess that the remaining scatter seems random, i.e. no particular antenna or time range appears to be responsible.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0~1:4~60',antenna='')<br />
</source><br />
<br />
==Split==<br />
<br />
Now we split the data into individual files. This is not strictly necessary, as you can select the appropriate fields in later clean stages, but it is safer in case for example you get confused with later processing and want to fall back to this point (this is especially a good idea if you plan to do continuum subtraction or self calibration later on). It also makes smaller individual files in case you want to copy to another machine or colleague.<br />
<br />
Here, we split off the data for the phase calibrator and the target:<br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='day2_TDEM0003_10s_norx',outputvis='J0954',<br />
field='2')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='day2_TDEM0003_10s_norx',outputvis='IRC10216',<br />
field='3')<br />
</source><br />
<br />
To reinitialize the scratch columns for use by later tasks, we need to run clearcal for both new datasets<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='J0954')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='IRC10216')<br />
</source><br />
<br />
This concludes the calibration phase of the data reductions. The tutorial continues with continuum subtraction, imaging, and image analysis in <br />
[[EVLA Spectral Line Imaging Analysis IRC+10216]].<br />
<br />
[[Main Page | &#8629; '''CASAguides''']]<br />
<br />
--[[User:Cbrogan|Crystal Brogan]]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Karl_G._Jansky_VLA_Tutorials&diff=3698Karl G. Jansky VLA Tutorials2010-06-03T19:57:45Z<p>Jgallimo: </p>
<hr />
<div>* Twelfth Synthesis Imaging Workshop Tutorials ('''coming soon, these tutorials require CASA 3.0.2 which is not available until early June''')<br />
** EVLA Ka-Band (36 GHz) Spectral Line Observations of the AGB Star ([http://simbad.u-strasbg.fr/simbad/sim-id?Ident=CW+Leo&NbIdent=1&Radius=2&Radius.unit=arcmin&submit=submit+id IRC +10216])<br />
*** Data Calibration: [[EVLA Spectral Line Calibration IRC+10216]]<br />
*** Data Imaging and Analysis: [[EVLA Spectral Line Imaging Analysis IRC+10216]]<br />
** EVLA 6cm Continuum Mosaic of the Supernova Remnant ([http://simbad.u-strasbg.fr/simbad/sim-id?Ident=3C+391&NbIdent=1&Radius=2&Radius.unit=arcmin&submit=submit+id 3C 391])<br />
*** Basic Data Calibration and Imaging: [[EVLA Continuum Tutorial 3C391]]<br />
*** Advanced Topics (Image Analysis, Polarization, Self-calibration): [[EVLA Advanced Topics 3C391]]<br />
*** Appendix: [[Obtaining EVLA Data: 3C 391 Example]]<br />
<br />
* [[Imaging Flanking Fields]]<br />
<br />
* Transient reduction pipeline</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Karl_G._Jansky_VLA_Tutorials&diff=3697Karl G. Jansky VLA Tutorials2010-06-03T19:57:15Z<p>Jgallimo: </p>
<hr />
<div>* Twelfth Synthesis Imaging Workshop Tutorials ('''coming soon, these tutorials require CASA 3.0.2 which is not available until early June''')<br />
** EVLA Ka-Band (36 GHz) Spectral Line Observations of the AGB Star ([http://simbad.u-strasbg.fr/simbad/sim-id?Ident=CW+Leo&NbIdent=1&Radius=2&Radius.unit=arcmin&submit=submit+id IRC +10216])<br />
*** Data Calibration: [[EVLA Spectral Line Calibration IRC+10216]]<br />
*** Data Imaging and Analysis: [[EVLA Spectral Line Imaging Analysis IRC+10216]]<br />
** EVLA 6cm Continuum Mosaic of the Supernova Remnant [http://simbad.u-strasbg.fr/simbad/sim-id?Ident=3C+391&NbIdent=1&Radius=2&Radius.unit=arcmin&submit=submit+id 3C 391]<br />
*** Basic Data Calibration and Imaging: [[EVLA Continuum Tutorial 3C391]]<br />
*** Advanced Topics (Image Analysis, Polarization, Self-calibration): [[EVLA Advanced Topics 3C391]]<br />
*** Appendix: [[Obtaining EVLA Data: 3C 391 Example]]<br />
<br />
* [[Imaging Flanking Fields]]<br />
<br />
* Transient reduction pipeline</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=CARMA_spectral_line_mosaic_M99_3.1&diff=3696CARMA spectral line mosaic M99 3.12010-06-03T19:50:23Z<p>Jgallimo: </p>
<hr />
<div>[[Category: CARMA]] [[Category: Calibration]] [[Category: Mosaicking]]<br />
<br />
{{CARMA Intro}}<br />
<br />
== Overview ==<br />
<br />
This tutorial describes the data reduction for CO (1-0) data observed toward the galaxy M99 (NGC 4254) using CARMA. <br />
These data were kindly provided by the CARMA STING team and should not be used for scientific purposes. More information about STING and these data in particular can be found in Rahman et al. (2010) and [http://www.astro.umd.edu/~bolatto/STING/ CARMA STING webpage].<br />
<br />
In this tutorial we follow common CARMA practice to utilize a wide band (500 MHz) spectral window to calibrate narrow band (6 MHz) spectral windows in order to achieve better signal-to-noise.<br />
<br />
The tutorial below assumes that you have followed the initial MIRIAD data reduction and export to fits steps described at <br />
[[Extracting data from MIRIAD]].<br />
<br />
A tar file of the resulting fits files can be downloaded from http://casa.nrao.edu/Data/CARMA/M99/M99_CARMA.fits.tar<br />
<br />
After downloading, unpack the data in the directory you will be working in with<br />
<br />
tar -xvf M99_CARMA.fits.tar<br />
<br />
this will create a directory called fits.<br />
<br />
== Import fits files ==<br />
<br />
Below we show an example of creating a python dictionary and using "for" loops in python to run importuvfits multiple times, and then use the output as the input to the concat task. <br />
<br />
<source lang="python"><br />
myfiles = []<br />
for i in range(4,7):<br />
msfile = "c0104I"+str(i)+".ms"<br />
importuvfits(fitsfile="fits/c0104I."+str(i)+".fits",<br />
vis=msfile)<br />
myfiles.append(msfile)<br />
</source><br />
<br />
<source lang="python"><br />
concat(vis=myfiles,concatvis='c0104I',timesort=True)<br />
</source><br />
<br />
<source lang="python"><br />
listobs(vis='c0104I')<br />
</source><br />
<br />
Look at the logger output. Notice that the CARMA data comes into<br />
CASA with antenna names that are numbers and that CASA also creates<br />
an antenna ID number for each antenna (it also creates ID numbers<br />
for fields and spw). Both the antenna name and ID can be used to<br />
identify an antenna, which is very confusing if both are numbers --<br />
but not the same number. The python commands below will append the<br />
antenna names with CA to more easily distinguish them from their<br />
IDs. ALMA will already have antenna names that are strings, as does<br />
the EVLA. This step is only needed for data that comes into CASA via<br />
importuvfits.<br />
<br />
<source lang="python"><br />
tb.open("c0104I/ANTENNA",nomodify=False)<br />
namelist=tb.getcol("NAME").tolist()<br />
for i in range(len(namelist)):<br />
name = 'CA'+namelist[i]<br />
print ' Changing '+namelist[i]+' to '+name<br />
namelist[i]=name<br />
<br />
tb.putcol("NAME",namelist)<br />
tb.close()<br />
</source><br />
<br />
<source lang="python"><br />
listobs(vis='c0104I')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
Fields: 22<br />
ID Code Name RA Decl Epoch nVis <br />
0 MARS 09:15:50.0585 +17.21.03.8918 J2000 9450 <br />
1 3C273 12:29:06.7000 +02.03.08.5980 J2000 60480 <br />
2 NGC4254 12:18:47.8090 +14.24.13.9342 J2000 24570 <br />
3 NGC4254 12:18:49.6000 +14.24.13.9342 J2000 24570 <br />
4 NGC4254 12:18:51.3910 +14.24.13.9342 J2000 24570 <br />
5 NGC4254 12:18:52.2865 +14.24.36.4672 J2000 24570 <br />
6 NGC4254 12:18:50.4955 +14.24.36.4672 J2000 24570 <br />
7 NGC4254 12:18:48.7045 +14.24.36.4672 J2000 24570 <br />
8 NGC4254 12:18:46.9135 +14.24.36.4672 J2000 24570 <br />
9 NGC4254 12:18:46.0179 +14.24.59.0000 J2000 24570 <br />
10 NGC4254 12:18:47.8090 +14.24.59.0000 J2000 24570 <br />
11 NGC4254 12:18:49.6000 +14.24.59.0000 J2000 24570 <br />
12 NGC4254 12:18:51.3910 +14.24.59.0000 J2000 24570 <br />
13 NGC4254 12:18:53.1821 +14.24.59.0000 J2000 24570 <br />
14 NGC4254 12:18:52.2865 +14.25.21.5328 J2000 24570 <br />
15 NGC4254 12:18:50.4955 +14.25.21.5328 J2000 24570 <br />
16 NGC4254 12:18:48.7045 +14.25.21.5328 J2000 24570 <br />
17 NGC4254 12:18:46.9135 +14.25.21.5328 J2000 22680 <br />
18 NGC4254 12:18:47.8090 +14.25.44.0658 J2000 22680 <br />
19 NGC4254 12:18:49.6000 +14.25.44.0658 J2000 22680 <br />
20 NGC4254 12:18:51.3910 +14.25.44.0658 J2000 22680 <br />
21 3C274 12:30:49.4230 +12.23.28.0440 J2000 45360 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (3 unique spectral windows and 1 unique polarization setups)<br />
SpwID Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs<br />
0 15 LSRK 113978.067 31250 468750 113978.067 RR <br />
1 63 LSRK 114289.671 976.5625 61523.4375 114289.671 RR <br />
2 63 LSRK 114341.036 976.5625 61523.4375 114341.036 RR <br />
The SOURCE table is empty: see the FIELD table<br />
Antennas: 15:<br />
ID Name Station Diam. Long. Lat. <br />
0 CA1 ANT1 10.4 m -116.45.01.0 +37.13.43.4 <br />
1 CA2 ANT2 10.4 m -116.59.48.3 +37.52.00.3 <br />
2 CA3 ANT3 10.4 m -120.06.43.6 +37.35.02.8 <br />
3 CA4 ANT4 10.4 m -119.38.33.8 +38.26.22.2 <br />
4 CA5 ANT5 10.4 m -119.13.25.0 +35.03.23.4 <br />
5 CA6 ANT6 10.4 m -119.06.39.2 +38.54.24.4 <br />
6 CA7 ANT7 6.1 m -119.30.34.9 +36.58.55.6 <br />
7 CA8 ANT8 6.1 m -118.08.34.0 +37.16.45.8 <br />
8 CA9 ANT9 6.1 m -118.46.59.9 +36.48.41.4 <br />
9 CA10 ANT10 6.1 m -118.29.04.6 +36.03.45.6 <br />
10 CA11 ANT11 6.1 m -118.48.40.9 +37.15.57.8 <br />
11 CA12 ANT12 6.1 m -119.33.27.5 +36.06.46.1 <br />
12 CA13 ANT13 6.1 m -118.31.43.5 +37.05.19.4 <br />
13 CA14 ANT14 6.1 m -118.13.18.7 +36.50.34.6 <br />
14 CA15 ANT15 6.1 m -117.23.50.2 +36.25.48.2 <br />
</pre><br />
<br />
Since you were (likely) not the original observer for these data, here is a basic overview of how we will use them:<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Observing Strategy:<br />
<br />
Bandpass, Gain, and Flux calibrator: 3c273 field ID=1<br />
Secondary Gain Calibrator 3C274 field ID=21<br />
Extra flux calibrator Mars field ID=0<br />
<br />
The target mosaic (M99) is in field IDs 2~20<br />
<br />
There is one wideband channel (spw=0) and two narrow band channels<br />
(spw=1,2)<br />
</pre><br />
<br />
== Initial Inspection and Flagging ==<br />
[[Image:M99plotms1.png|thumb| Amplitude as a function of time for all sources, with each field shown in a different color.]]<br />
[[Image:M99plotms2.png|thumb|Zoom on bad target data, with small marked region.]]<br />
[[Image:M99plotms3.png|thumb|Zoom on last few scans of 3c273 (field=1) and 3c274 (field=21).]]<br />
<br />
First, flag edge channels: <br />
<br />
<source lang="python"><br />
flagdata(vis='c0104I',mode='manualflag',selectdata=True,spw='0:0~1;13~14')<br />
</source><br />
<br />
<source lang="python"><br />
flagdata(vis='c0104I',mode='manualflag',selectdata=True,spw='1~2:0~1;61~62')<br />
</source><br />
<br />
Let's look at the wide band channel on all sources:<br />
<br />
<br />
<source lang="python"><br />
plotms(vis='c0104I',xaxis='time',yaxis='amp',field='1~21', spw='0',<br />
avgchannel='15')<br />
</source><br />
<br />
Click "Display" tab in the plotms GUI and select "Colorize by: Field",<br />
then click the plot button.<br />
<br />
<br />
'''There are a few things to notice:'''<br />
<br />
First there is some very noticeably bad target data near the end of<br />
the observation. Use the zoom button to zoom in on the bad timerange, click the Mark Region icon and put a box over a modest number of the<br />
offending high points, and then press the Locate button. <br />
<br />
Information about the located points will display to the terminal ('''not''' the Log Messages window). This will tell<br />
you that the offending telescope is antenna name=CA13 (id=12) and<br />
that the field-ids are 2~11. Looking at the plot the bad time range<br />
is 05:43:00~05:54:00.<br />
<br />
<br />
Click the "Clear Regions" button, and then the "house" button to<br />
unzoom.<br />
<br />
<br />
Next note that the first two scans on 3c273 and the last scan on<br />
3c273 show some low points. Also the last scan on 3c274 shows low<br />
points. Again use zoom, mark, and locate to see if you can see a<br />
pattern.<br />
<br />
The first two scans on 3c273 don't show a particular pattern -- no<br />
particular antenna or individual time range appears to be<br />
responsible. This is usually a good indication that it cannot be<br />
calibrated out. Also note that it is unlikely that the target data<br />
in between is good, though this is not obvious because the target is<br />
weak. However, 3c274 does look ok, before the second 3c273 scan.<br />
Unfortunately, there is no way to calibrate the first target scans<br />
even if they are good, with no calibrator scan to precede them. For<br />
now we will flag 3c273 scans and the target in that timerange.<br />
<br />
As for the last scans, there is a pattern: problems with the last scan on 3c273 appears to be caused by antenna CA7 (in scan 272)<br />
and problems with the last scan on 3c274 appears to be related to antenna CA8 (scan 255).<br />
<br />
Looking at the lowest points on all the 3c273 scans, baseline<br />
CA2-CA8 appears low, we will also wait to see if this calibrates out.<br />
<br />
We will flag the narrow band channels wherever we see problems in<br />
wideband. You can either make separate plotting commands, or combine<br />
as below. To demonstrate different possibilities we use timerange to<br />
identify some data, and scan number to identify others.<br />
<br />
<source lang="python"><br />
flagdata(vis='c0104I',spw='0~2',<br />
antenna=['CA13','','CA7','CA8'],<br />
field=['2~11','1~20','1','21'],<br />
scan=['','','272','255'],<br />
timerange=['05:43:00~05:54:00','00:25:00~00:55:00','',''])<br />
</source><br />
<br />
Note that each of these flagging commands could have been written out separately, but combining them into one command will run much faster than the combined time of multiple calls as the data only have to be searched once.<br />
<br />
== Set the Absolute Flux Scale ==<br />
<br />
Often for millimeter observations, the absolute flux scale is determined by observing a planet and using a model of its flux as a function of baseline length (most planets are not point sources at mm frequencies using typical arrays). This is because the flux of planets change in a mostly predictable way (depending primarily on distance at any given time) than quasars. CASA does not yet have this functionality (we expect it for the next release). The flux of 3c273 is inserted from CARMA flux monitoring (which used the Mars observation to derive the 3c273 flux).<br />
<br />
<source lang="python"><br />
setjy(vis='c0104I', field='3C273',fluxdensity=[17.8,0.,0.,0.], spw='0~2')<br />
</source><br />
<br />
== Transferring Gains from One Spectral Window to Another ==<br />
<br />
Below we lay out in detail the steps for using the wideband gain calibration for the <br />
narrowband CARMA data. There are a few important things to note about this procedure: <br />
<br />
(1) There are two essential calibrations that must be done: Bandpass as a function of frequency (amplitude and phase) and Gain as a function of time (amplitude and phase). <br />
<br />
(2) Each spectral window (spw) will have independent bandpass shapes in both amplitude and phase. <br />
<br />
(3) As long as the system is relatively stable with time, the gain calibrations are typically the same for each spectral window after the '''full''' bandpass dependence is removed.<br />
<br />
In a dataset where each spw calibrates only itself, one typically normalizes the bandpass solutions, so that they take out the shape of the bandpass (in amplitude and phase), but not the absolute amplitude or phase offsets (which vary from spw to spw). In that case the gain solutions contain both the phase and amplitude solutions as a function of time, but also the absolute bandpass amplitude and phase offsets. The CASAguide [[EVLA spectral line IRC10216]] provides an example of this procedure.<br />
<br />
By contrast, in a case where you want to apply the gain calibrations from one spw to another, you definitely do '''not''' want those gains to apply the absolute bandpass amplitude and phase offsets derived from one spw to another. This is why in the steps below, we use solnorm=F in the bandpass task. This forces the absolute bandpass amplitude and phase offsets to be contained in the bandpass solutions (which are derived independently for each spw).<br />
<br />
== Calibrate the Wideband Bandpass ==<br />
[[Image:M99plotmswide1.png|thumb|Bandpass calibrator's (raw) wideband phase as a function of channel.]]<br />
[[Image:M99plotmswide2.png|thumb|Bandpass calibrator's wideband phase as a function of time.]]<br />
[[Image:M99plotcalwide1.png|thumb|Initial wideband gaincal solutions on 3C273, prior to bandpass calibration.]]<br />
[[Image:M99plotcalwide2.png|thumb|Bandpass wideband amplitude solution with applied initial gaincal.]]<br />
[[Image:M99plotcalwide3.png|thumb|Bandpass wideband phase solution with applied initial gaincal.]]<br />
<br />
Lets start by looking at the bandpass calibrator's phase as a<br />
function of channel for the wideband data.<br />
<br />
<source lang="python"><br />
plotms(vis='c0104I',xaxis='channel',yaxis='phase',<br />
field='1',spw='0',antenna='CA1',<br />
avgtime='1e8',avgscan=T)<br />
</source><br />
<br />
Select colorize by antenna2, and select "custom" for unflagged<br />
points, and then raise the style to 3 to make the plotted points easier to see. You will see that the<br />
phase does not change a great deal on individual baselines over<br />
the wide band channel (spw=0). This means that averaging over some <br />
channels will not introduce significant closure errors. Check<br />
other antennas if you like.<br />
<br />
Now look at the phase as a function of time. With avgtime a large<br />
number, but no avgscan=T, this command will show the average phase<br />
per scan. Since the cache changes, the colorize option changes<br />
too. You will have to select these again as above.<br />
<br />
<source lang="python"><br />
plotms(vis='c0104I',xaxis='time',yaxis='phase',<br />
field='1',spw='0',<br />
antenna='CA1',<br />
avgchannel='15',avgtime='1e8')<br />
</source><br />
<br />
Here you see significant variation with time. This is not<br />
surprising as the bandpass calibrator was observed over a fairly<br />
long period of time (~6 hours). In this case, it is important to calibrate the<br />
phase before solving for the bandpass. We choose a fairly narrow<br />
channel range since the bandpass phase as a function of frequency<br />
has not been taken out yet (though for these data it is quite well<br />
behaved).<br />
<br />
<source lang="python"><br />
gaincal(vis='c0104I',caltable='c0104I.bpphase_widecal',<br />
field='1',spw='0:5~9',<br />
refant='CA9',calmode='p',solint='inf',minsnr=2.0)<br />
</source><br />
<br />
The use of solint='inf' here without setting combine will get one<br />
solution per scan.<br />
<br />
Look at the solutions:<br />
<br />
<source lang="python"><br />
plotcal(caltable='c0104I.bpphase_widecal',<br />
xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=321)<br />
</source><br />
<br />
Note the phase drift is > 100 degrees on some antennas -- this is<br />
why it would not have been appropriate to vector average these<br />
data into one bp solution before taking out the phase. Use the<br />
"Next" button to page through all antennas.<br />
<br />
Having done a preliminary phase solution we can now combine all the<br />
3C273 scans into one bandpass solution. Note the default combine<br />
parameter is different for {{bandpass}} : combine='scan'.<br />
<br />
<source lang="python"><br />
bandpass(vis='c0104I',caltable='c0104I.bp_widecal',<br />
interp='',field='1',spw='0',<br />
bandtype='B',solint='inf',<br />
refant='CA9',solnorm=F,<br />
gaintable=['c0104I.bpphase_widecal'],<br />
spwmap=[[]])<br />
</source><br />
<br />
Next plot the amplitude and phase of the wideband bandpass solutions.<br />
<br />
<source lang="python"><br />
plotcal(caltable='c0104I.bp_widecal',xaxis='chan',yaxis='amp',<br />
iteration='antenna',subplot=321)<br />
</source><br />
<br />
<source lang="python"><br />
plotcal(caltable='c0104I.bp_widecal',xaxis='chan',yaxis='phase',<br />
iteration='antenna',subplot=321)<br />
</source><br />
<br />
== Calibrate the Wideband Gains ==<br />
[[Image:M99plotcalwide4.png|thumb|Wideband phase solution over individual integrations.]]<br />
[[Image:M99plotcalwide5a.png|thumb|Wideband gains for 3C274 (top points) and 3C273 (bottom points).]]<br />
[[Image:M99plotcalwide6a.png|thumb|Residual phase from wideband amplitude solutions.]]<br />
<br />
Now resolve for phase and also amplitude while applying the<br />
bandpass solutions, for both calibrators 3c273 and 3c274. We will<br />
not use the first gain solution again.<br />
<br />
First, do a phase solution on the timescale of an individual integration. (Consulting the listobs will reveal that each scan is about 5 minutes long, built up of 10-second integrations.)<br />
<br />
<source lang="python"><br />
gaincal(vis='c0104I',caltable='c0104I.phase_widecal',<br />
field='1,21',spw='0',<br />
refant='CA9',calmode='p',solint='int',minsnr=2.0,<br />
gaintable=['c0104I.bp_widecal'],<br />
spwmap=[[]])<br />
</source><br />
<br />
<br />
<source lang="python"><br />
plotcal(caltable='c0104I.phase_widecal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=321,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
Note the significant phase variation within a single scan. If we<br />
used an average phase over each whole scan to derive the amplitude<br />
solutions, it would decorrelate the subsequent amplitude<br />
corrections.<br />
<br />
So use the phase calibration just derived to get an amplitude solution over each scan:<br />
<br />
<source lang="python"><br />
gaincal(vis='c0104I',caltable='c0104I.amp_inf_widecal',<br />
field='1,21',spw='0',<br />
refant='CA9',calmode='ap',solint='inf',minsnr=2.0,<br />
gaintable=['c0104I.bp_widecal','c0104I.phase_widecal'],<br />
spwmap=[[]])<br />
</source><br />
<br />
<br />
<source lang="python"><br />
plotcal(caltable='c0104I.amp_inf_widecal',xaxis='time',yaxis='amp',<br />
iteration='antenna',subplot=321)<br />
</source><br />
<br />
Note the different gains for 3c273 scans and 3c274 scans, this<br />
just reflects that the two calibrators have different strengths.<br />
<br />
Next plot the phase from the amplitude solutions -- this will be<br />
the residual phase after taking out the integration-time based<br />
solutions. This gives a good idea of the residual phase<br />
noise. If this is more than a few degrees, the cause should be<br />
investigated. Note that the scatter for 3c274 is larger than 3c273<br />
-- this reflects that 3c274 is significantly weaker and thus has<br />
lower S/N. <br />
<br />
<br />
[[Image:M99plotcalwide7a.png|thumb|Wideband gain phase solutions on scan timescales.]]<br />
<br />
<source lang="python"><br />
plotcal(caltable='c0104I.amp_inf_widecal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=321)<br />
</source><br />
<br />
Here we re-run the phase only calibration but now getting one<br />
solution per scan to apply later to the target. An alternative<br />
would be to smooth the integration time phase calibration table,<br />
but this is a bit simpler.<br />
<br />
<source lang="python"><br />
gaincal(vis='c0104I',caltable='c0104I.phase_inf_widecal',<br />
field='1,21',spw='0',<br />
refant='CA9',calmode='p',solint='inf',minsnr=2.0,<br />
gaintable=['c0104I.bp_widecal'],<br />
spwmap=[[]])<br />
</source><br />
<br />
<br />
<source lang="python"><br />
plotcal(caltable='c0104I.phase_inf_widecal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=321,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
This is a very important plot to look at carefully as these are<br />
the phase solutions that will be applied to the target. Note that<br />
the phases for 3c273 and 3c274 are very similar, but not exactly<br />
the same. Unfortunately we can not color by field here to make it<br />
easier to see.<br />
<br />
== Calibrate the Narrow Band Bandpasses ==<br />
[[Image:M99plotcalnarrow1.png|thumb|Narrowband bandpass amplitude solutions.]]<br />
[[Image:M99plotcalnarrow2.png|thumb|Narrowband bandpass phase solutions.]]<br />
<br />
Solve for narrow band bandpasses, applying wideband phase and<br />
amplitude corrections. Because there are 3 spw in the data, you must<br />
set a placeholder for all three in spwmap, even though we are only<br />
solving for 2 of them.<br />
<br />
<source lang="python"><br />
bandpass(vis='c0104I',caltable='c0104I.bp_narrowcal',<br />
interp='',field='1',spw='1,2',<br />
bandtype='B',solint='inf',<br />
refant='CA9',solnorm=F,<br />
gaintable=['c0104I.phase_widecal','c0104I.amp_inf_widecal'],<br />
spwmap=[[0,0,0],[0,0,0]])<br />
</source><br />
<br />
<br />
<source lang="python"><br />
plotcal(caltable='c0104I.bp_narrowcal',xaxis='chan',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
<br />
<source lang="python"><br />
plotcal(caltable='c0104I.bp_narrowcal',xaxis='chan',yaxis='phase',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
== Calibrate Absolute Flux ==<br />
<br />
<source lang="python"><br />
fluxscale(vis='c0104I',caltable='c0104I.amp_inf_widecal',<br />
fluxtable='c0104I.fluxcal',reference='1')<br />
</source><br />
[[Image:M99plotcalflux2.png|thumb|Plotcal for the fluxscale solution.]]<br />
<pre style="background-color: #fffacd;"><br />
Flux density for 3C274 in SpW=0 is: 3.11626 +/- 0.0146614 <br />
(SNR = 212.549, nAnt= 15)<br />
</pre><br />
<br />
Check that the flux table looks reasonable; as the raw fluxes of the calibrators were close to their measured values in Jy, it is not surprising that the points for each antenna are clustered around 1.0. <br />
<br />
<source lang="python"><br />
plotcal(caltable='c0104I.fluxcal',xaxis='time',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
== Applycal and Inspect ==<br />
<br />
We run applycal separately for the wide and narrow band data so we can apply the appropriate bandpass tables.<br />
<br />
Applying solutions to 3C273:<br />
<source lang="python"><br />
applycal(vis='c0104I',field='1',spw='0',<br />
gaintable=['c0104I.bp_widecal','c0104I.phase_widecal',<br />
'c0104I.fluxcal'],<br />
spwmap=[[],[],[]],gainfield=['1','1','1'])<br />
</source><br />
<br />
<source lang="python"><br />
applycal(vis='c0104I',field='1',spw='1,2',<br />
gaintable=['c0104I.bp_narrowcal','c0104I.phase_widecal',<br />
'c0104I.fluxcal'],<br />
spwmap=[[],[0,0,0],[0,0,0]],gainfield=['1','1','1'])<br />
</source><br />
<br />
Applying solutions to 3C274:<br />
<source lang="python"><br />
applycal(vis='c0104I',field='21',spw='0',<br />
gaintable=['c0104I.bp_widecal','c0104I.phase_widecal',<br />
'c0104I.fluxcal'],<br />
spwmap=[[],[],[]],gainfield=['1','21','21'])<br />
</source><br />
<br />
<source lang="python"><br />
applycal(vis='c0104I',field='21',spw='1,2',<br />
gaintable=['c0104I.bp_narrowcal','c0104I.phase_widecal',<br />
'c0104I.fluxcal'],<br />
spwmap=[[],[0,0,0],[0,0,0]],gainfield=['1','21','21'])<br />
</source><br />
<br />
[[Image:M99plotmsfinp.png|thumb|Phases after calibration.]]<br />
[[Image:M99plotmsfina.png|thumb|Amplitudes after calibration.]]<br />
<br />
For the target we will use both gain calibrators, so whichever is closest in time will be applied to the target.<br />
<br />
<source lang="python"><br />
applycal(vis='c0104I',field='2~20',spw='0',<br />
gaintable=['c0104I.bp_widecal','c0104I.phase_inf_widecal',<br />
'c0104I.fluxcal'],<br />
spwmap=[[],[],[]],gainfield=['1','1,21','1,21'])<br />
</source><br />
<br />
<source lang="python"><br />
applycal(vis='c0104I',field='2~20',spw='1,2',<br />
gaintable=['c0104I.bp_narrowcal','c0104I.phase_inf_widecal',<br />
'c0104I.fluxcal'],<br />
spwmap=[[],[0,0,0],[0,0,0]],gainfield=['1','1,21','1,21'])<br />
</source><br />
<br />
<br />
You should now see, for example, that the phases are flat across all spw for 3C273, and amplitudes match the monitored calibrator fluxes for this date (with the source data at the bottom).<br />
<br />
<source lang="python"><br />
plotms(vis='c0104I',xaxis='frequency',ydatacolumn='corrected',<br />
field='1',avgtime='1e8')<br />
</source><br />
<br />
<br />
<source lang="python"><br />
plotms(vis='c0104I',xaxis='time',yaxis='amp',ydatacolumn='corrected',<br />
field='1~21',spw='0',<br />
avgchannel='15',avgtime='1e8')<br />
</source><br />
<br />
== Deconvolution and Imaging ==<br />
<br />
[[Image:M99plotms_spw.png|thumb|Narrowband spw as a function of velocity, colorized by spw.]]<br />
<source lang="python"><br />
plotms(vis='c0104I',xaxis='velocity',yaxis='amp',ydatacolumn='corrected',<br />
field='2',spw='1~2',avgtime='1e8')<br />
</source><br />
<br />
in plotms in the '''Trans''' tab set the CO rest frequency (115271.2<br />
MHz) in order to see the velocity range of the narrow band<br />
channels (don't forget to click '''Plot''' again). Unfortunately the individual pointings are a bit too<br />
weak to see the UV vector averaged CO signal but you can at least<br />
see the observed velocity range.<br />
<br />
Go to '''Display''' tab and choose colorize by spw. Notice that the edge<br />
channels are a bit noisy -- especially a concern in the overlap<br />
region. We will exclude these below.<br />
<br />
[[Image:M99_interactive.png|thumb|The interactive viewer with the .flux contours in magenta and the clean mask in white contours.]]<br />
The clean call below, uses the interactive clean mode. This is important for complex extended emission as is seen in the CO(1-0) for M99. Below we provide a brief description of one easy way you might make a clean mask for this image. Of course making a clean mask for each channel individually would be better if you have the time and patience.<br />
<br />
<source lang="python"><br />
clean(vis='c0104I',imagename='M99_cube_nearest',spw='1~2:3~59',field='2~20',<br />
phasecenter='11',<br />
cell='0.9arcsec',imsize=450,<br />
mode='velocity',start='2268km/s',width='10.0km/s',<br />
interpolation='nearest',<br />
imagermode='mosaic',cyclefactor=2,<br />
restfreq='115.2712GHz',interactive=T,<br />
minpb=0.1,pbcor=F,<br />
niter=5000,threshold='40mJy')<br />
</source><br />
<br />
When the interactive viewer pops up (this may take a few minutes), click the "folder" icon in top left. From file GUI select "M99_cube_nearest.flux" and then click "Contour Map" under "Display As". This will show the convolution of the primary beam coverage. Next click the "wrench" next to the file folder icon. This will open the "Data Display Options" GUI. At the top, tab over until you see the "M99_cube_nearest.flux-contour" tab. <br />
<br />
Now change the line color to magenta (from foreground). Now click the zoom button in the Display panel and zoom in on the mosaic region. Chose "all channels" toggle in the green box and then chose the "Polygon drawing" tool from the top, and make a clean mask around the outermost contour (this happens to be the 0.2 contour level). Double click inside the polygon area (with the same button you used to define the polygon), and you should see it turn white. If you now use the tape deck commands below the image to move back and forth through the cube, you can check that all the emission falls within the masked region. <br />
<br />
Once you are satisfied with the mask, '''go to the data drop down menu and close the "M99_cube_nearest.flux-contour" file. If you don't do this you will get a table lock and the final image will not be constructed.''' Then hit the blue arrow to continue cleaning with this mask until the threshold is reached. More clean masking tips and techniques are described in the [[EVLA spectral line IRC10216]] casaguide.<br />
<br />
== Image Analysis ==<br />
<br />
First lets see what the rms noise level in a single channel is using the viewer.<br />
<br />
<source lang="python"><br />
viewer(infile='M99_cube_nearest.image')<br />
</source><br />
<br />
Then use the tape deck to go to a line free channel, select the box region tool and make a box. When you double click in the box, the image statistics for the whole cube will print to the terminal and for the channel you are on it will print to a pop up window. Move the box around a bit to see what the variation is. You should get something like 22 - 25 mJy. If you want the box tool to go away, hit the escape key.<br />
<br />
Next make integrated intensity maps (moment 0) and integrated velocity maps (moment 1). to do this, we'll want to know what channels the line emission starts on. The first channel with significant emission is channel 1, while the last channel with significant emission is channel 23.<br />
<br />
[[Image:moment_maps_2.png|thumb|Example of moment 0 and moment 1 images side by side.]]<br />
For moment zero, its best to limit the calculation to image channels with significant signal in them, but not to apply a flux cutoff, as this will bias the derived integrated intensities upward. <br />
<br />
<source lang="python"><br />
immoments(imagename='M99_cube_nearest.image',moments=[0],<br />
axis='spectral',<br />
chans='1~23',outfile='M99_cube.moment0')<br />
</source><br />
<br />
For moment 1, it is essential to apply a conservative flux cutoff to limit the calculation to <br />
high signal-to-noise areas. Here we use about 5sigma.<br />
<br />
<source lang="python"><br />
immoments(imagename='M99_cube_nearest.image',moments=[1],<br />
axis='spectral',<br />
chans='1~23',excludepix=[-100,0.125],<br />
outfile='M99_cube.moment1')<br />
</source><br />
<br />
[[Image:moment_maps.png|thumb|Example of moment 1 raster superposed with white moment 0 contours.]]<br />
Next you can open the viewer by typing <br />
<source lang="python"><br />
viewer<br />
</source><br />
<br />
You can open both moment maps as rasters and then blink between them by first clicking the "blink" toggle and then using the tape deck to cycle through. You might also try opening the "p wrench tool" (Viewer Canvas Manager) at the top of the Viewer display panel, then go to "Number of panels" and up the number in x to 2. Then if its not already selected, click blink in the Viewer display to see both images side by side. It will help to make your viewer window fairly wide.<br />
<br />
Also try opening the moment1 as a raster and moment0 as a contour map (In the example at right, I've played with the default contour levels in the "Data display options").<br />
<br />
<br />
{{Checked 3.0.2}}<br />
<br />
--[[User:CBrogan|Crystal Brogan]]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Obtaining_EVLA_Data:_3C_391_Example&diff=3695Obtaining EVLA Data: 3C 391 Example2010-06-03T19:48:21Z<p>Jgallimo: </p>
<hr />
<div>== Appendix: Obtaining Data: 3C 391 Example ==<br />
<br />
For the purposes of the summer school tutorials, a small number of initial processing steps had been applied. Here we describe in more detail the series of steps that one is likely to have to conduct to obtain a data set similar to what was used for the summer school tutorials, using the 3C 391 data set as an example.<br />
<br />
The original test data were taken on 2010 April 24, and are stored as file TDEM0001_sb1218006_1.55310.33439732639 .<br />
<br />
=== Acquiring data from the Archive ===<br />
<br />
The data are publicly available from the [https://archive.nrao.edu/archive/archiveproject.jsp NRAO archive], under Project (Proposal) Name TDEM0001. When submitting an archive query with this project name, 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 (TDEM0001_sb1218006_1.55310.33439732639; file size 39.79 GB). This file contains data at the full 1-s time resolution. You can select to download an SDM file from the archive, a measurement set, or an AIPS UVFITS file. In the latter two cases, you can opt for spectral or temporal averaging of the data. Spectral averaging prior to bandpass calibration is discouraged, since it can cause phase decorrelation. Whether or not to temporal average will depend on the array configuration, field of view, and acceptable level of time-average smearing. In this example, we opt not to perform any spectral or temporal averaging, and later show how this may be done after the fact by running the task {{split}} on the measurement set.<br />
<br />
Since the purpose of this tutorial is to demonstrate the steps involved in obtaining one's data from the archive, we will download the data in as unprocessed a format as possible, namely an SDM-BDF dataset (all files). To create a single file (rather than a directory) for downloading, we check the "Create MS or SDM tar file" box, and also check the box labelled "Apply flags generated during observing", to remove data known to be bad (for instance, antennas which are off source during slewing operations).<br />
<br />
Having entered your email address at the top of the form and selected the required data set, we now request to "Download checked files". When the data have been copied to the relevant directory, you will receive an email. Follow its instructions to download the tarred SDM file.<br />
<br />
=== Converting to a measurement set ===<br />
<br />
Now that we have the SDM file, untar the file to create a new directory. Then start up CASA, as described in [[Getting Started in CASA]].<br />
<br />
Within CASA, the task {{importevla}} will convert a Science Data Model (SDM file) into the Measurement Set (MS) that we will process further using CASA.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importevla(asdm='TDEM0001_sb1218006_1.55310.33439732639',vis='3c391_mosaic_fullres.ms',<br />
flagzero=True,cliplevel=1e-08,flagpol=True,shadow=True, diameter=28.0)<br />
</source><br />
[[Image:3c391 ctm importevla parameters.jpg|200px|thumb|right|importevla inputs]]<br />
<br />
While most parameters can be set to their default value, the following should be set explicitly:<br />
* asdm='TDEM0001_sb1218006_1.55310.33439732639' : We must specify the location of the SDM file to be converted.<br />
* vis='3c391_mosaic_fullres.ms' : We must provide a name for the MS to be created.<br />
* flagzero=True : A small fraction of the data is exactly zero, and we wish to get rid of these points, since they are a product of the WIDAR correlator, and do not represent real visibilities. This flagging will proceed via a simple clip, and we must specify the ''cliplevel'', which we set to 1e-08. Anything less than this is unlikely to be real. Since for polarization observations we do not wish to keep the cross-hand visibilities if the parallel hands are zero, we also set ''flagpol=True''.<br />
* shadow=True : When observing at low declinations, particularly in compact configurations, one antenna may block the line of sight between another antenna and the source of interest. This effect is known as shadowing. It is strongly recommended that all data suffering from shadowing be flagged. Knowing the antenna positions, the hour angle and elevation of the source, the shadowing can be computed as a function of antenna and time. By setting the ''shadow'' parameter, we opt to flag all shadowed data, regardless of source. To be conservative, we specify ''diameter=28.0'' to set the assumed antenna diameter for calculation of when antennas are shadowed.<br />
<br />
This task will take some time to execute, since the SDM file is large (39.79GB) and after creating the MS, it runs {{flagdata}}, inspecting every visibility inspected for zeroes and for shadowing.<br />
<br />
=== Averaging the data ===<br />
<br />
Depending upon the science goals and the details of the observation, averaging in time, frequency, or both may be possible at this stage. For instance, the 3C 391 data used in the summer school tutorial were acquired with a 1-second sampling in the D configuration. Given the size of 3C 391 itself, and the fact that there are no other strong nearby sources, it makes sense to average these data in time (and possibly in frequency as well, although that was not done for the summer school). For the summer school tutorial itself, we also restricted ourselves to just a single spectral window, even though the observations were acquired with two spectral windows. To create a data set averaged in time, we use the task {{split}}.<br />
<br />
[[Image:3C391_precal_split_parameters.png|200px|thumb|right|split inputs]]<br />
<br />
<source lang="python"><br />
split(vis='3c391_mosaic_fullres.ms',outputvis='3c391_ctm_mosaic_10s.ms',datacolumn='data',<br />
spw='0',width=1,timebin='10s')<br />
</source><br />
<br />
This results in a single spectral window, with an unchanged frequency resolution, averaged to 10-second sampling.<br />
* outputvis='3c391_ctm_mosaic_10s.ms' : We specify the name of the new, time-averaged MS.<br />
* datacolumn='data' : In this case, since we have not performed any calibration, we want to take the visibilities from the uncorrected, DATA, column. Were we splitting off the data after calibration, we would instead select the CALIBRATED_DATA column.<br />
* timebin='10s' : Here we specify the time averaging to apply; we write out visibilities averaged to 10s sampling.<br />
* width=1 : This is the number of channels to average to form a single output channel. Here we do no frequency averaging.<br />
* spw='0' : Select only the lower-frequency spectral window (to halve the size of the data set; if you wish to derive spectral index information by using both frequencies, you should set '' spw='' '').<br />
<br />
Having created our new 10-s averaged data set, the final step is to create the scratch columns needed in further processing. To do so, we run {{clearcal}}. You will recall that we split off the DATA column of the MS. {{clearcal}} will then create the MODEL_DATA column (initialized to unity) and the CORRECTED_DATA column (initialized to the values in the DATA column), to remove any previous calibration information and ready the data set for full calibration.<br />
<br />
<source lang="python"><br />
clearcal(vis='3c391_ctm_mosaic_10s.ms')<br />
</source><br />
<br />
We have now created the starting data set for the [[EVLA Continuum Tutorial 3C391]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Obtaining_EVLA_Data:_3C_391_Example&diff=3694Obtaining EVLA Data: 3C 391 Example2010-06-03T19:47:28Z<p>Jgallimo: /* Averaging the data */</p>
<hr />
<div>== Appendix: Obtaining Data: 3C 391 Example ==<br />
<br />
For the purposes of the summer school tutorials, a small number of initial processing steps had been applied. Here we describe in more detail the series of steps that one is likely to have to conduct to obtain a data set similar to what was used for the summer school tutorials, using the 3C 391 data set as an example.<br />
<br />
The original test data were taken on 2010 April 24, and are stored as file TDEM0001_sb1218006_1.55310.33439732639 .<br />
<br />
=== Acquiring data from the Archive ===<br />
<br />
The data are publicly available from the [https://archive.nrao.edu/archive/archiveproject.jsp NRAO archive], under Project (Proposal) Name TDEM0001. When submitting an archive query with this project name, 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 (TDEM0001_sb1218006_1.55310.33439732639; file size 39.79 GB). This file contains data at the full 1-s time resolution. You can select to download an SDM file from the archive, a measurement set, or an AIPS UVFITS file. In the latter two cases, you can opt for spectral or temporal averaging of the data. Spectral averaging prior to bandpass calibration is discouraged, since it can cause phase decorrelation. Whether or not to temporal average will depend on the array configuration, field of view, and acceptable level of time-average smearing. In this example, we opt not to perform any spectral or temporal averaging, and later show how this may be done after the fact by running the task [[split]] on the measurement set.<br />
<br />
Since the purpose of this tutorial is to demonstrate the steps involved in obtaining one's data from the archive, we will download the data in as unprocessed a format as possible, namely an SDM-BDF dataset (all files). To create a single file (rather than a directory) for downloading, we check the "Create MS or SDM tar file" box, and also check the box labelled "Apply flags generated during observing", to remove data known to be bad (for instance, antennas which are off source during slewing operations).<br />
<br />
Having entered your email address at the top of the form and selected the required data set, we now request to "Download checked files". When the data have been copied to the relevant directory, you will receive an email. Follow its instructions to download the tarred SDM file.<br />
<br />
=== Converting to a measurement set ===<br />
<br />
Now that we have the SDM file, untar the file to create a new directory. Then start up CASA, as described in [[Getting_Started_in_CASA]].<br />
<br />
Within CASA, the task {{importevla}} will convert a Science Data Model (SDM file) into the Measurement Set (MS) that we will process further using CASA.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importevla(asdm='TDEM0001_sb1218006_1.55310.33439732639',vis='3c391_mosaic_fullres.ms',<br />
flagzero=True,cliplevel=1e-08,flagpol=True,shadow=True, diameter=28.0)<br />
</source><br />
[[Image:3c391 ctm importevla parameters.jpg|200px|thumb|right|importevla inputs]]<br />
<br />
While most parameters can be set to their default value, the following should be set explicitly:<br />
* asdm='TDEM0001_sb1218006_1.55310.33439732639' : We must specify the location of the SDM file to be converted.<br />
* vis='3c391_mosaic_fullres.ms' : We must provide a name for the MS to be created.<br />
* flagzero=True : A small fraction of the data is exactly zero, and we wish to get rid of these points, since they are a product of the WIDAR correlator, and do not represent real visibilities. This flagging will proceed via a simple clip, and we must specify the ''cliplevel'', which we set to 1e-08. Anything less than this is unlikely to be real. Since for polarization observations we do not wish to keep the cross-hand visibilities if the parallel hands are zero, we also set ''flagpol=True''.<br />
* shadow=True : When observing at low declinations, particularly in compact configurations, one antenna may block the line of sight between another antenna and the source of interest. This effect is known as shadowing. It is strongly recommended that all data suffering from shadowing be flagged. Knowing the antenna positions, the hour angle and elevation of the source, the shadowing can be computed as a function of antenna and time. By setting the ''shadow'' parameter, we opt to flag all shadowed data, regardless of source. To be conservative, we specify ''diameter=28.0'' to set the assumed antenna diameter for calculation of when antennas are shadowed.<br />
<br />
This task will take some time to execute, since the SDM file is large (39.79GB) and after creating the MS, it runs {{flagdata}}, inspecting every visibility inspected for zeroes and for shadowing.<br />
<br />
=== Averaging the data ===<br />
<br />
Depending upon the science goals and the details of the observation, averaging in time, frequency, or both may be possible at this stage. For instance, the 3C 391 data used in the summer school tutorial were acquired with a 1-second sampling in the D configuration. Given the size of 3C 391 itself, and the fact that there are no other strong nearby sources, it makes sense to average these data in time (and possibly in frequency as well, although that was not done for the summer school). For the summer school tutorial itself, we also restricted ourselves to just a single spectral window, even though the observations were acquired with two spectral windows. To create a data set averaged in time, we use the task {{split}}.<br />
<br />
[[Image:3C391_precal_split_parameters.png|200px|thumb|right|split inputs]]<br />
<br />
<source lang="python"><br />
split(vis='3c391_mosaic_fullres.ms',outputvis='3c391_ctm_mosaic_10s.ms',datacolumn='data',<br />
spw='0',width=1,timebin='10s')<br />
</source><br />
<br />
This results in a single spectral window, with an unchanged frequency resolution, averaged to 10-second sampling.<br />
* outputvis='3c391_ctm_mosaic_10s.ms' : We specify the name of the new, time-averaged MS.<br />
* datacolumn='data' : In this case, since we have not performed any calibration, we want to take the visibilities from the uncorrected, DATA, column. Were we splitting off the data after calibration, we would instead select the CALIBRATED_DATA column.<br />
* timebin='10s' : Here we specify the time averaging to apply; we write out visibilities averaged to 10s sampling.<br />
* width=1 : This is the number of channels to average to form a single output channel. Here we do no frequency averaging.<br />
* spw='0' : Select only the lower-frequency spectral window (to halve the size of the data set; if you wish to derive spectral index information by using both frequencies, you should set '' spw='' '').<br />
<br />
Having created our new 10-s averaged data set, the final step is to create the scratch columns needed in further processing. To do so, we run {{clearcal}}. You will recall that we split off the DATA column of the MS. {{clearcal}} will then create the MODEL_DATA column (initialized to unity) and the CORRECTED_DATA column (initialized to the values in the DATA column), to remove any previous calibration information and ready the data set for full calibration.<br />
<br />
<source lang="python"><br />
clearcal(vis='3c391_ctm_mosaic_10s.ms')<br />
</source><br />
<br />
We have now created the starting data set for the [[EVLA Continuum Tutorial 3C391]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Obtaining_EVLA_Data:_3C_391_Example&diff=3693Obtaining EVLA Data: 3C 391 Example2010-06-03T19:47:08Z<p>Jgallimo: /* Averaging the data */</p>
<hr />
<div>== Appendix: Obtaining Data: 3C 391 Example ==<br />
<br />
For the purposes of the summer school tutorials, a small number of initial processing steps had been applied. Here we describe in more detail the series of steps that one is likely to have to conduct to obtain a data set similar to what was used for the summer school tutorials, using the 3C 391 data set as an example.<br />
<br />
The original test data were taken on 2010 April 24, and are stored as file TDEM0001_sb1218006_1.55310.33439732639 .<br />
<br />
=== Acquiring data from the Archive ===<br />
<br />
The data are publicly available from the [https://archive.nrao.edu/archive/archiveproject.jsp NRAO archive], under Project (Proposal) Name TDEM0001. When submitting an archive query with this project name, 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 (TDEM0001_sb1218006_1.55310.33439732639; file size 39.79 GB). This file contains data at the full 1-s time resolution. You can select to download an SDM file from the archive, a measurement set, or an AIPS UVFITS file. In the latter two cases, you can opt for spectral or temporal averaging of the data. Spectral averaging prior to bandpass calibration is discouraged, since it can cause phase decorrelation. Whether or not to temporal average will depend on the array configuration, field of view, and acceptable level of time-average smearing. In this example, we opt not to perform any spectral or temporal averaging, and later show how this may be done after the fact by running the task [[split]] on the measurement set.<br />
<br />
Since the purpose of this tutorial is to demonstrate the steps involved in obtaining one's data from the archive, we will download the data in as unprocessed a format as possible, namely an SDM-BDF dataset (all files). To create a single file (rather than a directory) for downloading, we check the "Create MS or SDM tar file" box, and also check the box labelled "Apply flags generated during observing", to remove data known to be bad (for instance, antennas which are off source during slewing operations).<br />
<br />
Having entered your email address at the top of the form and selected the required data set, we now request to "Download checked files". When the data have been copied to the relevant directory, you will receive an email. Follow its instructions to download the tarred SDM file.<br />
<br />
=== Converting to a measurement set ===<br />
<br />
Now that we have the SDM file, untar the file to create a new directory. Then start up CASA, as described in [[Getting_Started_in_CASA]].<br />
<br />
Within CASA, the task {{importevla}} will convert a Science Data Model (SDM file) into the Measurement Set (MS) that we will process further using CASA.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importevla(asdm='TDEM0001_sb1218006_1.55310.33439732639',vis='3c391_mosaic_fullres.ms',<br />
flagzero=True,cliplevel=1e-08,flagpol=True,shadow=True, diameter=28.0)<br />
</source><br />
[[Image:3c391 ctm importevla parameters.jpg|200px|thumb|right|importevla inputs]]<br />
<br />
While most parameters can be set to their default value, the following should be set explicitly:<br />
* asdm='TDEM0001_sb1218006_1.55310.33439732639' : We must specify the location of the SDM file to be converted.<br />
* vis='3c391_mosaic_fullres.ms' : We must provide a name for the MS to be created.<br />
* flagzero=True : A small fraction of the data is exactly zero, and we wish to get rid of these points, since they are a product of the WIDAR correlator, and do not represent real visibilities. This flagging will proceed via a simple clip, and we must specify the ''cliplevel'', which we set to 1e-08. Anything less than this is unlikely to be real. Since for polarization observations we do not wish to keep the cross-hand visibilities if the parallel hands are zero, we also set ''flagpol=True''.<br />
* shadow=True : When observing at low declinations, particularly in compact configurations, one antenna may block the line of sight between another antenna and the source of interest. This effect is known as shadowing. It is strongly recommended that all data suffering from shadowing be flagged. Knowing the antenna positions, the hour angle and elevation of the source, the shadowing can be computed as a function of antenna and time. By setting the ''shadow'' parameter, we opt to flag all shadowed data, regardless of source. To be conservative, we specify ''diameter=28.0'' to set the assumed antenna diameter for calculation of when antennas are shadowed.<br />
<br />
This task will take some time to execute, since the SDM file is large (39.79GB) and after creating the MS, it runs {{flagdata}}, inspecting every visibility inspected for zeroes and for shadowing.<br />
<br />
=== Averaging the data ===<br />
<br />
Depending upon the science goals and the details of the observation, averaging in time, frequency, or both may be possible at this stage. For instance, the 3C 391 data used in the summer school tutorial were acquired with a 1-second sampling in the D configuration. Given the size of 3C 391 itself, and the fact that there are no other strong nearby sources, it makes sense to average these data in time (and possibly in frequency as well, although that was not done for the summer school). For the summer school tutorial itself, we also restricted ourselves to just a single spectral window, even though the observations were acquired with two spectral windows. To create a data set averaged in time, we use the task [[split]].<br />
<br />
[[Image:3C391_precal_split_parameters.png|200px|thumb|right|split inputs]]<br />
<br />
<source lang="python"><br />
split(vis='3c391_mosaic_fullres.ms',outputvis='3c391_ctm_mosaic_10s.ms',datacolumn='data',<br />
spw='0',width=1,timebin='10s')<br />
</source><br />
<br />
This results in a single spectral window, with an unchanged frequency resolution, averaged to 10-second sampling.<br />
* outputvis='3c391_ctm_mosaic_10s.ms' : We specify the name of the new, time-averaged MS.<br />
* datacolumn='data' : In this case, since we have not performed any calibration, we want to take the visibilities from the uncorrected, DATA, column. Were we splitting off the data after calibration, we would instead select the CALIBRATED_DATA column.<br />
* timebin='10s' : Here we specify the time averaging to apply; we write out visibilities averaged to 10s sampling.<br />
* width=1 : This is the number of channels to average to form a single output channel. Here we do no frequency averaging.<br />
* spw='0' : Select only the lower-frequency spectral window (to halve the size of the data set; if you wish to derive spectral index information by using both frequencies, you should set '' spw='' '').<br />
<br />
Having created our new 10-s averaged data set, the final step is to create the scratch columns needed in further processing. To do so, we run {{clearcal}}. You will recall that we split off the DATA column of the MS. {{clearcal}} will then create the MODEL_DATA column (initialized to unity) and the CORRECTED_DATA column (initialized to the values in the DATA column), to remove any previous calibration information and ready the data set for full calibration.<br />
<br />
<source lang="python"><br />
clearcal(vis='3c391_ctm_mosaic_10s.ms')<br />
</source><br />
<br />
We have now created the starting data set for the [[EVLA Continuum Tutorial 3C391]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Obtaining_EVLA_Data:_3C_391_Example&diff=3692Obtaining EVLA Data: 3C 391 Example2010-06-03T19:46:50Z<p>Jgallimo: /* Averaging the data */</p>
<hr />
<div>== Appendix: Obtaining Data: 3C 391 Example ==<br />
<br />
For the purposes of the summer school tutorials, a small number of initial processing steps had been applied. Here we describe in more detail the series of steps that one is likely to have to conduct to obtain a data set similar to what was used for the summer school tutorials, using the 3C 391 data set as an example.<br />
<br />
The original test data were taken on 2010 April 24, and are stored as file TDEM0001_sb1218006_1.55310.33439732639 .<br />
<br />
=== Acquiring data from the Archive ===<br />
<br />
The data are publicly available from the [https://archive.nrao.edu/archive/archiveproject.jsp NRAO archive], under Project (Proposal) Name TDEM0001. When submitting an archive query with this project name, 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 (TDEM0001_sb1218006_1.55310.33439732639; file size 39.79 GB). This file contains data at the full 1-s time resolution. You can select to download an SDM file from the archive, a measurement set, or an AIPS UVFITS file. In the latter two cases, you can opt for spectral or temporal averaging of the data. Spectral averaging prior to bandpass calibration is discouraged, since it can cause phase decorrelation. Whether or not to temporal average will depend on the array configuration, field of view, and acceptable level of time-average smearing. In this example, we opt not to perform any spectral or temporal averaging, and later show how this may be done after the fact by running the task [[split]] on the measurement set.<br />
<br />
Since the purpose of this tutorial is to demonstrate the steps involved in obtaining one's data from the archive, we will download the data in as unprocessed a format as possible, namely an SDM-BDF dataset (all files). To create a single file (rather than a directory) for downloading, we check the "Create MS or SDM tar file" box, and also check the box labelled "Apply flags generated during observing", to remove data known to be bad (for instance, antennas which are off source during slewing operations).<br />
<br />
Having entered your email address at the top of the form and selected the required data set, we now request to "Download checked files". When the data have been copied to the relevant directory, you will receive an email. Follow its instructions to download the tarred SDM file.<br />
<br />
=== Converting to a measurement set ===<br />
<br />
Now that we have the SDM file, untar the file to create a new directory. Then start up CASA, as described in [[Getting_Started_in_CASA]].<br />
<br />
Within CASA, the task {{importevla}} will convert a Science Data Model (SDM file) into the Measurement Set (MS) that we will process further using CASA.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importevla(asdm='TDEM0001_sb1218006_1.55310.33439732639',vis='3c391_mosaic_fullres.ms',<br />
flagzero=True,cliplevel=1e-08,flagpol=True,shadow=True, diameter=28.0)<br />
</source><br />
[[Image:3c391 ctm importevla parameters.jpg|200px|thumb|right|importevla inputs]]<br />
<br />
While most parameters can be set to their default value, the following should be set explicitly:<br />
* asdm='TDEM0001_sb1218006_1.55310.33439732639' : We must specify the location of the SDM file to be converted.<br />
* vis='3c391_mosaic_fullres.ms' : We must provide a name for the MS to be created.<br />
* flagzero=True : A small fraction of the data is exactly zero, and we wish to get rid of these points, since they are a product of the WIDAR correlator, and do not represent real visibilities. This flagging will proceed via a simple clip, and we must specify the ''cliplevel'', which we set to 1e-08. Anything less than this is unlikely to be real. Since for polarization observations we do not wish to keep the cross-hand visibilities if the parallel hands are zero, we also set ''flagpol=True''.<br />
* shadow=True : When observing at low declinations, particularly in compact configurations, one antenna may block the line of sight between another antenna and the source of interest. This effect is known as shadowing. It is strongly recommended that all data suffering from shadowing be flagged. Knowing the antenna positions, the hour angle and elevation of the source, the shadowing can be computed as a function of antenna and time. By setting the ''shadow'' parameter, we opt to flag all shadowed data, regardless of source. To be conservative, we specify ''diameter=28.0'' to set the assumed antenna diameter for calculation of when antennas are shadowed.<br />
<br />
This task will take some time to execute, since the SDM file is large (39.79GB) and after creating the MS, it runs {{flagdata}}, inspecting every visibility inspected for zeroes and for shadowing.<br />
<br />
=== Averaging the data ===<br />
<br />
Depending upon the science goals and the details of the observation, averaging in time, frequency, or both may be possible at this stage. For instance, the 3C 391 data used in the summer school tutorial were acquired with a 1-second sampling in the D configuration. Given the size of 3C 391 itself, and the fact that there are no other strong nearby sources, it makes sense to average these data in time (and possibly in frequency as well, although that was not done for the summer school). For the summer school tutorial itself, we also restricted ourselves to just a single spectral window, even though the observations were acquired with two spectral windows. To create a data set averaged in time, we use the task [[split]].<br />
<br />
[[Image:3C391_precal_split_parameters.png|200px|thumb|right|split inputs]]<br />
<br />
<source lang="python"><br />
split(vis='3c391_mosaic_fullres.ms',outputvis='3c391_ctm_mosaic_10s.ms',datacolumn='data',<br />
spw='0',width=1,timebin='10s')<br />
</source><br />
<br />
This results in a single spectral window, with an unchanged frequency resolution, averaged to 10-second sampling.<br />
* outputvis='3c391_ctm_mosaic_10s.ms' : We specify the name of the new, time-averaged MS.<br />
* datacolumn='data' : In this case, since we have not performed any calibration, we want to take the visibilities from the uncorrected, DATA, column. Were we splitting off the data after calibration, we would instead select the CALIBRATED_DATA column.<br />
* timebin='10s' : Here we specify the time averaging to apply; we write out visibilities averaged to 10s sampling.<br />
* width=1 : This is the number of channels to average to form a single output channel. Here we do no frequency averaging.<br />
* spw='0' : Select only the lower-frequency spectral window (to halve the size of the data set; if you wish to derive spectral index information by using both frequencies, you should set '' spw='' '').<br />
<br />
Having created our new 10-s averaged data set, the final step is to create the scratch columns needed in further processing. To do so, we run {{clearcal}}. You will recall that we split off the DATA column of the MS. {{clearcal}} will then create the MODEL_DATA column (initialized to unity) and the CORRECTED_DATA column (initialized to the values in the DATA column), to remove any previous calibration information and ready the data set for full calibration.<br />
<br />
<source lang="python"><br />
clearcal(vis='3c391_ctm_mosaic_10s.ms')<br />
</source><br />
<br />
We have now created the starting data set for the [[EVLA_Continuum_Tutorial_3C391]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Obtaining_EVLA_Data:_3C_391_Example&diff=3691Obtaining EVLA Data: 3C 391 Example2010-06-03T19:46:14Z<p>Jgallimo: /* Converting to a measurement set */</p>
<hr />
<div>== Appendix: Obtaining Data: 3C 391 Example ==<br />
<br />
For the purposes of the summer school tutorials, a small number of initial processing steps had been applied. Here we describe in more detail the series of steps that one is likely to have to conduct to obtain a data set similar to what was used for the summer school tutorials, using the 3C 391 data set as an example.<br />
<br />
The original test data were taken on 2010 April 24, and are stored as file TDEM0001_sb1218006_1.55310.33439732639 .<br />
<br />
=== Acquiring data from the Archive ===<br />
<br />
The data are publicly available from the [https://archive.nrao.edu/archive/archiveproject.jsp NRAO archive], under Project (Proposal) Name TDEM0001. When submitting an archive query with this project name, 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 (TDEM0001_sb1218006_1.55310.33439732639; file size 39.79 GB). This file contains data at the full 1-s time resolution. You can select to download an SDM file from the archive, a measurement set, or an AIPS UVFITS file. In the latter two cases, you can opt for spectral or temporal averaging of the data. Spectral averaging prior to bandpass calibration is discouraged, since it can cause phase decorrelation. Whether or not to temporal average will depend on the array configuration, field of view, and acceptable level of time-average smearing. In this example, we opt not to perform any spectral or temporal averaging, and later show how this may be done after the fact by running the task [[split]] on the measurement set.<br />
<br />
Since the purpose of this tutorial is to demonstrate the steps involved in obtaining one's data from the archive, we will download the data in as unprocessed a format as possible, namely an SDM-BDF dataset (all files). To create a single file (rather than a directory) for downloading, we check the "Create MS or SDM tar file" box, and also check the box labelled "Apply flags generated during observing", to remove data known to be bad (for instance, antennas which are off source during slewing operations).<br />
<br />
Having entered your email address at the top of the form and selected the required data set, we now request to "Download checked files". When the data have been copied to the relevant directory, you will receive an email. Follow its instructions to download the tarred SDM file.<br />
<br />
=== Converting to a measurement set ===<br />
<br />
Now that we have the SDM file, untar the file to create a new directory. Then start up CASA, as described in [[Getting_Started_in_CASA]].<br />
<br />
Within CASA, the task {{importevla}} will convert a Science Data Model (SDM file) into the Measurement Set (MS) that we will process further using CASA.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importevla(asdm='TDEM0001_sb1218006_1.55310.33439732639',vis='3c391_mosaic_fullres.ms',<br />
flagzero=True,cliplevel=1e-08,flagpol=True,shadow=True, diameter=28.0)<br />
</source><br />
[[Image:3c391 ctm importevla parameters.jpg|200px|thumb|right|importevla inputs]]<br />
<br />
While most parameters can be set to their default value, the following should be set explicitly:<br />
* asdm='TDEM0001_sb1218006_1.55310.33439732639' : We must specify the location of the SDM file to be converted.<br />
* vis='3c391_mosaic_fullres.ms' : We must provide a name for the MS to be created.<br />
* flagzero=True : A small fraction of the data is exactly zero, and we wish to get rid of these points, since they are a product of the WIDAR correlator, and do not represent real visibilities. This flagging will proceed via a simple clip, and we must specify the ''cliplevel'', which we set to 1e-08. Anything less than this is unlikely to be real. Since for polarization observations we do not wish to keep the cross-hand visibilities if the parallel hands are zero, we also set ''flagpol=True''.<br />
* shadow=True : When observing at low declinations, particularly in compact configurations, one antenna may block the line of sight between another antenna and the source of interest. This effect is known as shadowing. It is strongly recommended that all data suffering from shadowing be flagged. Knowing the antenna positions, the hour angle and elevation of the source, the shadowing can be computed as a function of antenna and time. By setting the ''shadow'' parameter, we opt to flag all shadowed data, regardless of source. To be conservative, we specify ''diameter=28.0'' to set the assumed antenna diameter for calculation of when antennas are shadowed.<br />
<br />
This task will take some time to execute, since the SDM file is large (39.79GB) and after creating the MS, it runs {{flagdata}}, inspecting every visibility inspected for zeroes and for shadowing.<br />
<br />
=== Averaging the data ===<br />
<br />
Depending upon the science goals and the details of the observation, averaging in time, frequency, or both may be possible at this stage. For instance, the 3C 391 data used in the summer school tutorial were acquired with a 1-second sampling in the D configuration. Given the size of 3C 391 itself, and the fact that there are no other strong nearby sources, it makes sense to average these data in time (and possibly in frequency as well, although that was not done for the summer school). For the summer school tutorial itself, we also restricted ourselves to just a single spectral window, even though the observations were acquired with two spectral windows. To create a data set averaged in time, we use the task [[split]].<br />
<br />
[[Image:3C391_precal_split_parameters.png|200px|thumb|right|split inputs]]<br />
<br />
<source lang="python"><br />
split(vis='3c391_mosaic_fullres.ms',outputvis='3c391_ctm_mosaic_10s.ms',datacolumn='data',<br />
spw='0',width=1,timebin='10s')<br />
</source><br />
<br />
This results in a single spectral window, with an unchanged frequency resolution, averaged to 10-second sampling.<br />
* outputvis='3c391_ctm_mosaic_10s.ms' : We specify the name of the new, time-averaged MS.<br />
* datacolumn='data' : In this case, since we have not performed any calibration, we want to take the visibilities from the uncorrected, DATA, column. Were we splitting off the data after calibration, we would instead select the CALIBRATED_DATA column.<br />
* timebin='10s' : Here we specify the time averaging to apply; we write out visibilities averaged to 10s sampling.<br />
* width=1 : This is the number of channels to average to form a single output channel. Here we do no frequency averaging.<br />
* spw='0' : Select only the lower-frequency spectral window (to halve the size of the data set; if you wish to derive spectral index information by using both frequencies, you should set '' spw='' '').<br />
<br />
Having created our new 10-s averaged data set, the final step is to create the scratch columns needed in further processing. To do so, we run [[clearcal]]. You will recall that we split off the DATA column of the MS. [[clearcal]] will then create the MODEL_DATA column (initialized to unity) and the CORRECTED_DATA column (initialized to the values in the DATA column), to remove any previous calibration information and ready the data set for full calibration.<br />
<br />
<source lang="python"><br />
clearcal(vis='3c391_ctm_mosaic_10s.ms')<br />
</source><br />
<br />
We have now created the starting data set for the [[EVLA_Continuum_Tutorial_3C391]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=3690EVLA Advanced Topics 3C3912010-06-03T19:43:40Z<p>Jgallimo: /* Line studies */</p>
<hr />
<div>[[Category:EVLA]]<br />
<br />
= Continuum Observations Data Reduction Tutorial: 3C 391---Advanced Topics =<br />
<br />
In this document, we discuss various "advanced topics" for further reduction of the 3C 391 continuum data. This tutorial assumes that the reader already has some familiarity with basic continuum data reduction, such as should have been obtained [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]]<br />
on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. If one did not participate in the EVLA Continuum Data Reduction Tutorial, one could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script and process the data to form an initial image. Current experience on a standard desktop computer suggests that such a data set could be processed in 30 min. or less.<br />
<br />
== Image Analysis and Manipulation ==<br />
<br />
This topic is perhaps not "advanced," but it appears to fit more naturally here. It is assumed that an image 3c391_ctm_spw0_IQUV.image, resulting from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] exists.<br />
<br />
The three most basic analyses are to determine the peak brightness, the flux density, and the image noise level. These are useful measures of how well one's imaging efforts are in approaching the thermal noise limit or in reproducing what is already known about a source. Additional discussion of image analysis and manipulation, including the combination of multiple images, mathematical operations on images, and much more can be found in [http://casa.nrao.edu/docs/userman/UserManch6.html#x310-3050006 Image Analysis] in the CASA Reference Book.<br />
<br />
The most straightforward statistic is the peak brightness, which is determined by {{imstat}}.<br />
<source lang="python"><br />
imstat(imagename='3c391_ctm_spw0_IQUV.image',stokes='')<br />
</source><br />
* stokes=' ' : This example determines the peak brightness in the <EM>entire</EM> image, which has all four Stokes planes. If one wanted to determine the peak brightness in just, say, the Stokes V image, one would set stokes='V'.<br />
<br />
The other two statistics require slightly more care. The flux density of a source is determined by integrating its brightness or intensity over some solid angle, i.e., <math>S = \int d\Omega I</math>, where <math>I</math> is the intensity (measured in units of Jy/beam), <math>\Omega</math> is the solid angle of the source (e.g., number of synthesized beams), and <math>S</math> is the flux density (measured in units of Jy). In general, if the noise is well-behaved in one's image, when averaged over a reasonable solid angle, the noise contribution should approach 0 Jy. If that is the case, then the flux density of the source is also reported by {{imstat}}. However, there are many cases for which a noise contribution of 0 Jy may not be a safe assumption. If one's source is in a complicated region (e.g., a star formation region, the Galactic center, near the edge of a galaxy), a better estimate of the source's flux density will be obtained by limiting carefully the solid angle over which the integration is performed.<br />
<br />
[[Image:3C391_viewer.jpg|200px|thumb|right|polygon region button selection]]<br />
<br />
Open {{viewer}} and use it to display an image, such as 3c391_ctm_spw0_IQUV.image. One can choose the function assigned to each mouse button; assign 'polygon region' to a desired mouse button (e.g., right button) by selecting the icon shown in the figure to the right with the desired mouse button.<br />
<br />
Using the mouse button just assigned to 'polygon region', outline the supernova remnant. Double click inside of that region, and the statistics will be reported. In fact, two sets of statistics will be returned. In the window one is using for casapy itself will be a set of statistics determined over the <EM>entire</EM> image cube; a new pop-up window will also appear, showing the image statistics for the particular Stokes plane being displayed in the {{viewer}}. One of the statistics reported will be the flux density within the region selected. (For the record, one of the authors of this document found a flux density of about 2.4 Jy.)<br />
<br />
[[Image:3C391_rmsnoise.jpg|200px|thumb|right|polygonal region for determining image statistics]]<br />
<br />
By contrast, for the rms noise level, one wants to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. In the region illustrated in the figure to the right, one of the authors of this document found an rms noise level of 1.4 mJy/beam.<br />
<br />
== Polarization Imaging ==<br />
<br />
[[Image:3C391_full_pol_image_i_settings.png|200px|thumb|right|data display options for total intensity contours]]<br />
In the previous data reduction tutorial, a full polarization imaging cube of 3C 391 was constructed. This cube has 3 dimensions, the standard two angular dimensions (right ascension, declination) and a third dimension containing the polarization information. Considering the image cube as a matrix, <math>Image[l,m,p]</math>, the <math>l</math> and <math>m</math> axis describe the sky brightness or intensity for the given <math>p</math> axis. If one opens the {{viewer}} and loads the 3C 391 continuum image, the default view contains an "animator" or pane with movie controls. One can step through the polarization axis, displaying the images for the different polarizations.<br />
<br />
As [[EVLA Continuum Tutorial 3C391#Imaging | constructed]], the image contains four polarizations, for the four Stokes parameters, I, Q, U, and V. Recalling the lectures, Q and U describe the linear polarization and V describes the circular polarization. Specifically, Q describes the amount of linear polarization aligned with a given axis, and U describes the amount of linear polarization at a 45 deg angle to that axis. The V parameter describes the amount of circular polarization, with the sign (positive or negative) describing the sense of the circular polarization (right- or left-hand circularly polarized).<br />
<br />
In general, few celestial sources are expected to show circular polarization, with the notable exception of masers, while terrestrial and satellite sources are often highly circularly polarized. The V image is therefore often worth forming because any V emission could be indicative of unflagged RFI within the data (or problems with the calibration!).<br />
<br />
Because the Q and U images both describe the amount of linear polarization, it is more common to work with a linear polarization intensity image, <math>P = \sqrt{Q^2 +U^2}</math>. (<math>P</math> can also be denoted by <math>L</math>.) Also important can be the polarization position angle <math>tan 2\chi = U/Q</math>.<br />
<br />
[[Image:3C391_full_pol_image_vector_settings.png|200px|thumb|right|data display options for position angle vectors]]<br />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/userman/UserMansu275.html#x326-3210006.5.1.2 Polarization Manipulation]. The steps are the following.<br />
<br />
1. Extract the I, Q, U, V planes from the full Stokes image cube, forming separate images for each Stokes parameter.<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.I',expr='IM0',stokes='I')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.Q',expr='IM0',stokes='Q')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.U',expr='IM0',stokes='U')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.V',expr='IM0',stokes='V')<br />
</source><br />
<br />
2. Combine the Q and U images using the mode='poli' option of {{immath}} to form the linear polarization image.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='poli',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.P',sigma='0.08mJy/beam')<br />
</source><br />
To correct for bias (the P image does not obey Gaussian statistics), we must supply the noise level in the Stokes Q and U images (these should be similar), using the ''sigma'' parameter. These noise levels can be estimated as described in the [[Advanced Topics#Image Analysis and Manipulation|Image Analysis and Manipulation]] section above.<br />
<br />
3. If desired, combine the Q and U images using the mode='pola' option of {{immath}} to form the polarization position angle image. Because the polarization position angle is derived from the tangent function, the order in which the Q and U images are specified is important.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='pola',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.X',sigma='0.08mJy/beam',<br />
polithresh='0.4mJy/beam')<br />
</source><br />
Again, we supply the noise level. To avoid displaying the position angle of noise, we can set a threshold intensity of the linear polarization for above which we wish to calculate the polarization angle, using the ''polithresh'' parameter. An appropriate level here might be the <math>5\sigma</math> level of 0.4 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],mode='evalexpr',<br />
expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)')<br />
</source><br />
Since the total intensity image can (and hopefully does) approach zero in regions free of source emission, dividing by the total intensity can produce very high pixel values in these regions. We therefore wish to restrict our fractional polarization image to regions containing real emission, which we do by setting a threshold in the total intensity image, which in this case corresponds to three times the noise level. The computation of the polarized intensity is specified by ''expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)' '', with the expression in square brackets setting the threshold in IM0 (the total intensity image). Note that IM0, IM1 and IM2 correspond to the three files listed in the ''imagename'' array, '''in that order'''. The order in which the different images are specified is therefore critical once again.<br />
<br />
One can then view these various images using {{viewer}}. It is instructive to display the I, P and X images (total intensity, total linearly polarized intensity, and polarization position angle) together, to show how the polarized emission relates to the total intensity, and how the magnetic field is structured. We can do this using the viewer.<br />
* Begin by loading the linear polarization image in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0.P')<br />
</source><br />
* Next, load the total intensity image as a contour image. In the viewer panel, hit the "Open" icon (the leftmost button in the top row of icons in the viewer). This will bring up a 'Load Data' GUI showing all images and MS in the current directory. Select the total intensity image (3c391_ctm_spw0.I) and click the 'Contour Map' button on the right hand side.<br />
* Finally, load the polarization position angle image (3c391_ctm_spw0.X) as a vector map.<br />
<br />
While we set the ''polithresh'' parameter when we created the position angle (X) image, a digression here is instructive in the use of LEL Expressions. Had we not set this parameter, the position angle would have been derived for all pixels within the full IQUV image cube. There is only polarized emission from a limited subset of pixels within this image. Therefore, to avoid plotting vectors corresponding to the position angle of pure noise, we would now wish to select only the regions where the polarized intensity is brighter than some threshold value. To do this, we would use a LEL (Lattice Expression Language) Expression in the 'Load Data' GUI. For our chosen threshold of 0.4 mJy (the 5 sigma level in the P image), we would paste the expression '' '3C391_ctm_spw0.X'['3C391_ctm_spw0.P'>0.0004] '' into the LEL Expression box in the GUI, and click the 'Vector Map' button. This would load the vectors only for regions where <math>P>0.4</math> mJy.<br />
<br />
[[Image:3C391_full_pol_image.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.P) in color, the total intensity (3c391_ctm_spw0.I) as a contour map, and the polarization position angle (3c391_ctm_spw0.X) as a vector map), we still wish to optimize the display for ease of interpretation.<br />
* Change the image transfer function. Hold down the middle mouse button and move the mouse until the color scale is optimized for the display of the polarized intensity.<br />
* Change the contour levels. Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. Select the total intensity tab (3c391_ctm_spw0.I). Change the relative contour levels from the default levels of [0.2,0.4,0.6,0.8,1.0] to powers of <math>\sqrt{2}</math>, including a couple of negative contours at the beginning to demonstrate the image quality. An appropriate set of levels might be [-1.414,-1,1,1.414,2,2.828,4,5.657,8,11.314,16,22.627,32,45.255,64]. These levels will multiply the Unit Contour Level, which we set at some multiple of the rms noise in the total intensity image. An appropriate value might be 0.0024 Jy (<math>3\sigma</math>).<br />
* Change the vector spacing and color, and rotate the vectors. The polarization position angle as calculated is the electric vector position angle (EVPA). If we are interested in the orientation of the magnetic field, then for an optically thin source, the magnetic field orientation is perpendicular to the EVPA, so we must rotate the vectors by <math>90^{\circ}</math>. Select the vector image tab in the 'Data Display Options' GUI (labeled as the LEL expression we entered in the Load Data GUI) and enter ''90'' in the ''Extra rotation'' box. If the vectors appear too densely packed on the image, change the spacing of the vectors by setting ''X-increment'' and ''Y-increment'' to a larger value (8 might be appropriate here). Finally, to be able to distinguish the vectors from the total intensity contours, change the color of the vectors by selecting a different ''Line color'' (red might be a good choice).<br />
<br />
Now that we have altered the display to our satisfaction, it remains only to zoom in to the region containing the emission. Close the animator tab in the viewer, and then drag out a rectangular region around the supernova remnant with your left mouse button. Double-click to zoom in to that region. This will give you a final image looking something like that shown at right.<br />
<br />
== Spectral Index Imaging ==<br />
<br />
The spectral index, defined as the slope of the radio spectrum between two different frequencies, <math>\log(S_{\nu_1}/S_{\nu_2})/\log(\nu_1/\nu_2)</math>, is a useful analytical tool which can convey information about the emission mechanism, the optical depth of the source or the underlying energy distribution of synchrotron-radiating electrons.<br />
<br />
Having used {{immath}} to manipulate the polarization images, the reader should now have some familiarity with performing mathematical operations within CASA. {{immath}} also has a special mode for calculating the spectral index, ''mode='spix' ''. The two input images at different frequencies should be provided using the parameter (in this case, the Python list) ''imagename''. With this information, it is left as an exercise for the reader to create a spectral index map.<br />
<br />
The two input images could be the two different spectral windows from the 3C391 continuum data set. If the higher-frequency spectral window (spw1) has not yet been reduced, then two images made with different channel ranges from the lower spectral window, spw0, should suffice. In this latter case, the extreme upper and lower channels are suggested, to provide a sufficient lever arm in frequency to measure a believable spectral index.<br />
<br />
== Self-Calibration ==<br />
<br />
Recalling the lectures, even after the initial calibration using the amplitude calibrator and the phase calibrator, there are likely to be residual phase and/or amplitude errors in the data. Self-calibration is the process of using an existing model, often constructed by imaging the data itself. Provided that sufficient visibility data have been obtained, and this is essentially always the case with the EVLA (and often the VLBA, and should be with ALMA), the system of equations is wildly over-constrained for the number of unknowns. <br />
<br />
More specifically, the observed visibility data on the <math>i</math>-<math>j</math> baseline can be modeled as <br />
<br />
<math><br />
V'_{ij} = G_i G^*_j V_{ij}<br />
</math><br />
<br />
where <math>G_i</math> is the complex gain for the <math>i^{\mathrm{th}}</math> antenna and <math>V_{ij}</math> is the "true" visibility. For an array of <math>N</math> antennas, at any given instant, there are <math>N(N-1)/2</math> visibility data, but only <math>N</math> gain factors. For an array with a reasonable number of antennas, <math>N</math> >~ 8, solutions to this set of coupled equations converge quickly.<br />
<br />
There is a small amount of discussion in the CASA Reference Manual on <br />
[http://casa.nrao.edu/docs/userman/UserManse30.html#x307-3020005.8 self calibration]. In self-calibrating data, it is useful to keep in mind the structure of a Measurement Set: there are three columns of interest for an MS, the DATA column, the MODEL column, and the CORRECTED_DATA column. In normal usage, as part of the initial split, the CORRECTED_DATA column is set equal to the DATA column. The self-calibration procedure is then <br />
<br />
* Produce an image ({{clean}}) using the CORRECTED_DATA column.<br />
* Derive a series of gain corrections ({{gaincal}}) by comparing the DATA columns and the Fourier transform of the image, which is stored in the MODEL column. These corrections are stored in an external table.<br />
* Apply these corrections ({{applycal}}) to the DATA column, to form a new CORRECTED_DATA column, <em>overwriting</em> the previous contents of CORRECTED_DATA.<br />
<br />
The following example begins with the standard data set, 3c391_ctm_mosaic_spw0.ms, resulting from the [[EVLA Continuum Tutorial 3C391 | 3C391 Continuum Tutorial]]. A model image is generated (3c391_ctm_spw0_IQUV.image), this model is used to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.G2), those gain corrections are applied to the data to form a set of self-calibrated data, and new image is then formed (3c391_ctm_spw0_IQUV_G2.image).<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3C391_ctm_mosaic_spw0.G2',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
solnorm=True,gaintype='G',calmode='p',append=False)<br />
<br />
applycal(vis='3c391_ctm_mosaic_spw0.ms',<br />
field='',spw='',selectdata=False,<br />
gaintable= ['3c391_ctm_mosaic_spw0.G2'],gainfield=[''],interp=['nearest'])<br />
<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_G2',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
Commonly, this procedure is applied multiple times.<br />
The number of iterations is determined by a combination of the data quality and number of antennas in the array, the structure of the source, the extent to which the original self-calibration assumptions are valid, and the user's patience. With reference to the original self-calibration equation above, if the observed visibility data cannot be modeled well by this equation, no amount of self-calibration will help. A not-uncommon limitation for moderately high dynamic range imaging is that there may be <em>baseline-based</em> factors that modify the "true" visibility. If the corruptions to the "true" visibility cannot be modeled as antenna-based, as they are above, self-calibration won't help.<br />
<br />
Self-calibration requires experimentation. Do not be afraid to dump an image, or even a set of gain corrections, <br />
change something and try again. Having said that, here are several general comments or guidelines:<br />
<br />
* Bookkeeping is important! Suppose one conducts 9 iterations of self-calibration. Will it be possible to remember one month later (or maybe even one week later!) which set of gain corrections and images are which? In the example above, the descriptor 'G2' is attached to various files to help keep straight which is what. 'G2' is used because the original calibration already included a gain calibration, in 'G1'. Successive iterations of self-cal could then be 'G3', 'G4', etc.<br />
<br />
* A common metric for whether self-calibration is whether the image <em>dynamic range</em> (= max/rms) has improved. An improvement of 10% is quite acceptable.<br />
<br />
* Be careful when making images and setting CLEAN regions or masks. Self-calibration assumes that the model is "perfect." If one CLEANs a noise bump, self-calibration will quite happily try to adjust the gains so that the CORRECTED_DATA describe a source at the location of the noise bump. As the author demonstrated to himself during the writing of his thesis, it is quite possible to take completely noisy data and manufacture a source. It is far better to exclude some feature of a source or a weak source from initial CLEANing and conduct another round of self-calibration than to create an artificial source. If a real source is excluded from initial CLEANing, it will continue to be present in subsequent iterations of self-calibration; if it's not a real source, one probably isn't interested in it anyway.<br />
<br />
* Start self-calibration with phase-only solutions (calmode='p' in {{gaincal}}). As [http://adsabs.harvard.edu/abs/1989ASPC....6..287P Rick Perley] has discussed in previous summer school lectures, a phase error of 20 deg is as bad as an amplitude error of 10%.<br />
<br />
* In initial rounds of self-calibration, consider solution intervals longer than the nominal sampling time (solint in {{gaincal}}) and/or lower signal-to-noise ratio thresholds (minsnr in {{gaincal}}). Depending upon the frequency and configuration and fidelity of the model image, it can be quite reasonable to start with solint='30s' or solint='60s' and/or minsnr=3 (or even lower). One might also want to consider specifying a uvrange, if, for example, the field has structure on large scales (small <math>u</math>-<math>v</math>) that is not well represented by the current image.<br />
<br />
* One can track the agreement between the DATA, CORRECTED_DATA, and MODEL in {{plotms}}. The options in 'Axes' allows one to select which column is to be plotted. If the MODEL agrees well with the CORRECTED_DATA, one can use shorter solint and/or higher minsnr values.<br />
<br />
== Line studies ==<br />
<br />
A second data set on 3C391 was taken, this time in OSRO-2 mode, centered on the formaldehyde line at 4829.66 MHz, to search for absorption against the supernova remnant. Again, we made a 7-pointing mosaic, with the same pointing centers as the continuum data set. If you have also already gone through the [[EVLA Spectral Line Calibration IRC+10216]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391]], you should be able to combine what you have learned from these two tutorials to reduce this spectral line study of 3C 391. Should you wish to do so, a 10-s averaged data set, with some pre-flagging done, is available from the [http://casa.nrao.edu/Data/EVLA/3C391/3c391_line_10s_summerschool.ms.tgz CASA repository].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=3689EVLA Advanced Topics 3C3912010-06-03T19:43:15Z<p>Jgallimo: /* Self-Calibration */</p>
<hr />
<div>[[Category:EVLA]]<br />
<br />
= Continuum Observations Data Reduction Tutorial: 3C 391---Advanced Topics =<br />
<br />
In this document, we discuss various "advanced topics" for further reduction of the 3C 391 continuum data. This tutorial assumes that the reader already has some familiarity with basic continuum data reduction, such as should have been obtained [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]]<br />
on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. If one did not participate in the EVLA Continuum Data Reduction Tutorial, one could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script and process the data to form an initial image. Current experience on a standard desktop computer suggests that such a data set could be processed in 30 min. or less.<br />
<br />
== Image Analysis and Manipulation ==<br />
<br />
This topic is perhaps not "advanced," but it appears to fit more naturally here. It is assumed that an image 3c391_ctm_spw0_IQUV.image, resulting from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] exists.<br />
<br />
The three most basic analyses are to determine the peak brightness, the flux density, and the image noise level. These are useful measures of how well one's imaging efforts are in approaching the thermal noise limit or in reproducing what is already known about a source. Additional discussion of image analysis and manipulation, including the combination of multiple images, mathematical operations on images, and much more can be found in [http://casa.nrao.edu/docs/userman/UserManch6.html#x310-3050006 Image Analysis] in the CASA Reference Book.<br />
<br />
The most straightforward statistic is the peak brightness, which is determined by {{imstat}}.<br />
<source lang="python"><br />
imstat(imagename='3c391_ctm_spw0_IQUV.image',stokes='')<br />
</source><br />
* stokes=' ' : This example determines the peak brightness in the <EM>entire</EM> image, which has all four Stokes planes. If one wanted to determine the peak brightness in just, say, the Stokes V image, one would set stokes='V'.<br />
<br />
The other two statistics require slightly more care. The flux density of a source is determined by integrating its brightness or intensity over some solid angle, i.e., <math>S = \int d\Omega I</math>, where <math>I</math> is the intensity (measured in units of Jy/beam), <math>\Omega</math> is the solid angle of the source (e.g., number of synthesized beams), and <math>S</math> is the flux density (measured in units of Jy). In general, if the noise is well-behaved in one's image, when averaged over a reasonable solid angle, the noise contribution should approach 0 Jy. If that is the case, then the flux density of the source is also reported by {{imstat}}. However, there are many cases for which a noise contribution of 0 Jy may not be a safe assumption. If one's source is in a complicated region (e.g., a star formation region, the Galactic center, near the edge of a galaxy), a better estimate of the source's flux density will be obtained by limiting carefully the solid angle over which the integration is performed.<br />
<br />
[[Image:3C391_viewer.jpg|200px|thumb|right|polygon region button selection]]<br />
<br />
Open {{viewer}} and use it to display an image, such as 3c391_ctm_spw0_IQUV.image. One can choose the function assigned to each mouse button; assign 'polygon region' to a desired mouse button (e.g., right button) by selecting the icon shown in the figure to the right with the desired mouse button.<br />
<br />
Using the mouse button just assigned to 'polygon region', outline the supernova remnant. Double click inside of that region, and the statistics will be reported. In fact, two sets of statistics will be returned. In the window one is using for casapy itself will be a set of statistics determined over the <EM>entire</EM> image cube; a new pop-up window will also appear, showing the image statistics for the particular Stokes plane being displayed in the {{viewer}}. One of the statistics reported will be the flux density within the region selected. (For the record, one of the authors of this document found a flux density of about 2.4 Jy.)<br />
<br />
[[Image:3C391_rmsnoise.jpg|200px|thumb|right|polygonal region for determining image statistics]]<br />
<br />
By contrast, for the rms noise level, one wants to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. In the region illustrated in the figure to the right, one of the authors of this document found an rms noise level of 1.4 mJy/beam.<br />
<br />
== Polarization Imaging ==<br />
<br />
[[Image:3C391_full_pol_image_i_settings.png|200px|thumb|right|data display options for total intensity contours]]<br />
In the previous data reduction tutorial, a full polarization imaging cube of 3C 391 was constructed. This cube has 3 dimensions, the standard two angular dimensions (right ascension, declination) and a third dimension containing the polarization information. Considering the image cube as a matrix, <math>Image[l,m,p]</math>, the <math>l</math> and <math>m</math> axis describe the sky brightness or intensity for the given <math>p</math> axis. If one opens the {{viewer}} and loads the 3C 391 continuum image, the default view contains an "animator" or pane with movie controls. One can step through the polarization axis, displaying the images for the different polarizations.<br />
<br />
As [[EVLA Continuum Tutorial 3C391#Imaging | constructed]], the image contains four polarizations, for the four Stokes parameters, I, Q, U, and V. Recalling the lectures, Q and U describe the linear polarization and V describes the circular polarization. Specifically, Q describes the amount of linear polarization aligned with a given axis, and U describes the amount of linear polarization at a 45 deg angle to that axis. The V parameter describes the amount of circular polarization, with the sign (positive or negative) describing the sense of the circular polarization (right- or left-hand circularly polarized).<br />
<br />
In general, few celestial sources are expected to show circular polarization, with the notable exception of masers, while terrestrial and satellite sources are often highly circularly polarized. The V image is therefore often worth forming because any V emission could be indicative of unflagged RFI within the data (or problems with the calibration!).<br />
<br />
Because the Q and U images both describe the amount of linear polarization, it is more common to work with a linear polarization intensity image, <math>P = \sqrt{Q^2 +U^2}</math>. (<math>P</math> can also be denoted by <math>L</math>.) Also important can be the polarization position angle <math>tan 2\chi = U/Q</math>.<br />
<br />
[[Image:3C391_full_pol_image_vector_settings.png|200px|thumb|right|data display options for position angle vectors]]<br />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/userman/UserMansu275.html#x326-3210006.5.1.2 Polarization Manipulation]. The steps are the following.<br />
<br />
1. Extract the I, Q, U, V planes from the full Stokes image cube, forming separate images for each Stokes parameter.<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.I',expr='IM0',stokes='I')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.Q',expr='IM0',stokes='Q')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.U',expr='IM0',stokes='U')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.V',expr='IM0',stokes='V')<br />
</source><br />
<br />
2. Combine the Q and U images using the mode='poli' option of {{immath}} to form the linear polarization image.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='poli',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.P',sigma='0.08mJy/beam')<br />
</source><br />
To correct for bias (the P image does not obey Gaussian statistics), we must supply the noise level in the Stokes Q and U images (these should be similar), using the ''sigma'' parameter. These noise levels can be estimated as described in the [[Advanced Topics#Image Analysis and Manipulation|Image Analysis and Manipulation]] section above.<br />
<br />
3. If desired, combine the Q and U images using the mode='pola' option of {{immath}} to form the polarization position angle image. Because the polarization position angle is derived from the tangent function, the order in which the Q and U images are specified is important.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='pola',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.X',sigma='0.08mJy/beam',<br />
polithresh='0.4mJy/beam')<br />
</source><br />
Again, we supply the noise level. To avoid displaying the position angle of noise, we can set a threshold intensity of the linear polarization for above which we wish to calculate the polarization angle, using the ''polithresh'' parameter. An appropriate level here might be the <math>5\sigma</math> level of 0.4 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],mode='evalexpr',<br />
expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)')<br />
</source><br />
Since the total intensity image can (and hopefully does) approach zero in regions free of source emission, dividing by the total intensity can produce very high pixel values in these regions. We therefore wish to restrict our fractional polarization image to regions containing real emission, which we do by setting a threshold in the total intensity image, which in this case corresponds to three times the noise level. The computation of the polarized intensity is specified by ''expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)' '', with the expression in square brackets setting the threshold in IM0 (the total intensity image). Note that IM0, IM1 and IM2 correspond to the three files listed in the ''imagename'' array, '''in that order'''. The order in which the different images are specified is therefore critical once again.<br />
<br />
One can then view these various images using {{viewer}}. It is instructive to display the I, P and X images (total intensity, total linearly polarized intensity, and polarization position angle) together, to show how the polarized emission relates to the total intensity, and how the magnetic field is structured. We can do this using the viewer.<br />
* Begin by loading the linear polarization image in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0.P')<br />
</source><br />
* Next, load the total intensity image as a contour image. In the viewer panel, hit the "Open" icon (the leftmost button in the top row of icons in the viewer). This will bring up a 'Load Data' GUI showing all images and MS in the current directory. Select the total intensity image (3c391_ctm_spw0.I) and click the 'Contour Map' button on the right hand side.<br />
* Finally, load the polarization position angle image (3c391_ctm_spw0.X) as a vector map.<br />
<br />
While we set the ''polithresh'' parameter when we created the position angle (X) image, a digression here is instructive in the use of LEL Expressions. Had we not set this parameter, the position angle would have been derived for all pixels within the full IQUV image cube. There is only polarized emission from a limited subset of pixels within this image. Therefore, to avoid plotting vectors corresponding to the position angle of pure noise, we would now wish to select only the regions where the polarized intensity is brighter than some threshold value. To do this, we would use a LEL (Lattice Expression Language) Expression in the 'Load Data' GUI. For our chosen threshold of 0.4 mJy (the 5 sigma level in the P image), we would paste the expression '' '3C391_ctm_spw0.X'['3C391_ctm_spw0.P'>0.0004] '' into the LEL Expression box in the GUI, and click the 'Vector Map' button. This would load the vectors only for regions where <math>P>0.4</math> mJy.<br />
<br />
[[Image:3C391_full_pol_image.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.P) in color, the total intensity (3c391_ctm_spw0.I) as a contour map, and the polarization position angle (3c391_ctm_spw0.X) as a vector map), we still wish to optimize the display for ease of interpretation.<br />
* Change the image transfer function. Hold down the middle mouse button and move the mouse until the color scale is optimized for the display of the polarized intensity.<br />
* Change the contour levels. Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. Select the total intensity tab (3c391_ctm_spw0.I). Change the relative contour levels from the default levels of [0.2,0.4,0.6,0.8,1.0] to powers of <math>\sqrt{2}</math>, including a couple of negative contours at the beginning to demonstrate the image quality. An appropriate set of levels might be [-1.414,-1,1,1.414,2,2.828,4,5.657,8,11.314,16,22.627,32,45.255,64]. These levels will multiply the Unit Contour Level, which we set at some multiple of the rms noise in the total intensity image. An appropriate value might be 0.0024 Jy (<math>3\sigma</math>).<br />
* Change the vector spacing and color, and rotate the vectors. The polarization position angle as calculated is the electric vector position angle (EVPA). If we are interested in the orientation of the magnetic field, then for an optically thin source, the magnetic field orientation is perpendicular to the EVPA, so we must rotate the vectors by <math>90^{\circ}</math>. Select the vector image tab in the 'Data Display Options' GUI (labeled as the LEL expression we entered in the Load Data GUI) and enter ''90'' in the ''Extra rotation'' box. If the vectors appear too densely packed on the image, change the spacing of the vectors by setting ''X-increment'' and ''Y-increment'' to a larger value (8 might be appropriate here). Finally, to be able to distinguish the vectors from the total intensity contours, change the color of the vectors by selecting a different ''Line color'' (red might be a good choice).<br />
<br />
Now that we have altered the display to our satisfaction, it remains only to zoom in to the region containing the emission. Close the animator tab in the viewer, and then drag out a rectangular region around the supernova remnant with your left mouse button. Double-click to zoom in to that region. This will give you a final image looking something like that shown at right.<br />
<br />
== Spectral Index Imaging ==<br />
<br />
The spectral index, defined as the slope of the radio spectrum between two different frequencies, <math>\log(S_{\nu_1}/S_{\nu_2})/\log(\nu_1/\nu_2)</math>, is a useful analytical tool which can convey information about the emission mechanism, the optical depth of the source or the underlying energy distribution of synchrotron-radiating electrons.<br />
<br />
Having used {{immath}} to manipulate the polarization images, the reader should now have some familiarity with performing mathematical operations within CASA. {{immath}} also has a special mode for calculating the spectral index, ''mode='spix' ''. The two input images at different frequencies should be provided using the parameter (in this case, the Python list) ''imagename''. With this information, it is left as an exercise for the reader to create a spectral index map.<br />
<br />
The two input images could be the two different spectral windows from the 3C391 continuum data set. If the higher-frequency spectral window (spw1) has not yet been reduced, then two images made with different channel ranges from the lower spectral window, spw0, should suffice. In this latter case, the extreme upper and lower channels are suggested, to provide a sufficient lever arm in frequency to measure a believable spectral index.<br />
<br />
== Self-Calibration ==<br />
<br />
Recalling the lectures, even after the initial calibration using the amplitude calibrator and the phase calibrator, there are likely to be residual phase and/or amplitude errors in the data. Self-calibration is the process of using an existing model, often constructed by imaging the data itself. Provided that sufficient visibility data have been obtained, and this is essentially always the case with the EVLA (and often the VLBA, and should be with ALMA), the system of equations is wildly over-constrained for the number of unknowns. <br />
<br />
More specifically, the observed visibility data on the <math>i</math>-<math>j</math> baseline can be modeled as <br />
<br />
<math><br />
V'_{ij} = G_i G^*_j V_{ij}<br />
</math><br />
<br />
where <math>G_i</math> is the complex gain for the <math>i^{\mathrm{th}}</math> antenna and <math>V_{ij}</math> is the "true" visibility. For an array of <math>N</math> antennas, at any given instant, there are <math>N(N-1)/2</math> visibility data, but only <math>N</math> gain factors. For an array with a reasonable number of antennas, <math>N</math> >~ 8, solutions to this set of coupled equations converge quickly.<br />
<br />
There is a small amount of discussion in the CASA Reference Manual on <br />
[http://casa.nrao.edu/docs/userman/UserManse30.html#x307-3020005.8 self calibration]. In self-calibrating data, it is useful to keep in mind the structure of a Measurement Set: there are three columns of interest for an MS, the DATA column, the MODEL column, and the CORRECTED_DATA column. In normal usage, as part of the initial split, the CORRECTED_DATA column is set equal to the DATA column. The self-calibration procedure is then <br />
<br />
* Produce an image ({{clean}}) using the CORRECTED_DATA column.<br />
* Derive a series of gain corrections ({{gaincal}}) by comparing the DATA columns and the Fourier transform of the image, which is stored in the MODEL column. These corrections are stored in an external table.<br />
* Apply these corrections ({{applycal}}) to the DATA column, to form a new CORRECTED_DATA column, <em>overwriting</em> the previous contents of CORRECTED_DATA.<br />
<br />
The following example begins with the standard data set, 3c391_ctm_mosaic_spw0.ms, resulting from the [[EVLA Continuum Tutorial 3C391 | 3C391 Continuum Tutorial]]. A model image is generated (3c391_ctm_spw0_IQUV.image), this model is used to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.G2), those gain corrections are applied to the data to form a set of self-calibrated data, and new image is then formed (3c391_ctm_spw0_IQUV_G2.image).<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3C391_ctm_mosaic_spw0.G2',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
solnorm=True,gaintype='G',calmode='p',append=False)<br />
<br />
applycal(vis='3c391_ctm_mosaic_spw0.ms',<br />
field='',spw='',selectdata=False,<br />
gaintable= ['3c391_ctm_mosaic_spw0.G2'],gainfield=[''],interp=['nearest'])<br />
<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_G2',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
Commonly, this procedure is applied multiple times.<br />
The number of iterations is determined by a combination of the data quality and number of antennas in the array, the structure of the source, the extent to which the original self-calibration assumptions are valid, and the user's patience. With reference to the original self-calibration equation above, if the observed visibility data cannot be modeled well by this equation, no amount of self-calibration will help. A not-uncommon limitation for moderately high dynamic range imaging is that there may be <em>baseline-based</em> factors that modify the "true" visibility. If the corruptions to the "true" visibility cannot be modeled as antenna-based, as they are above, self-calibration won't help.<br />
<br />
Self-calibration requires experimentation. Do not be afraid to dump an image, or even a set of gain corrections, <br />
change something and try again. Having said that, here are several general comments or guidelines:<br />
<br />
* Bookkeeping is important! Suppose one conducts 9 iterations of self-calibration. Will it be possible to remember one month later (or maybe even one week later!) which set of gain corrections and images are which? In the example above, the descriptor 'G2' is attached to various files to help keep straight which is what. 'G2' is used because the original calibration already included a gain calibration, in 'G1'. Successive iterations of self-cal could then be 'G3', 'G4', etc.<br />
<br />
* A common metric for whether self-calibration is whether the image <em>dynamic range</em> (= max/rms) has improved. An improvement of 10% is quite acceptable.<br />
<br />
* Be careful when making images and setting CLEAN regions or masks. Self-calibration assumes that the model is "perfect." If one CLEANs a noise bump, self-calibration will quite happily try to adjust the gains so that the CORRECTED_DATA describe a source at the location of the noise bump. As the author demonstrated to himself during the writing of his thesis, it is quite possible to take completely noisy data and manufacture a source. It is far better to exclude some feature of a source or a weak source from initial CLEANing and conduct another round of self-calibration than to create an artificial source. If a real source is excluded from initial CLEANing, it will continue to be present in subsequent iterations of self-calibration; if it's not a real source, one probably isn't interested in it anyway.<br />
<br />
* Start self-calibration with phase-only solutions (calmode='p' in {{gaincal}}). As [http://adsabs.harvard.edu/abs/1989ASPC....6..287P Rick Perley] has discussed in previous summer school lectures, a phase error of 20 deg is as bad as an amplitude error of 10%.<br />
<br />
* In initial rounds of self-calibration, consider solution intervals longer than the nominal sampling time (solint in {{gaincal}}) and/or lower signal-to-noise ratio thresholds (minsnr in {{gaincal}}). Depending upon the frequency and configuration and fidelity of the model image, it can be quite reasonable to start with solint='30s' or solint='60s' and/or minsnr=3 (or even lower). One might also want to consider specifying a uvrange, if, for example, the field has structure on large scales (small <math>u</math>-<math>v</math>) that is not well represented by the current image.<br />
<br />
* One can track the agreement between the DATA, CORRECTED_DATA, and MODEL in {{plotms}}. The options in 'Axes' allows one to select which column is to be plotted. If the MODEL agrees well with the CORRECTED_DATA, one can use shorter solint and/or higher minsnr values.<br />
<br />
== Line studies ==<br />
<br />
A second data set on 3C391 was taken, this time in OSRO-2 mode, centered on the formaldehyde line at 4829.66 MHz, to search for absorption against the supernova remnant. Again, we made a 7-pointing mosaic, with the same pointing centers as the continuum data set. If you have also already gone through the [[EVLA Spectral Line Calibration IRC+10216]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391]], you should be able to combine what you have learned from these two tutorials to reduce this spectral line study of 3C 391. Should you wish to do so, a 10-s averaged data set, with some pre-flagging done, is available from the [[http://casa.nrao.edu/Data/EVLA/3C391/3c391_line_10s_summerschool.ms.tgz CASA repository]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=3688EVLA Advanced Topics 3C3912010-06-03T19:40:47Z<p>Jgallimo: /* Self-Calibration */</p>
<hr />
<div>[[Category:EVLA]]<br />
<br />
= Continuum Observations Data Reduction Tutorial: 3C 391---Advanced Topics =<br />
<br />
In this document, we discuss various "advanced topics" for further reduction of the 3C 391 continuum data. This tutorial assumes that the reader already has some familiarity with basic continuum data reduction, such as should have been obtained [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]]<br />
on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. If one did not participate in the EVLA Continuum Data Reduction Tutorial, one could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script and process the data to form an initial image. Current experience on a standard desktop computer suggests that such a data set could be processed in 30 min. or less.<br />
<br />
== Image Analysis and Manipulation ==<br />
<br />
This topic is perhaps not "advanced," but it appears to fit more naturally here. It is assumed that an image 3c391_ctm_spw0_IQUV.image, resulting from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] exists.<br />
<br />
The three most basic analyses are to determine the peak brightness, the flux density, and the image noise level. These are useful measures of how well one's imaging efforts are in approaching the thermal noise limit or in reproducing what is already known about a source. Additional discussion of image analysis and manipulation, including the combination of multiple images, mathematical operations on images, and much more can be found in [http://casa.nrao.edu/docs/userman/UserManch6.html#x310-3050006 Image Analysis] in the CASA Reference Book.<br />
<br />
The most straightforward statistic is the peak brightness, which is determined by {{imstat}}.<br />
<source lang="python"><br />
imstat(imagename='3c391_ctm_spw0_IQUV.image',stokes='')<br />
</source><br />
* stokes=' ' : This example determines the peak brightness in the <EM>entire</EM> image, which has all four Stokes planes. If one wanted to determine the peak brightness in just, say, the Stokes V image, one would set stokes='V'.<br />
<br />
The other two statistics require slightly more care. The flux density of a source is determined by integrating its brightness or intensity over some solid angle, i.e., <math>S = \int d\Omega I</math>, where <math>I</math> is the intensity (measured in units of Jy/beam), <math>\Omega</math> is the solid angle of the source (e.g., number of synthesized beams), and <math>S</math> is the flux density (measured in units of Jy). In general, if the noise is well-behaved in one's image, when averaged over a reasonable solid angle, the noise contribution should approach 0 Jy. If that is the case, then the flux density of the source is also reported by {{imstat}}. However, there are many cases for which a noise contribution of 0 Jy may not be a safe assumption. If one's source is in a complicated region (e.g., a star formation region, the Galactic center, near the edge of a galaxy), a better estimate of the source's flux density will be obtained by limiting carefully the solid angle over which the integration is performed.<br />
<br />
[[Image:3C391_viewer.jpg|200px|thumb|right|polygon region button selection]]<br />
<br />
Open {{viewer}} and use it to display an image, such as 3c391_ctm_spw0_IQUV.image. One can choose the function assigned to each mouse button; assign 'polygon region' to a desired mouse button (e.g., right button) by selecting the icon shown in the figure to the right with the desired mouse button.<br />
<br />
Using the mouse button just assigned to 'polygon region', outline the supernova remnant. Double click inside of that region, and the statistics will be reported. In fact, two sets of statistics will be returned. In the window one is using for casapy itself will be a set of statistics determined over the <EM>entire</EM> image cube; a new pop-up window will also appear, showing the image statistics for the particular Stokes plane being displayed in the {{viewer}}. One of the statistics reported will be the flux density within the region selected. (For the record, one of the authors of this document found a flux density of about 2.4 Jy.)<br />
<br />
[[Image:3C391_rmsnoise.jpg|200px|thumb|right|polygonal region for determining image statistics]]<br />
<br />
By contrast, for the rms noise level, one wants to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. In the region illustrated in the figure to the right, one of the authors of this document found an rms noise level of 1.4 mJy/beam.<br />
<br />
== Polarization Imaging ==<br />
<br />
[[Image:3C391_full_pol_image_i_settings.png|200px|thumb|right|data display options for total intensity contours]]<br />
In the previous data reduction tutorial, a full polarization imaging cube of 3C 391 was constructed. This cube has 3 dimensions, the standard two angular dimensions (right ascension, declination) and a third dimension containing the polarization information. Considering the image cube as a matrix, <math>Image[l,m,p]</math>, the <math>l</math> and <math>m</math> axis describe the sky brightness or intensity for the given <math>p</math> axis. If one opens the {{viewer}} and loads the 3C 391 continuum image, the default view contains an "animator" or pane with movie controls. One can step through the polarization axis, displaying the images for the different polarizations.<br />
<br />
As [[EVLA Continuum Tutorial 3C391#Imaging | constructed]], the image contains four polarizations, for the four Stokes parameters, I, Q, U, and V. Recalling the lectures, Q and U describe the linear polarization and V describes the circular polarization. Specifically, Q describes the amount of linear polarization aligned with a given axis, and U describes the amount of linear polarization at a 45 deg angle to that axis. The V parameter describes the amount of circular polarization, with the sign (positive or negative) describing the sense of the circular polarization (right- or left-hand circularly polarized).<br />
<br />
In general, few celestial sources are expected to show circular polarization, with the notable exception of masers, while terrestrial and satellite sources are often highly circularly polarized. The V image is therefore often worth forming because any V emission could be indicative of unflagged RFI within the data (or problems with the calibration!).<br />
<br />
Because the Q and U images both describe the amount of linear polarization, it is more common to work with a linear polarization intensity image, <math>P = \sqrt{Q^2 +U^2}</math>. (<math>P</math> can also be denoted by <math>L</math>.) Also important can be the polarization position angle <math>tan 2\chi = U/Q</math>.<br />
<br />
[[Image:3C391_full_pol_image_vector_settings.png|200px|thumb|right|data display options for position angle vectors]]<br />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/userman/UserMansu275.html#x326-3210006.5.1.2 Polarization Manipulation]. The steps are the following.<br />
<br />
1. Extract the I, Q, U, V planes from the full Stokes image cube, forming separate images for each Stokes parameter.<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.I',expr='IM0',stokes='I')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.Q',expr='IM0',stokes='Q')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.U',expr='IM0',stokes='U')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.V',expr='IM0',stokes='V')<br />
</source><br />
<br />
2. Combine the Q and U images using the mode='poli' option of {{immath}} to form the linear polarization image.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='poli',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.P',sigma='0.08mJy/beam')<br />
</source><br />
To correct for bias (the P image does not obey Gaussian statistics), we must supply the noise level in the Stokes Q and U images (these should be similar), using the ''sigma'' parameter. These noise levels can be estimated as described in the [[Advanced Topics#Image Analysis and Manipulation|Image Analysis and Manipulation]] section above.<br />
<br />
3. If desired, combine the Q and U images using the mode='pola' option of {{immath}} to form the polarization position angle image. Because the polarization position angle is derived from the tangent function, the order in which the Q and U images are specified is important.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='pola',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.X',sigma='0.08mJy/beam',<br />
polithresh='0.4mJy/beam')<br />
</source><br />
Again, we supply the noise level. To avoid displaying the position angle of noise, we can set a threshold intensity of the linear polarization for above which we wish to calculate the polarization angle, using the ''polithresh'' parameter. An appropriate level here might be the <math>5\sigma</math> level of 0.4 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],mode='evalexpr',<br />
expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)')<br />
</source><br />
Since the total intensity image can (and hopefully does) approach zero in regions free of source emission, dividing by the total intensity can produce very high pixel values in these regions. We therefore wish to restrict our fractional polarization image to regions containing real emission, which we do by setting a threshold in the total intensity image, which in this case corresponds to three times the noise level. The computation of the polarized intensity is specified by ''expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)' '', with the expression in square brackets setting the threshold in IM0 (the total intensity image). Note that IM0, IM1 and IM2 correspond to the three files listed in the ''imagename'' array, '''in that order'''. The order in which the different images are specified is therefore critical once again.<br />
<br />
One can then view these various images using {{viewer}}. It is instructive to display the I, P and X images (total intensity, total linearly polarized intensity, and polarization position angle) together, to show how the polarized emission relates to the total intensity, and how the magnetic field is structured. We can do this using the viewer.<br />
* Begin by loading the linear polarization image in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0.P')<br />
</source><br />
* Next, load the total intensity image as a contour image. In the viewer panel, hit the "Open" icon (the leftmost button in the top row of icons in the viewer). This will bring up a 'Load Data' GUI showing all images and MS in the current directory. Select the total intensity image (3c391_ctm_spw0.I) and click the 'Contour Map' button on the right hand side.<br />
* Finally, load the polarization position angle image (3c391_ctm_spw0.X) as a vector map.<br />
<br />
While we set the ''polithresh'' parameter when we created the position angle (X) image, a digression here is instructive in the use of LEL Expressions. Had we not set this parameter, the position angle would have been derived for all pixels within the full IQUV image cube. There is only polarized emission from a limited subset of pixels within this image. Therefore, to avoid plotting vectors corresponding to the position angle of pure noise, we would now wish to select only the regions where the polarized intensity is brighter than some threshold value. To do this, we would use a LEL (Lattice Expression Language) Expression in the 'Load Data' GUI. For our chosen threshold of 0.4 mJy (the 5 sigma level in the P image), we would paste the expression '' '3C391_ctm_spw0.X'['3C391_ctm_spw0.P'>0.0004] '' into the LEL Expression box in the GUI, and click the 'Vector Map' button. This would load the vectors only for regions where <math>P>0.4</math> mJy.<br />
<br />
[[Image:3C391_full_pol_image.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.P) in color, the total intensity (3c391_ctm_spw0.I) as a contour map, and the polarization position angle (3c391_ctm_spw0.X) as a vector map), we still wish to optimize the display for ease of interpretation.<br />
* Change the image transfer function. Hold down the middle mouse button and move the mouse until the color scale is optimized for the display of the polarized intensity.<br />
* Change the contour levels. Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. Select the total intensity tab (3c391_ctm_spw0.I). Change the relative contour levels from the default levels of [0.2,0.4,0.6,0.8,1.0] to powers of <math>\sqrt{2}</math>, including a couple of negative contours at the beginning to demonstrate the image quality. An appropriate set of levels might be [-1.414,-1,1,1.414,2,2.828,4,5.657,8,11.314,16,22.627,32,45.255,64]. These levels will multiply the Unit Contour Level, which we set at some multiple of the rms noise in the total intensity image. An appropriate value might be 0.0024 Jy (<math>3\sigma</math>).<br />
* Change the vector spacing and color, and rotate the vectors. The polarization position angle as calculated is the electric vector position angle (EVPA). If we are interested in the orientation of the magnetic field, then for an optically thin source, the magnetic field orientation is perpendicular to the EVPA, so we must rotate the vectors by <math>90^{\circ}</math>. Select the vector image tab in the 'Data Display Options' GUI (labeled as the LEL expression we entered in the Load Data GUI) and enter ''90'' in the ''Extra rotation'' box. If the vectors appear too densely packed on the image, change the spacing of the vectors by setting ''X-increment'' and ''Y-increment'' to a larger value (8 might be appropriate here). Finally, to be able to distinguish the vectors from the total intensity contours, change the color of the vectors by selecting a different ''Line color'' (red might be a good choice).<br />
<br />
Now that we have altered the display to our satisfaction, it remains only to zoom in to the region containing the emission. Close the animator tab in the viewer, and then drag out a rectangular region around the supernova remnant with your left mouse button. Double-click to zoom in to that region. This will give you a final image looking something like that shown at right.<br />
<br />
== Spectral Index Imaging ==<br />
<br />
The spectral index, defined as the slope of the radio spectrum between two different frequencies, <math>\log(S_{\nu_1}/S_{\nu_2})/\log(\nu_1/\nu_2)</math>, is a useful analytical tool which can convey information about the emission mechanism, the optical depth of the source or the underlying energy distribution of synchrotron-radiating electrons.<br />
<br />
Having used {{immath}} to manipulate the polarization images, the reader should now have some familiarity with performing mathematical operations within CASA. {{immath}} also has a special mode for calculating the spectral index, ''mode='spix' ''. The two input images at different frequencies should be provided using the parameter (in this case, the Python list) ''imagename''. With this information, it is left as an exercise for the reader to create a spectral index map.<br />
<br />
The two input images could be the two different spectral windows from the 3C391 continuum data set. If the higher-frequency spectral window (spw1) has not yet been reduced, then two images made with different channel ranges from the lower spectral window, spw0, should suffice. In this latter case, the extreme upper and lower channels are suggested, to provide a sufficient lever arm in frequency to measure a believable spectral index.<br />
<br />
== Self-Calibration ==<br />
<br />
Recalling the lectures, even after the initial calibration using the amplitude calibrator and the phase calibrator, there are likely to be residual phase and/or amplitude errors in the data. Self-calibration is the process of using an existing model, often constructed by imaging the data itself. Provided that sufficient visibility data have been obtained, and this is essentially always the case with the EVLA (and often the VLBA, and should be with ALMA), the system of equations is wildly over-constrained for the number of unknowns. <br />
<br />
More specifically, the observed visibility data on the <math>i</math>-<math>j</math> baseline can be modeled as <br />
<br />
<math><br />
V'_{ij} = G_i G^*_j V_{ij}<br />
</math><br />
<br />
where <math>G_i</math> is the complex gain for the <math>i^{\mathrm{th}}</math> antenna and <math>V_{ij}</math> is the "true" visibility. For an array of <math>N</math> antennas, at any given instant, there are <math>N(N-1)/2</math> visibility data, but only <math>N</math> gain factors. For an array with a reasonable number of antennas, <math>N</math> >~ 8, solutions to this set of coupled equations converge quickly.<br />
<br />
There is a small amount of discussion in the CASA Reference Manual on <br />
[http://casa.nrao.edu/docs/userman/UserManse30.html#x307-3020005.8 self calibration]. In self-calibrating data, it is useful to keep in mind the structure of a Measurement Set: there are three columns of interest for an MS, the DATA column, the MODEL column, and the CORRECTED_DATA column. In normal usage, as part of the initial split, the CORRECTED_DATA column is set equal to the DATA column. The self-calibration procedure is then <br />
<br />
* Produce an image ({{clean}}) using the CORRECTED_DATA column.<br />
* Derive a series of gain corrections ({{gaincal}}) by comparing the DATA columns and the Fourier transform of the image, which is stored in the MODEL column. These corrections are stored in an external table.<br />
* Apply these corrections ({{applycal}}) to the DATA column, to form a new CORRECTED_DATA column, <em>overwriting</em> the previous contents of CORRECTED_DATA.<br />
<br />
The following example begins with the standard data set, 3c391_ctm_mosaic_spw0.ms, resulting from the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391 3C391 Continuum Tutorial]]. A model image is generated (3c391_ctm_spw0_IQUV.image), this model is used to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.G2), those gain corrections are applied to the data to form a set of self-calibrated data, and new image is then formed (3c391_ctm_spw0_IQUV_G2.image).<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3C391_ctm_mosaic_spw0.G2',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
solnorm=True,gaintype='G',calmode='p',append=False)<br />
<br />
applycal(vis='3c391_ctm_mosaic_spw0.ms',<br />
field='',spw='',selectdata=False,<br />
gaintable= ['3c391_ctm_mosaic_spw0.G2'],gainfield=[''],interp=['nearest'])<br />
<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_G2',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
Commonly, this procedure is applied multiple times.<br />
The number of iterations is determined by a combination of the data quality and number of antennas in the array, the structure of the source, the extent to which the original self-calibration assumptions are valid, and the user's patience. With reference to the original self-calibration equation above, if the observed visibility data cannot be modeled well by this equation, no amount of self-calibration will help. A not-uncommon limitation for moderately high dynamic range imaging is that there may be <em>baseline-based</em> factors that modify the "true" visibility. If the corruptions to the "true" visibility cannot be modeled as antenna-based, as they are above, self-calibration won't help.<br />
<br />
Self-calibration requires experimentation. Do not be afraid to dump an image, or even a set of gain corrections, <br />
change something and try again. Having said that, here are several general comments or guidelines:<br />
<br />
* Bookkeeping is important! Suppose one conducts 9 iterations of self-calibration. Will it be possible to remember one month later (or maybe even one week later!) which set of gain corrections and images are which? In the example above, the descriptor 'G2' is attached to various files to help keep straight which is what. 'G2' is used because the original calibration already included a gain calibration, in 'G1'. Successive iterations of self-cal could then be 'G3', 'G4', etc.<br />
<br />
* A common metric for whether self-calibration is whether the image <em>dynamic range</em> (= max/rms) has improved. An improvement of 10% is quite acceptable.<br />
<br />
* Be careful when making images and setting CLEAN regions or masks. Self-calibration assumes that the model is "perfect." If one CLEANs a noise bump, self-calibration will quite happily try to adjust the gains so that the CORRECTED_DATA describe a source at the location of the noise bump. As the author demonstrated to himself during the writing of his thesis, it is quite possible to take completely noisy data and manufacture a source. It is far better to exclude some feature of a source or a weak source from initial CLEANing and conduct another round of self-calibration than to create an artificial source. If a real source is excluded from initial CLEANing, it will continue to be present in subsequent iterations of self-calibration; if it's not a real source, one probably isn't interested in it anyway.<br />
<br />
* Start self-calibration with phase-only solutions (calmode='p' in {{gaincal}}). As [[http://adsabs.harvard.edu/abs/1989ASPC....6..287P Rick Perley]] has discussed in previous summer school lectures, a phase error of 20 deg is as bad as an amplitude error of 10%.<br />
<br />
* In initial rounds of self-calibration, consider solution intervals longer than the nominal sampling time (solint in {{gaincal}}) and/or lower signal-to-noise ratio thresholds (minsnr in {{gaincal}}). Depending upon the frequency and configuration and fidelity of the model image, it can be quite reasonable to start with solint='30s' or solint='60s' and/or minsnr=3 (or even lower). One might also want to consider specifying a uvrange, if, for example, the field has structure on large scales (small <math>u</math>-<math>v</math>) that is not well represented by the current image.<br />
<br />
* One can track the agreement between the DATA, CORRECTED_DATA, and MODEL in {{plotms}}. The options in 'Axes' allows one to select which column is to be plotted. If the MODEL agrees well with the CORRECTED_DATA, one can use shorter solint and/or higher minsnr values.<br />
<br />
== Line studies ==<br />
<br />
A second data set on 3C391 was taken, this time in OSRO-2 mode, centered on the formaldehyde line at 4829.66 MHz, to search for absorption against the supernova remnant. Again, we made a 7-pointing mosaic, with the same pointing centers as the continuum data set. If you have also already gone through the [[EVLA Spectral Line Calibration IRC+10216]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391]], you should be able to combine what you have learned from these two tutorials to reduce this spectral line study of 3C 391. Should you wish to do so, a 10-s averaged data set, with some pre-flagging done, is available from the [[http://casa.nrao.edu/Data/EVLA/3C391/3c391_line_10s_summerschool.ms.tgz CASA repository]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=3687EVLA Advanced Topics 3C3912010-06-03T19:40:04Z<p>Jgallimo: /* Polarization Imaging */</p>
<hr />
<div>[[Category:EVLA]]<br />
<br />
= Continuum Observations Data Reduction Tutorial: 3C 391---Advanced Topics =<br />
<br />
In this document, we discuss various "advanced topics" for further reduction of the 3C 391 continuum data. This tutorial assumes that the reader already has some familiarity with basic continuum data reduction, such as should have been obtained [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]]<br />
on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. If one did not participate in the EVLA Continuum Data Reduction Tutorial, one could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script and process the data to form an initial image. Current experience on a standard desktop computer suggests that such a data set could be processed in 30 min. or less.<br />
<br />
== Image Analysis and Manipulation ==<br />
<br />
This topic is perhaps not "advanced," but it appears to fit more naturally here. It is assumed that an image 3c391_ctm_spw0_IQUV.image, resulting from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] exists.<br />
<br />
The three most basic analyses are to determine the peak brightness, the flux density, and the image noise level. These are useful measures of how well one's imaging efforts are in approaching the thermal noise limit or in reproducing what is already known about a source. Additional discussion of image analysis and manipulation, including the combination of multiple images, mathematical operations on images, and much more can be found in [http://casa.nrao.edu/docs/userman/UserManch6.html#x310-3050006 Image Analysis] in the CASA Reference Book.<br />
<br />
The most straightforward statistic is the peak brightness, which is determined by {{imstat}}.<br />
<source lang="python"><br />
imstat(imagename='3c391_ctm_spw0_IQUV.image',stokes='')<br />
</source><br />
* stokes=' ' : This example determines the peak brightness in the <EM>entire</EM> image, which has all four Stokes planes. If one wanted to determine the peak brightness in just, say, the Stokes V image, one would set stokes='V'.<br />
<br />
The other two statistics require slightly more care. The flux density of a source is determined by integrating its brightness or intensity over some solid angle, i.e., <math>S = \int d\Omega I</math>, where <math>I</math> is the intensity (measured in units of Jy/beam), <math>\Omega</math> is the solid angle of the source (e.g., number of synthesized beams), and <math>S</math> is the flux density (measured in units of Jy). In general, if the noise is well-behaved in one's image, when averaged over a reasonable solid angle, the noise contribution should approach 0 Jy. If that is the case, then the flux density of the source is also reported by {{imstat}}. However, there are many cases for which a noise contribution of 0 Jy may not be a safe assumption. If one's source is in a complicated region (e.g., a star formation region, the Galactic center, near the edge of a galaxy), a better estimate of the source's flux density will be obtained by limiting carefully the solid angle over which the integration is performed.<br />
<br />
[[Image:3C391_viewer.jpg|200px|thumb|right|polygon region button selection]]<br />
<br />
Open {{viewer}} and use it to display an image, such as 3c391_ctm_spw0_IQUV.image. One can choose the function assigned to each mouse button; assign 'polygon region' to a desired mouse button (e.g., right button) by selecting the icon shown in the figure to the right with the desired mouse button.<br />
<br />
Using the mouse button just assigned to 'polygon region', outline the supernova remnant. Double click inside of that region, and the statistics will be reported. In fact, two sets of statistics will be returned. In the window one is using for casapy itself will be a set of statistics determined over the <EM>entire</EM> image cube; a new pop-up window will also appear, showing the image statistics for the particular Stokes plane being displayed in the {{viewer}}. One of the statistics reported will be the flux density within the region selected. (For the record, one of the authors of this document found a flux density of about 2.4 Jy.)<br />
<br />
[[Image:3C391_rmsnoise.jpg|200px|thumb|right|polygonal region for determining image statistics]]<br />
<br />
By contrast, for the rms noise level, one wants to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. In the region illustrated in the figure to the right, one of the authors of this document found an rms noise level of 1.4 mJy/beam.<br />
<br />
== Polarization Imaging ==<br />
<br />
[[Image:3C391_full_pol_image_i_settings.png|200px|thumb|right|data display options for total intensity contours]]<br />
In the previous data reduction tutorial, a full polarization imaging cube of 3C 391 was constructed. This cube has 3 dimensions, the standard two angular dimensions (right ascension, declination) and a third dimension containing the polarization information. Considering the image cube as a matrix, <math>Image[l,m,p]</math>, the <math>l</math> and <math>m</math> axis describe the sky brightness or intensity for the given <math>p</math> axis. If one opens the {{viewer}} and loads the 3C 391 continuum image, the default view contains an "animator" or pane with movie controls. One can step through the polarization axis, displaying the images for the different polarizations.<br />
<br />
As [[EVLA Continuum Tutorial 3C391#Imaging | constructed]], the image contains four polarizations, for the four Stokes parameters, I, Q, U, and V. Recalling the lectures, Q and U describe the linear polarization and V describes the circular polarization. Specifically, Q describes the amount of linear polarization aligned with a given axis, and U describes the amount of linear polarization at a 45 deg angle to that axis. The V parameter describes the amount of circular polarization, with the sign (positive or negative) describing the sense of the circular polarization (right- or left-hand circularly polarized).<br />
<br />
In general, few celestial sources are expected to show circular polarization, with the notable exception of masers, while terrestrial and satellite sources are often highly circularly polarized. The V image is therefore often worth forming because any V emission could be indicative of unflagged RFI within the data (or problems with the calibration!).<br />
<br />
Because the Q and U images both describe the amount of linear polarization, it is more common to work with a linear polarization intensity image, <math>P = \sqrt{Q^2 +U^2}</math>. (<math>P</math> can also be denoted by <math>L</math>.) Also important can be the polarization position angle <math>tan 2\chi = U/Q</math>.<br />
<br />
[[Image:3C391_full_pol_image_vector_settings.png|200px|thumb|right|data display options for position angle vectors]]<br />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/userman/UserMansu275.html#x326-3210006.5.1.2 Polarization Manipulation]. The steps are the following.<br />
<br />
1. Extract the I, Q, U, V planes from the full Stokes image cube, forming separate images for each Stokes parameter.<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.I',expr='IM0',stokes='I')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.Q',expr='IM0',stokes='Q')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.U',expr='IM0',stokes='U')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.V',expr='IM0',stokes='V')<br />
</source><br />
<br />
2. Combine the Q and U images using the mode='poli' option of {{immath}} to form the linear polarization image.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='poli',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.P',sigma='0.08mJy/beam')<br />
</source><br />
To correct for bias (the P image does not obey Gaussian statistics), we must supply the noise level in the Stokes Q and U images (these should be similar), using the ''sigma'' parameter. These noise levels can be estimated as described in the [[Advanced Topics#Image Analysis and Manipulation|Image Analysis and Manipulation]] section above.<br />
<br />
3. If desired, combine the Q and U images using the mode='pola' option of {{immath}} to form the polarization position angle image. Because the polarization position angle is derived from the tangent function, the order in which the Q and U images are specified is important.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='pola',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.X',sigma='0.08mJy/beam',<br />
polithresh='0.4mJy/beam')<br />
</source><br />
Again, we supply the noise level. To avoid displaying the position angle of noise, we can set a threshold intensity of the linear polarization for above which we wish to calculate the polarization angle, using the ''polithresh'' parameter. An appropriate level here might be the <math>5\sigma</math> level of 0.4 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],mode='evalexpr',<br />
expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)')<br />
</source><br />
Since the total intensity image can (and hopefully does) approach zero in regions free of source emission, dividing by the total intensity can produce very high pixel values in these regions. We therefore wish to restrict our fractional polarization image to regions containing real emission, which we do by setting a threshold in the total intensity image, which in this case corresponds to three times the noise level. The computation of the polarized intensity is specified by ''expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)' '', with the expression in square brackets setting the threshold in IM0 (the total intensity image). Note that IM0, IM1 and IM2 correspond to the three files listed in the ''imagename'' array, '''in that order'''. The order in which the different images are specified is therefore critical once again.<br />
<br />
One can then view these various images using {{viewer}}. It is instructive to display the I, P and X images (total intensity, total linearly polarized intensity, and polarization position angle) together, to show how the polarized emission relates to the total intensity, and how the magnetic field is structured. We can do this using the viewer.<br />
* Begin by loading the linear polarization image in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0.P')<br />
</source><br />
* Next, load the total intensity image as a contour image. In the viewer panel, hit the "Open" icon (the leftmost button in the top row of icons in the viewer). This will bring up a 'Load Data' GUI showing all images and MS in the current directory. Select the total intensity image (3c391_ctm_spw0.I) and click the 'Contour Map' button on the right hand side.<br />
* Finally, load the polarization position angle image (3c391_ctm_spw0.X) as a vector map.<br />
<br />
While we set the ''polithresh'' parameter when we created the position angle (X) image, a digression here is instructive in the use of LEL Expressions. Had we not set this parameter, the position angle would have been derived for all pixels within the full IQUV image cube. There is only polarized emission from a limited subset of pixels within this image. Therefore, to avoid plotting vectors corresponding to the position angle of pure noise, we would now wish to select only the regions where the polarized intensity is brighter than some threshold value. To do this, we would use a LEL (Lattice Expression Language) Expression in the 'Load Data' GUI. For our chosen threshold of 0.4 mJy (the 5 sigma level in the P image), we would paste the expression '' '3C391_ctm_spw0.X'['3C391_ctm_spw0.P'>0.0004] '' into the LEL Expression box in the GUI, and click the 'Vector Map' button. This would load the vectors only for regions where <math>P>0.4</math> mJy.<br />
<br />
[[Image:3C391_full_pol_image.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.P) in color, the total intensity (3c391_ctm_spw0.I) as a contour map, and the polarization position angle (3c391_ctm_spw0.X) as a vector map), we still wish to optimize the display for ease of interpretation.<br />
* Change the image transfer function. Hold down the middle mouse button and move the mouse until the color scale is optimized for the display of the polarized intensity.<br />
* Change the contour levels. Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. Select the total intensity tab (3c391_ctm_spw0.I). Change the relative contour levels from the default levels of [0.2,0.4,0.6,0.8,1.0] to powers of <math>\sqrt{2}</math>, including a couple of negative contours at the beginning to demonstrate the image quality. An appropriate set of levels might be [-1.414,-1,1,1.414,2,2.828,4,5.657,8,11.314,16,22.627,32,45.255,64]. These levels will multiply the Unit Contour Level, which we set at some multiple of the rms noise in the total intensity image. An appropriate value might be 0.0024 Jy (<math>3\sigma</math>).<br />
* Change the vector spacing and color, and rotate the vectors. The polarization position angle as calculated is the electric vector position angle (EVPA). If we are interested in the orientation of the magnetic field, then for an optically thin source, the magnetic field orientation is perpendicular to the EVPA, so we must rotate the vectors by <math>90^{\circ}</math>. Select the vector image tab in the 'Data Display Options' GUI (labeled as the LEL expression we entered in the Load Data GUI) and enter ''90'' in the ''Extra rotation'' box. If the vectors appear too densely packed on the image, change the spacing of the vectors by setting ''X-increment'' and ''Y-increment'' to a larger value (8 might be appropriate here). Finally, to be able to distinguish the vectors from the total intensity contours, change the color of the vectors by selecting a different ''Line color'' (red might be a good choice).<br />
<br />
Now that we have altered the display to our satisfaction, it remains only to zoom in to the region containing the emission. Close the animator tab in the viewer, and then drag out a rectangular region around the supernova remnant with your left mouse button. Double-click to zoom in to that region. This will give you a final image looking something like that shown at right.<br />
<br />
== Spectral Index Imaging ==<br />
<br />
The spectral index, defined as the slope of the radio spectrum between two different frequencies, <math>\log(S_{\nu_1}/S_{\nu_2})/\log(\nu_1/\nu_2)</math>, is a useful analytical tool which can convey information about the emission mechanism, the optical depth of the source or the underlying energy distribution of synchrotron-radiating electrons.<br />
<br />
Having used {{immath}} to manipulate the polarization images, the reader should now have some familiarity with performing mathematical operations within CASA. {{immath}} also has a special mode for calculating the spectral index, ''mode='spix' ''. The two input images at different frequencies should be provided using the parameter (in this case, the Python list) ''imagename''. With this information, it is left as an exercise for the reader to create a spectral index map.<br />
<br />
The two input images could be the two different spectral windows from the 3C391 continuum data set. If the higher-frequency spectral window (spw1) has not yet been reduced, then two images made with different channel ranges from the lower spectral window, spw0, should suffice. In this latter case, the extreme upper and lower channels are suggested, to provide a sufficient lever arm in frequency to measure a believable spectral index.<br />
<br />
== Self-Calibration ==<br />
<br />
Recalling the lectures, even after the initial calibration using the amplitude calibrator and the phase calibrator, there are likely to be residual phase and/or amplitude errors in the data. Self-calibration is the process of using an existing model, often constructed by imaging the data itself. Provided that sufficient visibility data have been obtained, and this is essentially always the case with the EVLA (and often the VLBA, and should be with ALMA), the system of equations is wildly over-constrained for the number of unknowns. <br />
<br />
More specifically, the observed visibility data on the <math>i</math>-<math>j</math> baseline can be modeled as <br />
<br />
<math><br />
V'_{ij} = G_i G^*_j V_{ij}<br />
</math><br />
<br />
where <math>G_i</math> is the complex gain for the <math>i^{\mathrm{th}}</math> antenna and <math>V_{ij}</math> is the "true" visibility. For an array of <math>N</math> antennas, at any given instant, there are <math>N(N-1)/2</math> visibility data, but only <math>N</math> gain factors. For an array with a reasonable number of antennas, <math>N</math> >~ 8, solutions to this set of coupled equations converge quickly.<br />
<br />
There is a small amount of discussion in the CASA Reference Manual on <br />
[[http://casa.nrao.edu/docs/userman/UserManse30.html#x307-3020005.8 self calibration]]. In self-calibrating data, it is useful to keep in mind the structure of a Measurement Set: there are three columns of interest for an MS, the DATA column, the MODEL column, and the CORRECTED_DATA column. In normal usage, as part of the initial split, the CORRECTED_DATA column is set equal to the DATA column. The self-calibration procedure is then <br />
<br />
* Produce an image ({{clean}}) using the CORRECTED_DATA column.<br />
* Derive a series of gain corrections ({{gaincal}}) by comparing the DATA columns and the Fourier transform of the image, which is stored in the MODEL column. These corrections are stored in an external table.<br />
* Apply these corrections ({{applycal}}) to the DATA column, to form a new CORRECTED_DATA column, <em>overwriting</em> the previous contents of CORRECTED_DATA.<br />
<br />
The following example begins with the standard data set, 3c391_ctm_mosaic_spw0.ms, resulting from the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391 3C391 Continuum Tutorial]]. A model image is generated (3c391_ctm_spw0_IQUV.image), this model is used to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.G2), those gain corrections are applied to the data to form a set of self-calibrated data, and new image is then formed (3c391_ctm_spw0_IQUV_G2.image).<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3C391_ctm_mosaic_spw0.G2',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
solnorm=True,gaintype='G',calmode='p',append=False)<br />
<br />
applycal(vis='3c391_ctm_mosaic_spw0.ms',<br />
field='',spw='',selectdata=False,<br />
gaintable= ['3c391_ctm_mosaic_spw0.G2'],gainfield=[''],interp=['nearest'])<br />
<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_G2',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
Commonly, this procedure is applied multiple times.<br />
The number of iterations is determined by a combination of the data quality and number of antennas in the array, the structure of the source, the extent to which the original self-calibration assumptions are valid, and the user's patience. With reference to the original self-calibration equation above, if the observed visibility data cannot be modeled well by this equation, no amount of self-calibration will help. A not-uncommon limitation for moderately high dynamic range imaging is that there may be <em>baseline-based</em> factors that modify the "true" visibility. If the corruptions to the "true" visibility cannot be modeled as antenna-based, as they are above, self-calibration won't help.<br />
<br />
Self-calibration requires experimentation. Do not be afraid to dump an image, or even a set of gain corrections, <br />
change something and try again. Having said that, here are several general comments or guidelines:<br />
<br />
* Bookkeeping is important! Suppose one conducts 9 iterations of self-calibration. Will it be possible to remember one month later (or maybe even one week later!) which set of gain corrections and images are which? In the example above, the descriptor 'G2' is attached to various files to help keep straight which is what. 'G2' is used because the original calibration already included a gain calibration, in 'G1'. Successive iterations of self-cal could then be 'G3', 'G4', etc.<br />
<br />
* A common metric for whether self-calibration is whether the image <em>dynamic range</em> (= max/rms) has improved. An improvement of 10% is quite acceptable.<br />
<br />
* Be careful when making images and setting CLEAN regions or masks. Self-calibration assumes that the model is "perfect." If one CLEANs a noise bump, self-calibration will quite happily try to adjust the gains so that the CORRECTED_DATA describe a source at the location of the noise bump. As the author demonstrated to himself during the writing of his thesis, it is quite possible to take completely noisy data and manufacture a source. It is far better to exclude some feature of a source or a weak source from initial CLEANing and conduct another round of self-calibration than to create an artificial source. If a real source is excluded from initial CLEANing, it will continue to be present in subsequent iterations of self-calibration; if it's not a real source, one probably isn't interested in it anyway.<br />
<br />
* Start self-calibration with phase-only solutions (calmode='p' in {{gaincal}}). As [[http://adsabs.harvard.edu/abs/1989ASPC....6..287P Rick Perley]] has discussed in previous summer school lectures, a phase error of 20 deg is as bad as an amplitude error of 10%.<br />
<br />
* In initial rounds of self-calibration, consider solution intervals longer than the nominal sampling time (solint in {{gaincal}}) and/or lower signal-to-noise ratio thresholds (minsnr in {{gaincal}}). Depending upon the frequency and configuration and fidelity of the model image, it can be quite reasonable to start with solint='30s' or solint='60s' and/or minsnr=3 (or even lower). One might also want to consider specifying a uvrange, if, for example, the field has structure on large scales (small <math>u</math>-<math>v</math>) that is not well represented by the current image.<br />
<br />
* One can track the agreement between the DATA, CORRECTED_DATA, and MODEL in {{plotms}}. The options in 'Axes' allows one to select which column is to be plotted. If the MODEL agrees well with the CORRECTED_DATA, one can use shorter solint and/or higher minsnr values.<br />
<br />
== Line studies ==<br />
<br />
A second data set on 3C391 was taken, this time in OSRO-2 mode, centered on the formaldehyde line at 4829.66 MHz, to search for absorption against the supernova remnant. Again, we made a 7-pointing mosaic, with the same pointing centers as the continuum data set. If you have also already gone through the [[EVLA Spectral Line Calibration IRC+10216]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391]], you should be able to combine what you have learned from these two tutorials to reduce this spectral line study of 3C 391. Should you wish to do so, a 10-s averaged data set, with some pre-flagging done, is available from the [[http://casa.nrao.edu/Data/EVLA/3C391/3c391_line_10s_summerschool.ms.tgz CASA repository]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=3686EVLA Advanced Topics 3C3912010-06-03T19:39:26Z<p>Jgallimo: /* Polarization Imaging */</p>
<hr />
<div>[[Category:EVLA]]<br />
<br />
= Continuum Observations Data Reduction Tutorial: 3C 391---Advanced Topics =<br />
<br />
In this document, we discuss various "advanced topics" for further reduction of the 3C 391 continuum data. This tutorial assumes that the reader already has some familiarity with basic continuum data reduction, such as should have been obtained [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]]<br />
on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. If one did not participate in the EVLA Continuum Data Reduction Tutorial, one could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script and process the data to form an initial image. Current experience on a standard desktop computer suggests that such a data set could be processed in 30 min. or less.<br />
<br />
== Image Analysis and Manipulation ==<br />
<br />
This topic is perhaps not "advanced," but it appears to fit more naturally here. It is assumed that an image 3c391_ctm_spw0_IQUV.image, resulting from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] exists.<br />
<br />
The three most basic analyses are to determine the peak brightness, the flux density, and the image noise level. These are useful measures of how well one's imaging efforts are in approaching the thermal noise limit or in reproducing what is already known about a source. Additional discussion of image analysis and manipulation, including the combination of multiple images, mathematical operations on images, and much more can be found in [http://casa.nrao.edu/docs/userman/UserManch6.html#x310-3050006 Image Analysis] in the CASA Reference Book.<br />
<br />
The most straightforward statistic is the peak brightness, which is determined by {{imstat}}.<br />
<source lang="python"><br />
imstat(imagename='3c391_ctm_spw0_IQUV.image',stokes='')<br />
</source><br />
* stokes=' ' : This example determines the peak brightness in the <EM>entire</EM> image, which has all four Stokes planes. If one wanted to determine the peak brightness in just, say, the Stokes V image, one would set stokes='V'.<br />
<br />
The other two statistics require slightly more care. The flux density of a source is determined by integrating its brightness or intensity over some solid angle, i.e., <math>S = \int d\Omega I</math>, where <math>I</math> is the intensity (measured in units of Jy/beam), <math>\Omega</math> is the solid angle of the source (e.g., number of synthesized beams), and <math>S</math> is the flux density (measured in units of Jy). In general, if the noise is well-behaved in one's image, when averaged over a reasonable solid angle, the noise contribution should approach 0 Jy. If that is the case, then the flux density of the source is also reported by {{imstat}}. However, there are many cases for which a noise contribution of 0 Jy may not be a safe assumption. If one's source is in a complicated region (e.g., a star formation region, the Galactic center, near the edge of a galaxy), a better estimate of the source's flux density will be obtained by limiting carefully the solid angle over which the integration is performed.<br />
<br />
[[Image:3C391_viewer.jpg|200px|thumb|right|polygon region button selection]]<br />
<br />
Open {{viewer}} and use it to display an image, such as 3c391_ctm_spw0_IQUV.image. One can choose the function assigned to each mouse button; assign 'polygon region' to a desired mouse button (e.g., right button) by selecting the icon shown in the figure to the right with the desired mouse button.<br />
<br />
Using the mouse button just assigned to 'polygon region', outline the supernova remnant. Double click inside of that region, and the statistics will be reported. In fact, two sets of statistics will be returned. In the window one is using for casapy itself will be a set of statistics determined over the <EM>entire</EM> image cube; a new pop-up window will also appear, showing the image statistics for the particular Stokes plane being displayed in the {{viewer}}. One of the statistics reported will be the flux density within the region selected. (For the record, one of the authors of this document found a flux density of about 2.4 Jy.)<br />
<br />
[[Image:3C391_rmsnoise.jpg|200px|thumb|right|polygonal region for determining image statistics]]<br />
<br />
By contrast, for the rms noise level, one wants to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. In the region illustrated in the figure to the right, one of the authors of this document found an rms noise level of 1.4 mJy/beam.<br />
<br />
== Polarization Imaging ==<br />
<br />
[[Image:3C391_full_pol_image_i_settings.png|200px|thumb|right|data display options for total intensity contours]]<br />
In the previous data reduction tutorial, a full polarization imaging cube of 3C 391 was constructed. This cube has 3 dimensions, the standard two angular dimensions (right ascension, declination) and a third dimension containing the polarization information. Considering the image cube as a matrix, <math>Image[l,m,p]</math>, the <math>l</math> and <math>m</math> axis describe the sky brightness or intensity for the given <math>p</math> axis. If one opens the {{viewer}} and loads the 3C 391 continuum image, the default view contains an "animator" or pane with movie controls. One can step through the polarization axis, displaying the images for the different polarizations.<br />
<br />
As [[EVLA Continuum Tutorial 3C391#Imaging | constructed]], the image contains four polarizations, for the four Stokes parameters, I, Q, U, and V. Recalling the lectures, Q and U describe the linear polarization and V describes the circular polarization. Specifically, Q describes the amount of linear polarization aligned with a given axis, and U describes the amount of linear polarization at a 45 deg angle to that axis. The V parameter describes the amount of circular polarization, with the sign (positive or negative) describing the sense of the circular polarization (right- or left-hand circularly polarized).<br />
<br />
In general, few celestial sources are expected to show circular polarization, with the notable exception of masers, while terrestrial and satellite sources are often highly circularly polarized. The V image is therefore often worth forming because any V emission could be indicative of unflagged RFI within the data (or problems with the calibration!).<br />
<br />
Because the Q and U images both describe the amount of linear polarization, it is more common to work with a linear polarization intensity image, <math>P = \sqrt{Q^2 +U^2}</math>. (<math>P</math> can also be denoted by <math>L</math>.) Also important can be the polarization position angle <math>tan 2\chi = U/Q</math>.<br />
<br />
[[Image:3C391_full_pol_image_vector_settings.png|200px|thumb|right|data display options for position angle vectors]]<br />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/userman/UserMansu275.html#x326-3210006.5.1.2 Polarization Manipulation]. The steps are the following.<br />
<br />
1. Extract the I, Q, U, V planes from the full Stokes image cube, forming separate images for each Stokes parameter.<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.I',expr='IM0',stokes='I')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.Q',expr='IM0',stokes='Q')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.U',expr='IM0',stokes='U')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.V',expr='IM0',stokes='V')<br />
</source><br />
<br />
2. Combine the Q and U images using the mode='poli' option of {{immath}} to form the linear polarization image.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='poli',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.P',sigma='0.08mJy/beam')<br />
</source><br />
To correct for bias (the P image does not obey Gaussian statistics), we must supply the noise level in the Stokes Q and U images (these should be similar), using the ''sigma'' parameter. These noise levels can be estimated as described in the [[Advanced Topics#Image Analysis and Manipulation]] section above.<br />
<br />
3. If desired, combine the Q and U images using the mode='pola' option of {{immath}} to form the polarization position angle image. Because the polarization position angle is derived from the tangent function, the order in which the Q and U images are specified is important.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='pola',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.X',sigma='0.08mJy/beam',<br />
polithresh='0.4mJy/beam')<br />
</source><br />
Again, we supply the noise level. To avoid displaying the position angle of noise, we can set a threshold intensity of the linear polarization for above which we wish to calculate the polarization angle, using the ''polithresh'' parameter. An appropriate level here might be the <math>5\sigma</math> level of 0.4 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],mode='evalexpr',<br />
expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)')<br />
</source><br />
Since the total intensity image can (and hopefully does) approach zero in regions free of source emission, dividing by the total intensity can produce very high pixel values in these regions. We therefore wish to restrict our fractional polarization image to regions containing real emission, which we do by setting a threshold in the total intensity image, which in this case corresponds to three times the noise level. The computation of the polarized intensity is specified by ''expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)' '', with the expression in square brackets setting the threshold in IM0 (the total intensity image). Note that IM0, IM1 and IM2 correspond to the three files listed in the ''imagename'' array, '''in that order'''. The order in which the different images are specified is therefore critical once again.<br />
<br />
One can then view these various images using {{viewer}}. It is instructive to display the I, P and X images (total intensity, total linearly polarized intensity, and polarization position angle) together, to show how the polarized emission relates to the total intensity, and how the magnetic field is structured. We can do this using the viewer.<br />
* Begin by loading the linear polarization image in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0.P')<br />
</source><br />
* Next, load the total intensity image as a contour image. In the viewer panel, hit the "Open" icon (the leftmost button in the top row of icons in the viewer). This will bring up a 'Load Data' GUI showing all images and MS in the current directory. Select the total intensity image (3c391_ctm_spw0.I) and click the 'Contour Map' button on the right hand side.<br />
* Finally, load the polarization position angle image (3c391_ctm_spw0.X) as a vector map.<br />
<br />
While we set the ''polithresh'' parameter when we created the position angle (X) image, a digression here is instructive in the use of LEL Expressions. Had we not set this parameter, the position angle would have been derived for all pixels within the full IQUV image cube. There is only polarized emission from a limited subset of pixels within this image. Therefore, to avoid plotting vectors corresponding to the position angle of pure noise, we would now wish to select only the regions where the polarized intensity is brighter than some threshold value. To do this, we would use a LEL (Lattice Expression Language) Expression in the 'Load Data' GUI. For our chosen threshold of 0.4 mJy (the 5 sigma level in the P image), we would paste the expression '' '3C391_ctm_spw0.X'['3C391_ctm_spw0.P'>0.0004] '' into the LEL Expression box in the GUI, and click the 'Vector Map' button. This would load the vectors only for regions where <math>P>0.4</math> mJy.<br />
<br />
[[Image:3C391_full_pol_image.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.P) in color, the total intensity (3c391_ctm_spw0.I) as a contour map, and the polarization position angle (3c391_ctm_spw0.X) as a vector map), we still wish to optimize the display for ease of interpretation.<br />
* Change the image transfer function. Hold down the middle mouse button and move the mouse until the color scale is optimized for the display of the polarized intensity.<br />
* Change the contour levels. Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. Select the total intensity tab (3c391_ctm_spw0.I). Change the relative contour levels from the default levels of [0.2,0.4,0.6,0.8,1.0] to powers of <math>\sqrt{2}</math>, including a couple of negative contours at the beginning to demonstrate the image quality. An appropriate set of levels might be [-1.414,-1,1,1.414,2,2.828,4,5.657,8,11.314,16,22.627,32,45.255,64]. These levels will multiply the Unit Contour Level, which we set at some multiple of the rms noise in the total intensity image. An appropriate value might be 0.0024 Jy (<math>3\sigma</math>).<br />
* Change the vector spacing and color, and rotate the vectors. The polarization position angle as calculated is the electric vector position angle (EVPA). If we are interested in the orientation of the magnetic field, then for an optically thin source, the magnetic field orientation is perpendicular to the EVPA, so we must rotate the vectors by <math>90^{\circ}</math>. Select the vector image tab in the 'Data Display Options' GUI (labeled as the LEL expression we entered in the Load Data GUI) and enter ''90'' in the ''Extra rotation'' box. If the vectors appear too densely packed on the image, change the spacing of the vectors by setting ''X-increment'' and ''Y-increment'' to a larger value (8 might be appropriate here). Finally, to be able to distinguish the vectors from the total intensity contours, change the color of the vectors by selecting a different ''Line color'' (red might be a good choice).<br />
<br />
Now that we have altered the display to our satisfaction, it remains only to zoom in to the region containing the emission. Close the animator tab in the viewer, and then drag out a rectangular region around the supernova remnant with your left mouse button. Double-click to zoom in to that region. This will give you a final image looking something like that shown at right.<br />
<br />
== Spectral Index Imaging ==<br />
<br />
The spectral index, defined as the slope of the radio spectrum between two different frequencies, <math>\log(S_{\nu_1}/S_{\nu_2})/\log(\nu_1/\nu_2)</math>, is a useful analytical tool which can convey information about the emission mechanism, the optical depth of the source or the underlying energy distribution of synchrotron-radiating electrons.<br />
<br />
Having used {{immath}} to manipulate the polarization images, the reader should now have some familiarity with performing mathematical operations within CASA. {{immath}} also has a special mode for calculating the spectral index, ''mode='spix' ''. The two input images at different frequencies should be provided using the parameter (in this case, the Python list) ''imagename''. With this information, it is left as an exercise for the reader to create a spectral index map.<br />
<br />
The two input images could be the two different spectral windows from the 3C391 continuum data set. If the higher-frequency spectral window (spw1) has not yet been reduced, then two images made with different channel ranges from the lower spectral window, spw0, should suffice. In this latter case, the extreme upper and lower channels are suggested, to provide a sufficient lever arm in frequency to measure a believable spectral index.<br />
<br />
== Self-Calibration ==<br />
<br />
Recalling the lectures, even after the initial calibration using the amplitude calibrator and the phase calibrator, there are likely to be residual phase and/or amplitude errors in the data. Self-calibration is the process of using an existing model, often constructed by imaging the data itself. Provided that sufficient visibility data have been obtained, and this is essentially always the case with the EVLA (and often the VLBA, and should be with ALMA), the system of equations is wildly over-constrained for the number of unknowns. <br />
<br />
More specifically, the observed visibility data on the <math>i</math>-<math>j</math> baseline can be modeled as <br />
<br />
<math><br />
V'_{ij} = G_i G^*_j V_{ij}<br />
</math><br />
<br />
where <math>G_i</math> is the complex gain for the <math>i^{\mathrm{th}}</math> antenna and <math>V_{ij}</math> is the "true" visibility. For an array of <math>N</math> antennas, at any given instant, there are <math>N(N-1)/2</math> visibility data, but only <math>N</math> gain factors. For an array with a reasonable number of antennas, <math>N</math> >~ 8, solutions to this set of coupled equations converge quickly.<br />
<br />
There is a small amount of discussion in the CASA Reference Manual on <br />
[[http://casa.nrao.edu/docs/userman/UserManse30.html#x307-3020005.8 self calibration]]. In self-calibrating data, it is useful to keep in mind the structure of a Measurement Set: there are three columns of interest for an MS, the DATA column, the MODEL column, and the CORRECTED_DATA column. In normal usage, as part of the initial split, the CORRECTED_DATA column is set equal to the DATA column. The self-calibration procedure is then <br />
<br />
* Produce an image ({{clean}}) using the CORRECTED_DATA column.<br />
* Derive a series of gain corrections ({{gaincal}}) by comparing the DATA columns and the Fourier transform of the image, which is stored in the MODEL column. These corrections are stored in an external table.<br />
* Apply these corrections ({{applycal}}) to the DATA column, to form a new CORRECTED_DATA column, <em>overwriting</em> the previous contents of CORRECTED_DATA.<br />
<br />
The following example begins with the standard data set, 3c391_ctm_mosaic_spw0.ms, resulting from the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391 3C391 Continuum Tutorial]]. A model image is generated (3c391_ctm_spw0_IQUV.image), this model is used to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.G2), those gain corrections are applied to the data to form a set of self-calibrated data, and new image is then formed (3c391_ctm_spw0_IQUV_G2.image).<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3C391_ctm_mosaic_spw0.G2',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
solnorm=True,gaintype='G',calmode='p',append=False)<br />
<br />
applycal(vis='3c391_ctm_mosaic_spw0.ms',<br />
field='',spw='',selectdata=False,<br />
gaintable= ['3c391_ctm_mosaic_spw0.G2'],gainfield=[''],interp=['nearest'])<br />
<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_G2',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
Commonly, this procedure is applied multiple times.<br />
The number of iterations is determined by a combination of the data quality and number of antennas in the array, the structure of the source, the extent to which the original self-calibration assumptions are valid, and the user's patience. With reference to the original self-calibration equation above, if the observed visibility data cannot be modeled well by this equation, no amount of self-calibration will help. A not-uncommon limitation for moderately high dynamic range imaging is that there may be <em>baseline-based</em> factors that modify the "true" visibility. If the corruptions to the "true" visibility cannot be modeled as antenna-based, as they are above, self-calibration won't help.<br />
<br />
Self-calibration requires experimentation. Do not be afraid to dump an image, or even a set of gain corrections, <br />
change something and try again. Having said that, here are several general comments or guidelines:<br />
<br />
* Bookkeeping is important! Suppose one conducts 9 iterations of self-calibration. Will it be possible to remember one month later (or maybe even one week later!) which set of gain corrections and images are which? In the example above, the descriptor 'G2' is attached to various files to help keep straight which is what. 'G2' is used because the original calibration already included a gain calibration, in 'G1'. Successive iterations of self-cal could then be 'G3', 'G4', etc.<br />
<br />
* A common metric for whether self-calibration is whether the image <em>dynamic range</em> (= max/rms) has improved. An improvement of 10% is quite acceptable.<br />
<br />
* Be careful when making images and setting CLEAN regions or masks. Self-calibration assumes that the model is "perfect." If one CLEANs a noise bump, self-calibration will quite happily try to adjust the gains so that the CORRECTED_DATA describe a source at the location of the noise bump. As the author demonstrated to himself during the writing of his thesis, it is quite possible to take completely noisy data and manufacture a source. It is far better to exclude some feature of a source or a weak source from initial CLEANing and conduct another round of self-calibration than to create an artificial source. If a real source is excluded from initial CLEANing, it will continue to be present in subsequent iterations of self-calibration; if it's not a real source, one probably isn't interested in it anyway.<br />
<br />
* Start self-calibration with phase-only solutions (calmode='p' in {{gaincal}}). As [[http://adsabs.harvard.edu/abs/1989ASPC....6..287P Rick Perley]] has discussed in previous summer school lectures, a phase error of 20 deg is as bad as an amplitude error of 10%.<br />
<br />
* In initial rounds of self-calibration, consider solution intervals longer than the nominal sampling time (solint in {{gaincal}}) and/or lower signal-to-noise ratio thresholds (minsnr in {{gaincal}}). Depending upon the frequency and configuration and fidelity of the model image, it can be quite reasonable to start with solint='30s' or solint='60s' and/or minsnr=3 (or even lower). One might also want to consider specifying a uvrange, if, for example, the field has structure on large scales (small <math>u</math>-<math>v</math>) that is not well represented by the current image.<br />
<br />
* One can track the agreement between the DATA, CORRECTED_DATA, and MODEL in {{plotms}}. The options in 'Axes' allows one to select which column is to be plotted. If the MODEL agrees well with the CORRECTED_DATA, one can use shorter solint and/or higher minsnr values.<br />
<br />
== Line studies ==<br />
<br />
A second data set on 3C391 was taken, this time in OSRO-2 mode, centered on the formaldehyde line at 4829.66 MHz, to search for absorption against the supernova remnant. Again, we made a 7-pointing mosaic, with the same pointing centers as the continuum data set. If you have also already gone through the [[EVLA Spectral Line Calibration IRC+10216]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391]], you should be able to combine what you have learned from these two tutorials to reduce this spectral line study of 3C 391. Should you wish to do so, a 10-s averaged data set, with some pre-flagging done, is available from the [[http://casa.nrao.edu/Data/EVLA/3C391/3c391_line_10s_summerschool.ms.tgz CASA repository]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=3685EVLA Advanced Topics 3C3912010-06-03T19:38:51Z<p>Jgallimo: /* Polarization Imaging */</p>
<hr />
<div>[[Category:EVLA]]<br />
<br />
= Continuum Observations Data Reduction Tutorial: 3C 391---Advanced Topics =<br />
<br />
In this document, we discuss various "advanced topics" for further reduction of the 3C 391 continuum data. This tutorial assumes that the reader already has some familiarity with basic continuum data reduction, such as should have been obtained [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]]<br />
on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. If one did not participate in the EVLA Continuum Data Reduction Tutorial, one could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script and process the data to form an initial image. Current experience on a standard desktop computer suggests that such a data set could be processed in 30 min. or less.<br />
<br />
== Image Analysis and Manipulation ==<br />
<br />
This topic is perhaps not "advanced," but it appears to fit more naturally here. It is assumed that an image 3c391_ctm_spw0_IQUV.image, resulting from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] exists.<br />
<br />
The three most basic analyses are to determine the peak brightness, the flux density, and the image noise level. These are useful measures of how well one's imaging efforts are in approaching the thermal noise limit or in reproducing what is already known about a source. Additional discussion of image analysis and manipulation, including the combination of multiple images, mathematical operations on images, and much more can be found in [http://casa.nrao.edu/docs/userman/UserManch6.html#x310-3050006 Image Analysis] in the CASA Reference Book.<br />
<br />
The most straightforward statistic is the peak brightness, which is determined by {{imstat}}.<br />
<source lang="python"><br />
imstat(imagename='3c391_ctm_spw0_IQUV.image',stokes='')<br />
</source><br />
* stokes=' ' : This example determines the peak brightness in the <EM>entire</EM> image, which has all four Stokes planes. If one wanted to determine the peak brightness in just, say, the Stokes V image, one would set stokes='V'.<br />
<br />
The other two statistics require slightly more care. The flux density of a source is determined by integrating its brightness or intensity over some solid angle, i.e., <math>S = \int d\Omega I</math>, where <math>I</math> is the intensity (measured in units of Jy/beam), <math>\Omega</math> is the solid angle of the source (e.g., number of synthesized beams), and <math>S</math> is the flux density (measured in units of Jy). In general, if the noise is well-behaved in one's image, when averaged over a reasonable solid angle, the noise contribution should approach 0 Jy. If that is the case, then the flux density of the source is also reported by {{imstat}}. However, there are many cases for which a noise contribution of 0 Jy may not be a safe assumption. If one's source is in a complicated region (e.g., a star formation region, the Galactic center, near the edge of a galaxy), a better estimate of the source's flux density will be obtained by limiting carefully the solid angle over which the integration is performed.<br />
<br />
[[Image:3C391_viewer.jpg|200px|thumb|right|polygon region button selection]]<br />
<br />
Open {{viewer}} and use it to display an image, such as 3c391_ctm_spw0_IQUV.image. One can choose the function assigned to each mouse button; assign 'polygon region' to a desired mouse button (e.g., right button) by selecting the icon shown in the figure to the right with the desired mouse button.<br />
<br />
Using the mouse button just assigned to 'polygon region', outline the supernova remnant. Double click inside of that region, and the statistics will be reported. In fact, two sets of statistics will be returned. In the window one is using for casapy itself will be a set of statistics determined over the <EM>entire</EM> image cube; a new pop-up window will also appear, showing the image statistics for the particular Stokes plane being displayed in the {{viewer}}. One of the statistics reported will be the flux density within the region selected. (For the record, one of the authors of this document found a flux density of about 2.4 Jy.)<br />
<br />
[[Image:3C391_rmsnoise.jpg|200px|thumb|right|polygonal region for determining image statistics]]<br />
<br />
By contrast, for the rms noise level, one wants to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. In the region illustrated in the figure to the right, one of the authors of this document found an rms noise level of 1.4 mJy/beam.<br />
<br />
== Polarization Imaging ==<br />
<br />
[[Image:3C391_full_pol_image_i_settings.png|200px|thumb|right|data display options for total intensity contours]]<br />
In the previous data reduction tutorial, a full polarization imaging cube of 3C 391 was constructed. This cube has 3 dimensions, the standard two angular dimensions (right ascension, declination) and a third dimension containing the polarization information. Considering the image cube as a matrix, <math>Image[l,m,p]</math>, the <math>l</math> and <math>m</math> axis describe the sky brightness or intensity for the given <math>p</math> axis. If one opens the {{viewer}} and loads the 3C 391 continuum image, the default view contains an "animator" or pane with movie controls. One can step through the polarization axis, displaying the images for the different polarizations.<br />
<br />
As [[EVLA Continuum Tutorial 3C391#Imaging | constructed]], the image contains four polarizations, for the four Stokes parameters, I, Q, U, and V. Recalling the lectures, Q and U describe the linear polarization and V describes the circular polarization. Specifically, Q describes the amount of linear polarization aligned with a given axis, and U describes the amount of linear polarization at a 45 deg angle to that axis. The V parameter describes the amount of circular polarization, with the sign (positive or negative) describing the sense of the circular polarization (right- or left-hand circularly polarized).<br />
<br />
In general, few celestial sources are expected to show circular polarization, with the notable exception of masers, while terrestrial and satellite sources are often highly circularly polarized. The V image is therefore often worth forming because any V emission could be indicative of unflagged RFI within the data (or problems with the calibration!).<br />
<br />
Because the Q and U images both describe the amount of linear polarization, it is more common to work with a linear polarization intensity image, <math>P = \sqrt{Q^2 +U^2}</math>. (<math>P</math> can also be denoted by <math>L</math>.) Also important can be the polarization position angle <math>tan 2\chi = U/Q</math>.<br />
<br />
[[Image:3C391_full_pol_image_vector_settings.png|200px|thumb|right|data display options for position angle vectors]]<br />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[[http://casa.nrao.edu/docs/userman/UserMansu275.html#x326-3210006.5.1.2 Polarization Manipulation]]. The steps are the following.<br />
<br />
1. Extract the I, Q, U, V planes from the full Stokes image cube, forming separate images for each Stokes parameter.<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.I',expr='IM0',stokes='I')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.Q',expr='IM0',stokes='Q')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.U',expr='IM0',stokes='U')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.V',expr='IM0',stokes='V')<br />
</source><br />
<br />
2. Combine the Q and U images using the mode='poli' option of {{immath}} to form the linear polarization image.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='poli',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.P',sigma='0.08mJy/beam')<br />
</source><br />
To correct for bias (the P image does not obey Gaussian statistics), we must supply the noise level in the Stokes Q and U images (these should be similar), using the ''sigma'' parameter. These noise levels can be estimated as described in the [[Advanced Topics#Image Analysis and Manipulation]] section above.<br />
<br />
3. If desired, combine the Q and U images using the mode='pola' option of {{immath}} to form the polarization position angle image. Because the polarization position angle is derived from the tangent function, the order in which the Q and U images are specified is important.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='pola',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.X',sigma='0.08mJy/beam',<br />
polithresh='0.4mJy/beam')<br />
</source><br />
Again, we supply the noise level. To avoid displaying the position angle of noise, we can set a threshold intensity of the linear polarization for above which we wish to calculate the polarization angle, using the ''polithresh'' parameter. An appropriate level here might be the <math>5\sigma</math> level of 0.4 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],mode='evalexpr',<br />
expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)')<br />
</source><br />
Since the total intensity image can (and hopefully does) approach zero in regions free of source emission, dividing by the total intensity can produce very high pixel values in these regions. We therefore wish to restrict our fractional polarization image to regions containing real emission, which we do by setting a threshold in the total intensity image, which in this case corresponds to three times the noise level. The computation of the polarized intensity is specified by ''expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)' '', with the expression in square brackets setting the threshold in IM0 (the total intensity image). Note that IM0, IM1 and IM2 correspond to the three files listed in the ''imagename'' array, '''in that order'''. The order in which the different images are specified is therefore critical once again.<br />
<br />
One can then view these various images using {{viewer}}. It is instructive to display the I, P and X images (total intensity, total linearly polarized intensity, and polarization position angle) together, to show how the polarized emission relates to the total intensity, and how the magnetic field is structured. We can do this using the viewer.<br />
* Begin by loading the linear polarization image in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0.P')<br />
</source><br />
* Next, load the total intensity image as a contour image. In the viewer panel, hit the "Open" icon (the leftmost button in the top row of icons in the viewer). This will bring up a 'Load Data' GUI showing all images and MS in the current directory. Select the total intensity image (3c391_ctm_spw0.I) and click the 'Contour Map' button on the right hand side.<br />
* Finally, load the polarization position angle image (3c391_ctm_spw0.X) as a vector map.<br />
<br />
While we set the ''polithresh'' parameter when we created the position angle (X) image, a digression here is instructive in the use of LEL Expressions. Had we not set this parameter, the position angle would have been derived for all pixels within the full IQUV image cube. There is only polarized emission from a limited subset of pixels within this image. Therefore, to avoid plotting vectors corresponding to the position angle of pure noise, we would now wish to select only the regions where the polarized intensity is brighter than some threshold value. To do this, we would use a LEL (Lattice Expression Language) Expression in the 'Load Data' GUI. For our chosen threshold of 0.4 mJy (the 5 sigma level in the P image), we would paste the expression '' '3C391_ctm_spw0.X'['3C391_ctm_spw0.P'>0.0004] '' into the LEL Expression box in the GUI, and click the 'Vector Map' button. This would load the vectors only for regions where <math>P>0.4</math> mJy.<br />
<br />
[[Image:3C391_full_pol_image.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.P) in color, the total intensity (3c391_ctm_spw0.I) as a contour map, and the polarization position angle (3c391_ctm_spw0.X) as a vector map), we still wish to optimize the display for ease of interpretation.<br />
* Change the image transfer function. Hold down the middle mouse button and move the mouse until the color scale is optimized for the display of the polarized intensity.<br />
* Change the contour levels. Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. Select the total intensity tab (3c391_ctm_spw0.I). Change the relative contour levels from the default levels of [0.2,0.4,0.6,0.8,1.0] to powers of <math>\sqrt{2}</math>, including a couple of negative contours at the beginning to demonstrate the image quality. An appropriate set of levels might be [-1.414,-1,1,1.414,2,2.828,4,5.657,8,11.314,16,22.627,32,45.255,64]. These levels will multiply the Unit Contour Level, which we set at some multiple of the rms noise in the total intensity image. An appropriate value might be 0.0024 Jy (<math>3\sigma</math>).<br />
* Change the vector spacing and color, and rotate the vectors. The polarization position angle as calculated is the electric vector position angle (EVPA). If we are interested in the orientation of the magnetic field, then for an optically thin source, the magnetic field orientation is perpendicular to the EVPA, so we must rotate the vectors by <math>90^{\circ}</math>. Select the vector image tab in the 'Data Display Options' GUI (labeled as the LEL expression we entered in the Load Data GUI) and enter ''90'' in the ''Extra rotation'' box. If the vectors appear too densely packed on the image, change the spacing of the vectors by setting ''X-increment'' and ''Y-increment'' to a larger value (8 might be appropriate here). Finally, to be able to distinguish the vectors from the total intensity contours, change the color of the vectors by selecting a different ''Line color'' (red might be a good choice).<br />
<br />
Now that we have altered the display to our satisfaction, it remains only to zoom in to the region containing the emission. Close the animator tab in the viewer, and then drag out a rectangular region around the supernova remnant with your left mouse button. Double-click to zoom in to that region. This will give you a final image looking something like that shown at right.<br />
<br />
== Spectral Index Imaging ==<br />
<br />
The spectral index, defined as the slope of the radio spectrum between two different frequencies, <math>\log(S_{\nu_1}/S_{\nu_2})/\log(\nu_1/\nu_2)</math>, is a useful analytical tool which can convey information about the emission mechanism, the optical depth of the source or the underlying energy distribution of synchrotron-radiating electrons.<br />
<br />
Having used {{immath}} to manipulate the polarization images, the reader should now have some familiarity with performing mathematical operations within CASA. {{immath}} also has a special mode for calculating the spectral index, ''mode='spix' ''. The two input images at different frequencies should be provided using the parameter (in this case, the Python list) ''imagename''. With this information, it is left as an exercise for the reader to create a spectral index map.<br />
<br />
The two input images could be the two different spectral windows from the 3C391 continuum data set. If the higher-frequency spectral window (spw1) has not yet been reduced, then two images made with different channel ranges from the lower spectral window, spw0, should suffice. In this latter case, the extreme upper and lower channels are suggested, to provide a sufficient lever arm in frequency to measure a believable spectral index.<br />
<br />
== Self-Calibration ==<br />
<br />
Recalling the lectures, even after the initial calibration using the amplitude calibrator and the phase calibrator, there are likely to be residual phase and/or amplitude errors in the data. Self-calibration is the process of using an existing model, often constructed by imaging the data itself. Provided that sufficient visibility data have been obtained, and this is essentially always the case with the EVLA (and often the VLBA, and should be with ALMA), the system of equations is wildly over-constrained for the number of unknowns. <br />
<br />
More specifically, the observed visibility data on the <math>i</math>-<math>j</math> baseline can be modeled as <br />
<br />
<math><br />
V'_{ij} = G_i G^*_j V_{ij}<br />
</math><br />
<br />
where <math>G_i</math> is the complex gain for the <math>i^{\mathrm{th}}</math> antenna and <math>V_{ij}</math> is the "true" visibility. For an array of <math>N</math> antennas, at any given instant, there are <math>N(N-1)/2</math> visibility data, but only <math>N</math> gain factors. For an array with a reasonable number of antennas, <math>N</math> >~ 8, solutions to this set of coupled equations converge quickly.<br />
<br />
There is a small amount of discussion in the CASA Reference Manual on <br />
[[http://casa.nrao.edu/docs/userman/UserManse30.html#x307-3020005.8 self calibration]]. In self-calibrating data, it is useful to keep in mind the structure of a Measurement Set: there are three columns of interest for an MS, the DATA column, the MODEL column, and the CORRECTED_DATA column. In normal usage, as part of the initial split, the CORRECTED_DATA column is set equal to the DATA column. The self-calibration procedure is then <br />
<br />
* Produce an image ({{clean}}) using the CORRECTED_DATA column.<br />
* Derive a series of gain corrections ({{gaincal}}) by comparing the DATA columns and the Fourier transform of the image, which is stored in the MODEL column. These corrections are stored in an external table.<br />
* Apply these corrections ({{applycal}}) to the DATA column, to form a new CORRECTED_DATA column, <em>overwriting</em> the previous contents of CORRECTED_DATA.<br />
<br />
The following example begins with the standard data set, 3c391_ctm_mosaic_spw0.ms, resulting from the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391 3C391 Continuum Tutorial]]. A model image is generated (3c391_ctm_spw0_IQUV.image), this model is used to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.G2), those gain corrections are applied to the data to form a set of self-calibrated data, and new image is then formed (3c391_ctm_spw0_IQUV_G2.image).<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3C391_ctm_mosaic_spw0.G2',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
solnorm=True,gaintype='G',calmode='p',append=False)<br />
<br />
applycal(vis='3c391_ctm_mosaic_spw0.ms',<br />
field='',spw='',selectdata=False,<br />
gaintable= ['3c391_ctm_mosaic_spw0.G2'],gainfield=[''],interp=['nearest'])<br />
<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_G2',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
Commonly, this procedure is applied multiple times.<br />
The number of iterations is determined by a combination of the data quality and number of antennas in the array, the structure of the source, the extent to which the original self-calibration assumptions are valid, and the user's patience. With reference to the original self-calibration equation above, if the observed visibility data cannot be modeled well by this equation, no amount of self-calibration will help. A not-uncommon limitation for moderately high dynamic range imaging is that there may be <em>baseline-based</em> factors that modify the "true" visibility. If the corruptions to the "true" visibility cannot be modeled as antenna-based, as they are above, self-calibration won't help.<br />
<br />
Self-calibration requires experimentation. Do not be afraid to dump an image, or even a set of gain corrections, <br />
change something and try again. Having said that, here are several general comments or guidelines:<br />
<br />
* Bookkeeping is important! Suppose one conducts 9 iterations of self-calibration. Will it be possible to remember one month later (or maybe even one week later!) which set of gain corrections and images are which? In the example above, the descriptor 'G2' is attached to various files to help keep straight which is what. 'G2' is used because the original calibration already included a gain calibration, in 'G1'. Successive iterations of self-cal could then be 'G3', 'G4', etc.<br />
<br />
* A common metric for whether self-calibration is whether the image <em>dynamic range</em> (= max/rms) has improved. An improvement of 10% is quite acceptable.<br />
<br />
* Be careful when making images and setting CLEAN regions or masks. Self-calibration assumes that the model is "perfect." If one CLEANs a noise bump, self-calibration will quite happily try to adjust the gains so that the CORRECTED_DATA describe a source at the location of the noise bump. As the author demonstrated to himself during the writing of his thesis, it is quite possible to take completely noisy data and manufacture a source. It is far better to exclude some feature of a source or a weak source from initial CLEANing and conduct another round of self-calibration than to create an artificial source. If a real source is excluded from initial CLEANing, it will continue to be present in subsequent iterations of self-calibration; if it's not a real source, one probably isn't interested in it anyway.<br />
<br />
* Start self-calibration with phase-only solutions (calmode='p' in {{gaincal}}). As [[http://adsabs.harvard.edu/abs/1989ASPC....6..287P Rick Perley]] has discussed in previous summer school lectures, a phase error of 20 deg is as bad as an amplitude error of 10%.<br />
<br />
* In initial rounds of self-calibration, consider solution intervals longer than the nominal sampling time (solint in {{gaincal}}) and/or lower signal-to-noise ratio thresholds (minsnr in {{gaincal}}). Depending upon the frequency and configuration and fidelity of the model image, it can be quite reasonable to start with solint='30s' or solint='60s' and/or minsnr=3 (or even lower). One might also want to consider specifying a uvrange, if, for example, the field has structure on large scales (small <math>u</math>-<math>v</math>) that is not well represented by the current image.<br />
<br />
* One can track the agreement between the DATA, CORRECTED_DATA, and MODEL in {{plotms}}. The options in 'Axes' allows one to select which column is to be plotted. If the MODEL agrees well with the CORRECTED_DATA, one can use shorter solint and/or higher minsnr values.<br />
<br />
== Line studies ==<br />
<br />
A second data set on 3C391 was taken, this time in OSRO-2 mode, centered on the formaldehyde line at 4829.66 MHz, to search for absorption against the supernova remnant. Again, we made a 7-pointing mosaic, with the same pointing centers as the continuum data set. If you have also already gone through the [[EVLA Spectral Line Calibration IRC+10216]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391]], you should be able to combine what you have learned from these two tutorials to reduce this spectral line study of 3C 391. Should you wish to do so, a 10-s averaged data set, with some pre-flagging done, is available from the [[http://casa.nrao.edu/Data/EVLA/3C391/3c391_line_10s_summerschool.ms.tgz CASA repository]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=3684EVLA Advanced Topics 3C3912010-06-03T19:38:16Z<p>Jgallimo: /* Polarization Imaging */</p>
<hr />
<div>[[Category:EVLA]]<br />
<br />
= Continuum Observations Data Reduction Tutorial: 3C 391---Advanced Topics =<br />
<br />
In this document, we discuss various "advanced topics" for further reduction of the 3C 391 continuum data. This tutorial assumes that the reader already has some familiarity with basic continuum data reduction, such as should have been obtained [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]]<br />
on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. If one did not participate in the EVLA Continuum Data Reduction Tutorial, one could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script and process the data to form an initial image. Current experience on a standard desktop computer suggests that such a data set could be processed in 30 min. or less.<br />
<br />
== Image Analysis and Manipulation ==<br />
<br />
This topic is perhaps not "advanced," but it appears to fit more naturally here. It is assumed that an image 3c391_ctm_spw0_IQUV.image, resulting from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] exists.<br />
<br />
The three most basic analyses are to determine the peak brightness, the flux density, and the image noise level. These are useful measures of how well one's imaging efforts are in approaching the thermal noise limit or in reproducing what is already known about a source. Additional discussion of image analysis and manipulation, including the combination of multiple images, mathematical operations on images, and much more can be found in [http://casa.nrao.edu/docs/userman/UserManch6.html#x310-3050006 Image Analysis] in the CASA Reference Book.<br />
<br />
The most straightforward statistic is the peak brightness, which is determined by {{imstat}}.<br />
<source lang="python"><br />
imstat(imagename='3c391_ctm_spw0_IQUV.image',stokes='')<br />
</source><br />
* stokes=' ' : This example determines the peak brightness in the <EM>entire</EM> image, which has all four Stokes planes. If one wanted to determine the peak brightness in just, say, the Stokes V image, one would set stokes='V'.<br />
<br />
The other two statistics require slightly more care. The flux density of a source is determined by integrating its brightness or intensity over some solid angle, i.e., <math>S = \int d\Omega I</math>, where <math>I</math> is the intensity (measured in units of Jy/beam), <math>\Omega</math> is the solid angle of the source (e.g., number of synthesized beams), and <math>S</math> is the flux density (measured in units of Jy). In general, if the noise is well-behaved in one's image, when averaged over a reasonable solid angle, the noise contribution should approach 0 Jy. If that is the case, then the flux density of the source is also reported by {{imstat}}. However, there are many cases for which a noise contribution of 0 Jy may not be a safe assumption. If one's source is in a complicated region (e.g., a star formation region, the Galactic center, near the edge of a galaxy), a better estimate of the source's flux density will be obtained by limiting carefully the solid angle over which the integration is performed.<br />
<br />
[[Image:3C391_viewer.jpg|200px|thumb|right|polygon region button selection]]<br />
<br />
Open {{viewer}} and use it to display an image, such as 3c391_ctm_spw0_IQUV.image. One can choose the function assigned to each mouse button; assign 'polygon region' to a desired mouse button (e.g., right button) by selecting the icon shown in the figure to the right with the desired mouse button.<br />
<br />
Using the mouse button just assigned to 'polygon region', outline the supernova remnant. Double click inside of that region, and the statistics will be reported. In fact, two sets of statistics will be returned. In the window one is using for casapy itself will be a set of statistics determined over the <EM>entire</EM> image cube; a new pop-up window will also appear, showing the image statistics for the particular Stokes plane being displayed in the {{viewer}}. One of the statistics reported will be the flux density within the region selected. (For the record, one of the authors of this document found a flux density of about 2.4 Jy.)<br />
<br />
[[Image:3C391_rmsnoise.jpg|200px|thumb|right|polygonal region for determining image statistics]]<br />
<br />
By contrast, for the rms noise level, one wants to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. In the region illustrated in the figure to the right, one of the authors of this document found an rms noise level of 1.4 mJy/beam.<br />
<br />
== Polarization Imaging ==<br />
<br />
[[Image:3C391_full_pol_image_i_settings.png|200px|thumb|right|data display options for total intensity contours]]<br />
In the previous data reduction tutorial, a full polarization imaging cube of 3C 391 was constructed. This cube has 3 dimensions, the standard two angular dimensions (right ascension, declination) and a third dimension containing the polarization information. Considering the image cube as a matrix, <math>Image[l,m,p]</math>, the <math>l</math> and <math>m</math> axis describe the sky brightness or intensity for the given <math>p</math> axis. If one opens the {{viewer}} and loads the 3C 391 continuum image, the default view contains an "animator" or pane with movie controls. One can step through the polarization axis, displaying the images for the different polarizations.<br />
<br />
As [[EVLA Continuum Tutorial 3C391#Imaging | constructed]], the image contains four polarizations, for the four Stokes parameters, I, Q, U, and V. Recalling the lectures, Q and U describe the linear polarization and V describes the circular polarization. Specifically, Q describes the amount of linear polarization aligned with a given axis, and U describes the amount of linear polarization at a 45 deg angle to that axis. The V parameter describes the amount of circular polarization, with the sign (positive or negative) describing the sense of the circular polarization (right- or left-hand circularly polarized).<br />
<br />
In general, few celestial sources are expected to show circular polarization, with the notable exception of masers, while terrestrial and satellite sources are often highly circularly polarized. The V image is therefore often worth forming because any V emission could be indicative of unflagged RFI within the data (or problems with the calibration!).<br />
<br />
Because the Q and U images both describe the amount of linear polarization, it is more common to work with a linear polarization intensity image, <math>P = \sqrt{Q^2 +U^2}</math>. (<math>P</math> can also be denoted by <math>L</math>.) Also important can be the polarization position angle <math>tan 2\chi = U/Q</math>.<br />
<br />
[[Image:3C391_full_pol_image_vector_settings.png|200px|thumb|right|data display options for position angle vectors]]<br />
The relevant task is [[http://casa.nrao.edu/docs/userman/UserManse37.html#x323-3180006.5 immath]], with specific examples for processing of polarization images given in<br />
[[http://casa.nrao.edu/docs/userman/UserMansu275.html#x326-3210006.5.1.2 Polarization Manipulation]]. The steps are the following.<br />
<br />
1. Extract the I, Q, U, V planes from the full Stokes image cube, forming separate images for each Stokes parameter.<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.I',expr='IM0',stokes='I')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.Q',expr='IM0',stokes='Q')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.U',expr='IM0',stokes='U')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.V',expr='IM0',stokes='V')<br />
</source><br />
<br />
2. Combine the Q and U images using the mode='poli' option of {{immath}} to form the linear polarization image.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='poli',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.P',sigma='0.08mJy/beam')<br />
</source><br />
To correct for bias (the P image does not obey Gaussian statistics), we must supply the noise level in the Stokes Q and U images (these should be similar), using the ''sigma'' parameter. These noise levels can be estimated as described in the [[Advanced Topics#Image Analysis and Manipulation]] section above.<br />
<br />
3. If desired, combine the Q and U images using the mode='pola' option of {{immath}} to form the polarization position angle image. Because the polarization position angle is derived from the tangent function, the order in which the Q and U images are specified is important.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='pola',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.X',sigma='0.08mJy/beam',<br />
polithresh='0.4mJy/beam')<br />
</source><br />
Again, we supply the noise level. To avoid displaying the position angle of noise, we can set a threshold intensity of the linear polarization for above which we wish to calculate the polarization angle, using the ''polithresh'' parameter. An appropriate level here might be the <math>5\sigma</math> level of 0.4 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],mode='evalexpr',<br />
expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)')<br />
</source><br />
Since the total intensity image can (and hopefully does) approach zero in regions free of source emission, dividing by the total intensity can produce very high pixel values in these regions. We therefore wish to restrict our fractional polarization image to regions containing real emission, which we do by setting a threshold in the total intensity image, which in this case corresponds to three times the noise level. The computation of the polarized intensity is specified by ''expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)' '', with the expression in square brackets setting the threshold in IM0 (the total intensity image). Note that IM0, IM1 and IM2 correspond to the three files listed in the ''imagename'' array, '''in that order'''. The order in which the different images are specified is therefore critical once again.<br />
<br />
One can then view these various images using {{viewer}}. It is instructive to display the I, P and X images (total intensity, total linearly polarized intensity, and polarization position angle) together, to show how the polarized emission relates to the total intensity, and how the magnetic field is structured. We can do this using the viewer.<br />
* Begin by loading the linear polarization image in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0.P')<br />
</source><br />
* Next, load the total intensity image as a contour image. In the viewer panel, hit the "Open" icon (the leftmost button in the top row of icons in the viewer). This will bring up a 'Load Data' GUI showing all images and MS in the current directory. Select the total intensity image (3c391_ctm_spw0.I) and click the 'Contour Map' button on the right hand side.<br />
* Finally, load the polarization position angle image (3c391_ctm_spw0.X) as a vector map.<br />
<br />
While we set the ''polithresh'' parameter when we created the position angle (X) image, a digression here is instructive in the use of LEL Expressions. Had we not set this parameter, the position angle would have been derived for all pixels within the full IQUV image cube. There is only polarized emission from a limited subset of pixels within this image. Therefore, to avoid plotting vectors corresponding to the position angle of pure noise, we would now wish to select only the regions where the polarized intensity is brighter than some threshold value. To do this, we would use a LEL (Lattice Expression Language) Expression in the 'Load Data' GUI. For our chosen threshold of 0.4 mJy (the 5 sigma level in the P image), we would paste the expression '' '3C391_ctm_spw0.X'['3C391_ctm_spw0.P'>0.0004] '' into the LEL Expression box in the GUI, and click the 'Vector Map' button. This would load the vectors only for regions where <math>P>0.4</math> mJy.<br />
<br />
[[Image:3C391_full_pol_image.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.P) in color, the total intensity (3c391_ctm_spw0.I) as a contour map, and the polarization position angle (3c391_ctm_spw0.X) as a vector map), we still wish to optimize the display for ease of interpretation.<br />
* Change the image transfer function. Hold down the middle mouse button and move the mouse until the color scale is optimized for the display of the polarized intensity.<br />
* Change the contour levels. Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. Select the total intensity tab (3c391_ctm_spw0.I). Change the relative contour levels from the default levels of [0.2,0.4,0.6,0.8,1.0] to powers of <math>\sqrt{2}</math>, including a couple of negative contours at the beginning to demonstrate the image quality. An appropriate set of levels might be [-1.414,-1,1,1.414,2,2.828,4,5.657,8,11.314,16,22.627,32,45.255,64]. These levels will multiply the Unit Contour Level, which we set at some multiple of the rms noise in the total intensity image. An appropriate value might be 0.0024 Jy (<math>3\sigma</math>).<br />
* Change the vector spacing and color, and rotate the vectors. The polarization position angle as calculated is the electric vector position angle (EVPA). If we are interested in the orientation of the magnetic field, then for an optically thin source, the magnetic field orientation is perpendicular to the EVPA, so we must rotate the vectors by <math>90^{\circ}</math>. Select the vector image tab in the 'Data Display Options' GUI (labeled as the LEL expression we entered in the Load Data GUI) and enter ''90'' in the ''Extra rotation'' box. If the vectors appear too densely packed on the image, change the spacing of the vectors by setting ''X-increment'' and ''Y-increment'' to a larger value (8 might be appropriate here). Finally, to be able to distinguish the vectors from the total intensity contours, change the color of the vectors by selecting a different ''Line color'' (red might be a good choice).<br />
<br />
Now that we have altered the display to our satisfaction, it remains only to zoom in to the region containing the emission. Close the animator tab in the viewer, and then drag out a rectangular region around the supernova remnant with your left mouse button. Double-click to zoom in to that region. This will give you a final image looking something like that shown at right.<br />
<br />
== Spectral Index Imaging ==<br />
<br />
The spectral index, defined as the slope of the radio spectrum between two different frequencies, <math>\log(S_{\nu_1}/S_{\nu_2})/\log(\nu_1/\nu_2)</math>, is a useful analytical tool which can convey information about the emission mechanism, the optical depth of the source or the underlying energy distribution of synchrotron-radiating electrons.<br />
<br />
Having used {{immath}} to manipulate the polarization images, the reader should now have some familiarity with performing mathematical operations within CASA. {{immath}} also has a special mode for calculating the spectral index, ''mode='spix' ''. The two input images at different frequencies should be provided using the parameter (in this case, the Python list) ''imagename''. With this information, it is left as an exercise for the reader to create a spectral index map.<br />
<br />
The two input images could be the two different spectral windows from the 3C391 continuum data set. If the higher-frequency spectral window (spw1) has not yet been reduced, then two images made with different channel ranges from the lower spectral window, spw0, should suffice. In this latter case, the extreme upper and lower channels are suggested, to provide a sufficient lever arm in frequency to measure a believable spectral index.<br />
<br />
== Self-Calibration ==<br />
<br />
Recalling the lectures, even after the initial calibration using the amplitude calibrator and the phase calibrator, there are likely to be residual phase and/or amplitude errors in the data. Self-calibration is the process of using an existing model, often constructed by imaging the data itself. Provided that sufficient visibility data have been obtained, and this is essentially always the case with the EVLA (and often the VLBA, and should be with ALMA), the system of equations is wildly over-constrained for the number of unknowns. <br />
<br />
More specifically, the observed visibility data on the <math>i</math>-<math>j</math> baseline can be modeled as <br />
<br />
<math><br />
V'_{ij} = G_i G^*_j V_{ij}<br />
</math><br />
<br />
where <math>G_i</math> is the complex gain for the <math>i^{\mathrm{th}}</math> antenna and <math>V_{ij}</math> is the "true" visibility. For an array of <math>N</math> antennas, at any given instant, there are <math>N(N-1)/2</math> visibility data, but only <math>N</math> gain factors. For an array with a reasonable number of antennas, <math>N</math> >~ 8, solutions to this set of coupled equations converge quickly.<br />
<br />
There is a small amount of discussion in the CASA Reference Manual on <br />
[[http://casa.nrao.edu/docs/userman/UserManse30.html#x307-3020005.8 self calibration]]. In self-calibrating data, it is useful to keep in mind the structure of a Measurement Set: there are three columns of interest for an MS, the DATA column, the MODEL column, and the CORRECTED_DATA column. In normal usage, as part of the initial split, the CORRECTED_DATA column is set equal to the DATA column. The self-calibration procedure is then <br />
<br />
* Produce an image ({{clean}}) using the CORRECTED_DATA column.<br />
* Derive a series of gain corrections ({{gaincal}}) by comparing the DATA columns and the Fourier transform of the image, which is stored in the MODEL column. These corrections are stored in an external table.<br />
* Apply these corrections ({{applycal}}) to the DATA column, to form a new CORRECTED_DATA column, <em>overwriting</em> the previous contents of CORRECTED_DATA.<br />
<br />
The following example begins with the standard data set, 3c391_ctm_mosaic_spw0.ms, resulting from the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391 3C391 Continuum Tutorial]]. A model image is generated (3c391_ctm_spw0_IQUV.image), this model is used to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.G2), those gain corrections are applied to the data to form a set of self-calibrated data, and new image is then formed (3c391_ctm_spw0_IQUV_G2.image).<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3C391_ctm_mosaic_spw0.G2',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
solnorm=True,gaintype='G',calmode='p',append=False)<br />
<br />
applycal(vis='3c391_ctm_mosaic_spw0.ms',<br />
field='',spw='',selectdata=False,<br />
gaintable= ['3c391_ctm_mosaic_spw0.G2'],gainfield=[''],interp=['nearest'])<br />
<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_G2',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
Commonly, this procedure is applied multiple times.<br />
The number of iterations is determined by a combination of the data quality and number of antennas in the array, the structure of the source, the extent to which the original self-calibration assumptions are valid, and the user's patience. With reference to the original self-calibration equation above, if the observed visibility data cannot be modeled well by this equation, no amount of self-calibration will help. A not-uncommon limitation for moderately high dynamic range imaging is that there may be <em>baseline-based</em> factors that modify the "true" visibility. If the corruptions to the "true" visibility cannot be modeled as antenna-based, as they are above, self-calibration won't help.<br />
<br />
Self-calibration requires experimentation. Do not be afraid to dump an image, or even a set of gain corrections, <br />
change something and try again. Having said that, here are several general comments or guidelines:<br />
<br />
* Bookkeeping is important! Suppose one conducts 9 iterations of self-calibration. Will it be possible to remember one month later (or maybe even one week later!) which set of gain corrections and images are which? In the example above, the descriptor 'G2' is attached to various files to help keep straight which is what. 'G2' is used because the original calibration already included a gain calibration, in 'G1'. Successive iterations of self-cal could then be 'G3', 'G4', etc.<br />
<br />
* A common metric for whether self-calibration is whether the image <em>dynamic range</em> (= max/rms) has improved. An improvement of 10% is quite acceptable.<br />
<br />
* Be careful when making images and setting CLEAN regions or masks. Self-calibration assumes that the model is "perfect." If one CLEANs a noise bump, self-calibration will quite happily try to adjust the gains so that the CORRECTED_DATA describe a source at the location of the noise bump. As the author demonstrated to himself during the writing of his thesis, it is quite possible to take completely noisy data and manufacture a source. It is far better to exclude some feature of a source or a weak source from initial CLEANing and conduct another round of self-calibration than to create an artificial source. If a real source is excluded from initial CLEANing, it will continue to be present in subsequent iterations of self-calibration; if it's not a real source, one probably isn't interested in it anyway.<br />
<br />
* Start self-calibration with phase-only solutions (calmode='p' in {{gaincal}}). As [[http://adsabs.harvard.edu/abs/1989ASPC....6..287P Rick Perley]] has discussed in previous summer school lectures, a phase error of 20 deg is as bad as an amplitude error of 10%.<br />
<br />
* In initial rounds of self-calibration, consider solution intervals longer than the nominal sampling time (solint in {{gaincal}}) and/or lower signal-to-noise ratio thresholds (minsnr in {{gaincal}}). Depending upon the frequency and configuration and fidelity of the model image, it can be quite reasonable to start with solint='30s' or solint='60s' and/or minsnr=3 (or even lower). One might also want to consider specifying a uvrange, if, for example, the field has structure on large scales (small <math>u</math>-<math>v</math>) that is not well represented by the current image.<br />
<br />
* One can track the agreement between the DATA, CORRECTED_DATA, and MODEL in {{plotms}}. The options in 'Axes' allows one to select which column is to be plotted. If the MODEL agrees well with the CORRECTED_DATA, one can use shorter solint and/or higher minsnr values.<br />
<br />
== Line studies ==<br />
<br />
A second data set on 3C391 was taken, this time in OSRO-2 mode, centered on the formaldehyde line at 4829.66 MHz, to search for absorption against the supernova remnant. Again, we made a 7-pointing mosaic, with the same pointing centers as the continuum data set. If you have also already gone through the [[EVLA Spectral Line Calibration IRC+10216]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391]], you should be able to combine what you have learned from these two tutorials to reduce this spectral line study of 3C 391. Should you wish to do so, a 10-s averaged data set, with some pre-flagging done, is available from the [[http://casa.nrao.edu/Data/EVLA/3C391/3c391_line_10s_summerschool.ms.tgz CASA repository]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=3683EVLA Advanced Topics 3C3912010-06-03T19:37:21Z<p>Jgallimo: </p>
<hr />
<div>[[Category:EVLA]]<br />
<br />
= Continuum Observations Data Reduction Tutorial: 3C 391---Advanced Topics =<br />
<br />
In this document, we discuss various "advanced topics" for further reduction of the 3C 391 continuum data. This tutorial assumes that the reader already has some familiarity with basic continuum data reduction, such as should have been obtained [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]]<br />
on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. If one did not participate in the EVLA Continuum Data Reduction Tutorial, one could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script and process the data to form an initial image. Current experience on a standard desktop computer suggests that such a data set could be processed in 30 min. or less.<br />
<br />
== Image Analysis and Manipulation ==<br />
<br />
This topic is perhaps not "advanced," but it appears to fit more naturally here. It is assumed that an image 3c391_ctm_spw0_IQUV.image, resulting from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] exists.<br />
<br />
The three most basic analyses are to determine the peak brightness, the flux density, and the image noise level. These are useful measures of how well one's imaging efforts are in approaching the thermal noise limit or in reproducing what is already known about a source. Additional discussion of image analysis and manipulation, including the combination of multiple images, mathematical operations on images, and much more can be found in [http://casa.nrao.edu/docs/userman/UserManch6.html#x310-3050006 Image Analysis] in the CASA Reference Book.<br />
<br />
The most straightforward statistic is the peak brightness, which is determined by {{imstat}}.<br />
<source lang="python"><br />
imstat(imagename='3c391_ctm_spw0_IQUV.image',stokes='')<br />
</source><br />
* stokes=' ' : This example determines the peak brightness in the <EM>entire</EM> image, which has all four Stokes planes. If one wanted to determine the peak brightness in just, say, the Stokes V image, one would set stokes='V'.<br />
<br />
The other two statistics require slightly more care. The flux density of a source is determined by integrating its brightness or intensity over some solid angle, i.e., <math>S = \int d\Omega I</math>, where <math>I</math> is the intensity (measured in units of Jy/beam), <math>\Omega</math> is the solid angle of the source (e.g., number of synthesized beams), and <math>S</math> is the flux density (measured in units of Jy). In general, if the noise is well-behaved in one's image, when averaged over a reasonable solid angle, the noise contribution should approach 0 Jy. If that is the case, then the flux density of the source is also reported by {{imstat}}. However, there are many cases for which a noise contribution of 0 Jy may not be a safe assumption. If one's source is in a complicated region (e.g., a star formation region, the Galactic center, near the edge of a galaxy), a better estimate of the source's flux density will be obtained by limiting carefully the solid angle over which the integration is performed.<br />
<br />
[[Image:3C391_viewer.jpg|200px|thumb|right|polygon region button selection]]<br />
<br />
Open {{viewer}} and use it to display an image, such as 3c391_ctm_spw0_IQUV.image. One can choose the function assigned to each mouse button; assign 'polygon region' to a desired mouse button (e.g., right button) by selecting the icon shown in the figure to the right with the desired mouse button.<br />
<br />
Using the mouse button just assigned to 'polygon region', outline the supernova remnant. Double click inside of that region, and the statistics will be reported. In fact, two sets of statistics will be returned. In the window one is using for casapy itself will be a set of statistics determined over the <EM>entire</EM> image cube; a new pop-up window will also appear, showing the image statistics for the particular Stokes plane being displayed in the {{viewer}}. One of the statistics reported will be the flux density within the region selected. (For the record, one of the authors of this document found a flux density of about 2.4 Jy.)<br />
<br />
[[Image:3C391_rmsnoise.jpg|200px|thumb|right|polygonal region for determining image statistics]]<br />
<br />
By contrast, for the rms noise level, one wants to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. In the region illustrated in the figure to the right, one of the authors of this document found an rms noise level of 1.4 mJy/beam.<br />
<br />
== Polarization Imaging ==<br />
<br />
[[Image:3C391_full_pol_image_i_settings.png|200px|thumb|right|data display options for total intensity contours]]<br />
In the previous data reduction tutorial, a full polarization imaging cube of 3C 391 was constructed. This cube has 3 dimensions, the standard two angular dimensions (right ascension, declination) and a third dimension containing the polarization information. Considering the image cube as a matrix, <math>Image[l,m,p]</math>, the <math>l</math> and <math>m</math> axis describe the sky brightness or intensity for the given <math>p</math> axis. If one opens the {{viewer}} and loads the 3C 391 continuum image, the default view contains an "animator" or pane with movie controls. One can step through the polarization axis, displaying the images for the different polarizations.<br />
<br />
As [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Imaging constructed]], the image contains four polarizations, for the four Stokes parameters, I, Q, U, and V. Recalling the lectures, Q and U describe the linear polarization and V describes the circular polarization. Specifically, Q describes the amount of linear polarization aligned with a given axis, and U describes the amount of linear polarization at a 45 deg angle to that axis. The V parameter describes the amount of circular polarization, with the sign (positive or negative) describing the sense of the circular polarization (right- or left-hand circularly polarized).<br />
<br />
In general, few celestial sources are expected to show circular polarization, with the notable exception of masers, while terrestrial and satellite sources are often highly circularly polarized. The V image is therefore often worth forming because any V emission could be indicative of unflagged RFI within the data (or problems with the calibration!).<br />
<br />
Because the Q and U images both describe the amount of linear polarization, it is more common to work with a linear polarization intensity image, <math>P = \sqrt{Q^2 +U^2}</math>. (<math>P</math> can also be denoted by <math>L</math>.) Also important can be the polarization position angle <math>tan 2\chi = U/Q</math>.<br />
<br />
[[Image:3C391_full_pol_image_vector_settings.png|200px|thumb|right|data display options for position angle vectors]]<br />
The relevant task is [[http://casa.nrao.edu/docs/userman/UserManse37.html#x323-3180006.5 immath]], with specific examples for processing of polarization images given in<br />
[[http://casa.nrao.edu/docs/userman/UserMansu275.html#x326-3210006.5.1.2 Polarization Manipulation]]. The steps are the following.<br />
<br />
1. Extract the I, Q, U, V planes from the full Stokes image cube, forming separate images for each Stokes parameter.<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.I',expr='IM0',stokes='I')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.Q',expr='IM0',stokes='Q')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.U',expr='IM0',stokes='U')<br />
immath(imagename='3c391_ctm_spw0_IQUV.image',outfile='3c391_ctm_spw0.V',expr='IM0',stokes='V')<br />
</source><br />
<br />
2. Combine the Q and U images using the mode='poli' option of {{immath}} to form the linear polarization image.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='poli',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.P',sigma='0.08mJy/beam')<br />
</source><br />
To correct for bias (the P image does not obey Gaussian statistics), we must supply the noise level in the Stokes Q and U images (these should be similar), using the ''sigma'' parameter. These noise levels can be estimated as described in the [[Advanced Topics#Image Analysis and Manipulation]] section above.<br />
<br />
3. If desired, combine the Q and U images using the mode='pola' option of {{immath}} to form the polarization position angle image. Because the polarization position angle is derived from the tangent function, the order in which the Q and U images are specified is important.<br />
<source lang="python"><br />
# In CASA<br />
immath(mode='pola',imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],outfile='3c391_ctm_spw0.X',sigma='0.08mJy/beam',<br />
polithresh='0.4mJy/beam')<br />
</source><br />
Again, we supply the noise level. To avoid displaying the position angle of noise, we can set a threshold intensity of the linear polarization for above which we wish to calculate the polarization angle, using the ''polithresh'' parameter. An appropriate level here might be the <math>5\sigma</math> level of 0.4 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],mode='evalexpr',<br />
expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)')<br />
</source><br />
Since the total intensity image can (and hopefully does) approach zero in regions free of source emission, dividing by the total intensity can produce very high pixel values in these regions. We therefore wish to restrict our fractional polarization image to regions containing real emission, which we do by setting a threshold in the total intensity image, which in this case corresponds to three times the noise level. The computation of the polarized intensity is specified by ''expr='sqrt((IM1^2-IM2^2)/IM0[IM0>2.7e-3]^2)' '', with the expression in square brackets setting the threshold in IM0 (the total intensity image). Note that IM0, IM1 and IM2 correspond to the three files listed in the ''imagename'' array, '''in that order'''. The order in which the different images are specified is therefore critical once again.<br />
<br />
One can then view these various images using {{viewer}}. It is instructive to display the I, P and X images (total intensity, total linearly polarized intensity, and polarization position angle) together, to show how the polarized emission relates to the total intensity, and how the magnetic field is structured. We can do this using the viewer.<br />
* Begin by loading the linear polarization image in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0.P')<br />
</source><br />
* Next, load the total intensity image as a contour image. In the viewer panel, hit the "Open" icon (the leftmost button in the top row of icons in the viewer). This will bring up a 'Load Data' GUI showing all images and MS in the current directory. Select the total intensity image (3c391_ctm_spw0.I) and click the 'Contour Map' button on the right hand side.<br />
* Finally, load the polarization position angle image (3c391_ctm_spw0.X) as a vector map.<br />
<br />
While we set the ''polithresh'' parameter when we created the position angle (X) image, a digression here is instructive in the use of LEL Expressions. Had we not set this parameter, the position angle would have been derived for all pixels within the full IQUV image cube. There is only polarized emission from a limited subset of pixels within this image. Therefore, to avoid plotting vectors corresponding to the position angle of pure noise, we would now wish to select only the regions where the polarized intensity is brighter than some threshold value. To do this, we would use a LEL (Lattice Expression Language) Expression in the 'Load Data' GUI. For our chosen threshold of 0.4 mJy (the 5 sigma level in the P image), we would paste the expression '' '3C391_ctm_spw0.X'['3C391_ctm_spw0.P'>0.0004] '' into the LEL Expression box in the GUI, and click the 'Vector Map' button. This would load the vectors only for regions where <math>P>0.4</math> mJy.<br />
<br />
[[Image:3C391_full_pol_image.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.P) in color, the total intensity (3c391_ctm_spw0.I) as a contour map, and the polarization position angle (3c391_ctm_spw0.X) as a vector map), we still wish to optimize the display for ease of interpretation.<br />
* Change the image transfer function. Hold down the middle mouse button and move the mouse until the color scale is optimized for the display of the polarized intensity.<br />
* Change the contour levels. Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. Select the total intensity tab (3c391_ctm_spw0.I). Change the relative contour levels from the default levels of [0.2,0.4,0.6,0.8,1.0] to powers of <math>\sqrt{2}</math>, including a couple of negative contours at the beginning to demonstrate the image quality. An appropriate set of levels might be [-1.414,-1,1,1.414,2,2.828,4,5.657,8,11.314,16,22.627,32,45.255,64]. These levels will multiply the Unit Contour Level, which we set at some multiple of the rms noise in the total intensity image. An appropriate value might be 0.0024 Jy (<math>3\sigma</math>).<br />
* Change the vector spacing and color, and rotate the vectors. The polarization position angle as calculated is the electric vector position angle (EVPA). If we are interested in the orientation of the magnetic field, then for an optically thin source, the magnetic field orientation is perpendicular to the EVPA, so we must rotate the vectors by <math>90^{\circ}</math>. Select the vector image tab in the 'Data Display Options' GUI (labeled as the LEL expression we entered in the Load Data GUI) and enter ''90'' in the ''Extra rotation'' box. If the vectors appear too densely packed on the image, change the spacing of the vectors by setting ''X-increment'' and ''Y-increment'' to a larger value (8 might be appropriate here). Finally, to be able to distinguish the vectors from the total intensity contours, change the color of the vectors by selecting a different ''Line color'' (red might be a good choice).<br />
<br />
Now that we have altered the display to our satisfaction, it remains only to zoom in to the region containing the emission. Close the animator tab in the viewer, and then drag out a rectangular region around the supernova remnant with your left mouse button. Double-click to zoom in to that region. This will give you a final image looking something like that shown at right.<br />
<br />
== Spectral Index Imaging ==<br />
<br />
The spectral index, defined as the slope of the radio spectrum between two different frequencies, <math>\log(S_{\nu_1}/S_{\nu_2})/\log(\nu_1/\nu_2)</math>, is a useful analytical tool which can convey information about the emission mechanism, the optical depth of the source or the underlying energy distribution of synchrotron-radiating electrons.<br />
<br />
Having used {{immath}} to manipulate the polarization images, the reader should now have some familiarity with performing mathematical operations within CASA. {{immath}} also has a special mode for calculating the spectral index, ''mode='spix' ''. The two input images at different frequencies should be provided using the parameter (in this case, the Python list) ''imagename''. With this information, it is left as an exercise for the reader to create a spectral index map.<br />
<br />
The two input images could be the two different spectral windows from the 3C391 continuum data set. If the higher-frequency spectral window (spw1) has not yet been reduced, then two images made with different channel ranges from the lower spectral window, spw0, should suffice. In this latter case, the extreme upper and lower channels are suggested, to provide a sufficient lever arm in frequency to measure a believable spectral index.<br />
<br />
== Self-Calibration ==<br />
<br />
Recalling the lectures, even after the initial calibration using the amplitude calibrator and the phase calibrator, there are likely to be residual phase and/or amplitude errors in the data. Self-calibration is the process of using an existing model, often constructed by imaging the data itself. Provided that sufficient visibility data have been obtained, and this is essentially always the case with the EVLA (and often the VLBA, and should be with ALMA), the system of equations is wildly over-constrained for the number of unknowns. <br />
<br />
More specifically, the observed visibility data on the <math>i</math>-<math>j</math> baseline can be modeled as <br />
<br />
<math><br />
V'_{ij} = G_i G^*_j V_{ij}<br />
</math><br />
<br />
where <math>G_i</math> is the complex gain for the <math>i^{\mathrm{th}}</math> antenna and <math>V_{ij}</math> is the "true" visibility. For an array of <math>N</math> antennas, at any given instant, there are <math>N(N-1)/2</math> visibility data, but only <math>N</math> gain factors. For an array with a reasonable number of antennas, <math>N</math> >~ 8, solutions to this set of coupled equations converge quickly.<br />
<br />
There is a small amount of discussion in the CASA Reference Manual on <br />
[[http://casa.nrao.edu/docs/userman/UserManse30.html#x307-3020005.8 self calibration]]. In self-calibrating data, it is useful to keep in mind the structure of a Measurement Set: there are three columns of interest for an MS, the DATA column, the MODEL column, and the CORRECTED_DATA column. In normal usage, as part of the initial split, the CORRECTED_DATA column is set equal to the DATA column. The self-calibration procedure is then <br />
<br />
* Produce an image ({{clean}}) using the CORRECTED_DATA column.<br />
* Derive a series of gain corrections ({{gaincal}}) by comparing the DATA columns and the Fourier transform of the image, which is stored in the MODEL column. These corrections are stored in an external table.<br />
* Apply these corrections ({{applycal}}) to the DATA column, to form a new CORRECTED_DATA column, <em>overwriting</em> the previous contents of CORRECTED_DATA.<br />
<br />
The following example begins with the standard data set, 3c391_ctm_mosaic_spw0.ms, resulting from the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391 3C391 Continuum Tutorial]]. A model image is generated (3c391_ctm_spw0_IQUV.image), this model is used to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.G2), those gain corrections are applied to the data to form a set of self-calibrated data, and new image is then formed (3c391_ctm_spw0_IQUV_G2.image).<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3C391_ctm_mosaic_spw0.G2',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
solnorm=True,gaintype='G',calmode='p',append=False)<br />
<br />
applycal(vis='3c391_ctm_mosaic_spw0.ms',<br />
field='',spw='',selectdata=False,<br />
gaintable= ['3c391_ctm_mosaic_spw0.G2'],gainfield=[''],interp=['nearest'])<br />
<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_G2',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1,threshold='0.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
Commonly, this procedure is applied multiple times.<br />
The number of iterations is determined by a combination of the data quality and number of antennas in the array, the structure of the source, the extent to which the original self-calibration assumptions are valid, and the user's patience. With reference to the original self-calibration equation above, if the observed visibility data cannot be modeled well by this equation, no amount of self-calibration will help. A not-uncommon limitation for moderately high dynamic range imaging is that there may be <em>baseline-based</em> factors that modify the "true" visibility. If the corruptions to the "true" visibility cannot be modeled as antenna-based, as they are above, self-calibration won't help.<br />
<br />
Self-calibration requires experimentation. Do not be afraid to dump an image, or even a set of gain corrections, <br />
change something and try again. Having said that, here are several general comments or guidelines:<br />
<br />
* Bookkeeping is important! Suppose one conducts 9 iterations of self-calibration. Will it be possible to remember one month later (or maybe even one week later!) which set of gain corrections and images are which? In the example above, the descriptor 'G2' is attached to various files to help keep straight which is what. 'G2' is used because the original calibration already included a gain calibration, in 'G1'. Successive iterations of self-cal could then be 'G3', 'G4', etc.<br />
<br />
* A common metric for whether self-calibration is whether the image <em>dynamic range</em> (= max/rms) has improved. An improvement of 10% is quite acceptable.<br />
<br />
* Be careful when making images and setting CLEAN regions or masks. Self-calibration assumes that the model is "perfect." If one CLEANs a noise bump, self-calibration will quite happily try to adjust the gains so that the CORRECTED_DATA describe a source at the location of the noise bump. As the author demonstrated to himself during the writing of his thesis, it is quite possible to take completely noisy data and manufacture a source. It is far better to exclude some feature of a source or a weak source from initial CLEANing and conduct another round of self-calibration than to create an artificial source. If a real source is excluded from initial CLEANing, it will continue to be present in subsequent iterations of self-calibration; if it's not a real source, one probably isn't interested in it anyway.<br />
<br />
* Start self-calibration with phase-only solutions (calmode='p' in {{gaincal}}). As [[http://adsabs.harvard.edu/abs/1989ASPC....6..287P Rick Perley]] has discussed in previous summer school lectures, a phase error of 20 deg is as bad as an amplitude error of 10%.<br />
<br />
* In initial rounds of self-calibration, consider solution intervals longer than the nominal sampling time (solint in {{gaincal}}) and/or lower signal-to-noise ratio thresholds (minsnr in {{gaincal}}). Depending upon the frequency and configuration and fidelity of the model image, it can be quite reasonable to start with solint='30s' or solint='60s' and/or minsnr=3 (or even lower). One might also want to consider specifying a uvrange, if, for example, the field has structure on large scales (small <math>u</math>-<math>v</math>) that is not well represented by the current image.<br />
<br />
* One can track the agreement between the DATA, CORRECTED_DATA, and MODEL in {{plotms}}. The options in 'Axes' allows one to select which column is to be plotted. If the MODEL agrees well with the CORRECTED_DATA, one can use shorter solint and/or higher minsnr values.<br />
<br />
== Line studies ==<br />
<br />
A second data set on 3C391 was taken, this time in OSRO-2 mode, centered on the formaldehyde line at 4829.66 MHz, to search for absorption against the supernova remnant. Again, we made a 7-pointing mosaic, with the same pointing centers as the continuum data set. If you have also already gone through the [[EVLA Spectral Line Calibration IRC+10216]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391]], you should be able to combine what you have learned from these two tutorials to reduce this spectral line study of 3C 391. Should you wish to do so, a 10-s averaged data set, with some pre-flagging done, is available from the [[http://casa.nrao.edu/Data/EVLA/3C391/3c391_line_10s_summerschool.ms.tgz CASA repository]].</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=3682EVLA Continuum Tutorial 3C3912010-06-03T19:28:47Z<p>Jgallimo: /* Polarization Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
<br />
== Overview ==<br />
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]]. As an alternative to the function calls as provided by the script extractor, all tasks may be run interactively by typing ''default taskname'' to load the task, ''inp'' to examine the inputs, and ''go'' once those inputs have been set to your satisfaction. Allowed inputs are shown in blue, and bad inputs are colored red. If you prefer this more interactive CASA experience, screenshots of the inputs to the different tasks used in the data reduction are provided, to illustrate which parameters need to be set. The attentive reader will see that all non-default inputs to the tasks correspond exactly to the parameters set in the function calls derived from the script extractor.<br />
<br />
Should you use the script generated by the [[Extracting_scripts_from_these_tutorials | script extractor]], be aware that it will require some small amount of interaction, occasionally suggesting that you close the graphics window and hitting return in the terminal to proceed. It is in fact unnecessary to close the graphics windows (it is suggested that you do so purely to keep your desktop uncluttered), and in one case (that of {{plotms}}), you '''must''' leave the graphics window open, as the GUI cannot be reopened without first exiting from CASA.<br />
<br />
== Obtaining the Data ==<br />
<br />
For the purposes of this tutorial, we have created a "starting" data set, upon which several initial processing steps have already been conducted. This data set may already be present on the machine that you are using; if not, obtain it from the<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz CASA data archive].<br />
<br />
We are providing this "starting" data set, rather than the "true" initial data set for (at least) two reasons. First, many of these initial processing steps can be rather time consuming (> 1 hr), and the time for the data reduction tutorial is limited. Second, while necessary, many of these steps are not fundamental to the calibration and imaging process, upon which we want to focus today. For completeness, however, here are the steps that were taken from the initial data set to produce the "starting" data set:<br />
* The data loaded into CASA, converting the initial Science Data Model (SDM) file into a measurement set.<br />
* Basic data flagging was applied, to account for "shadowing" of the antennas. These data are from the D configuration, in which antennas are particularly susceptible to being blocked or "shadowed" by other antennas in the array, depending upon the elevation of the source.<br />
* The data were averaged to 10-second samples, from the initial 1-second correlator sample time. In the D configuration, the fringe rate is relatively slow and time-average smearing is less of a concern.<br />
* The data were acquired with two spectral windows (around 4.6 and 7.5 GHz). Because of disk space concerns on some machines, the focus will be on only one of the two spectral windows.<br />
<br />
We emphasize that, were this a real science observation, all of these steps would need to be run. Detailed instructions on obtaining the data from the archive and creating this "starting" data set may be found in the [[Obtaining EVLA Data: 3C 391 Example]] tutorial.<br />
<br />
== Examining the Data ==<br />
<br />
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. From this, we find the following:<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Information from observing log:<br />
There is no C-band receivers on ea13<br />
Antenna ea06 is out of the array<br />
Antenna ea15 has some corrupted data<br />
Antennas ea10, ea12, ea22 do not have good baseline positions<br />
Gusty winds, mixed clouds, API rms up to 11.5.<br />
</pre><br />
<br />
Before beginning our data reduction, we must start CASA. If you have not used CASA before, some helpful tips are available on the [[Getting Started in CASA]] page.<br />
<br />
Once you have CASA up and running in the directory containing the data, then start your data reduction by getting some basic information about the data. The task {{listobs}} can be used to get a listing of the individual scans comprising the observation, the frequency setup, source list, and antenna locations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='3c391_ctm_mosaic_10s_spw0.ms',verbose=T)<br />
</source><br />
<br />
{{listobs}} should now produce output similar to the following in the casa logger. (Note that the listing shown is for both spectral windows.)<br />
<br />
<pre style="background-color: #ffe4b5;"><br />
INFO listobs::::casa ##########################################<br />
INFO listobs::::casa ##### Begin Task: listobs #####<br />
INFO listobs::::casa <br />
INFO listobs::ms::summary ================================================================================<br />
INFO listobs::ms::summary+ MeasurementSet Name: /export/home/hamal/jmiller/TDEM0001_sb1218006/3c391_mosaic_fullres.ms MS Version 2<br />
INFO listobs::ms::summary+ ================================================================================<br />
INFO listobs::ms::summary+ Observer: Dr. James Miller-Jones Project: T.B.D. <br />
INFO listobs::ms::summary+ Observation: EVLA<br />
INFO listobs::ms::summary Data records: 18666050 Total integration time = 28716 seconds<br />
INFO listobs::ms::summary+ Observed from 24-Apr-2010/08:01:34.5 to 24-Apr-2010/16:00:10.5 (UTC)<br />
INFO listobs::ms::summary <br />
INFO listobs::ms::summary+ ObservationID = 0 ArrayID = 0<br />
INFO listobs::ms::summary+ Date Timerange (UTC) Scan FldId FieldName nVis Int(s) SpwIds<br />
INFO listobs::ms::summary+ 24-Apr-2010/08:01:34.5 - 08:02:28.5 1 0 J1331+3030 35750 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:02:29.5 - 08:09:27.5 2 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:09:28.5 - 08:16:26.5 3 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:16:27.5 - 08:24:25.5 4 1 J1822-0938 311350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:24:26.5 - 08:29:44.5 5 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:29:45.5 - 08:34:43.5 6 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:34:44.5 - 08:39:42.5 7 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:39:43.5 - 08:44:41.5 8 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:44:42.5 - 08:49:40.5 9 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:49:41.5 - 08:54:40.5 10 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:54:41.5 - 08:59:39.5 11 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:59:40.5 - 09:01:29.5 12 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:01:30.5 - 09:06:48.5 13 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:06:49.5 - 09:11:47.5 14 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:11:48.5 - 09:16:46.5 15 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:16:47.5 - 09:21:45.5 16 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:21:46.5 - 09:26:44.5 17 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:26:45.5 - 09:31:44.5 18 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:31:45.5 - 09:36:43.5 19 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:36:44.5 - 09:38:32.5 20 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:38:33.5 - 09:43:52.5 21 2 3C391 C1 208000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:43:53.5 - 09:48:51.5 22 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:48:52.5 - 09:53:50.5 23 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:53:51.5 - 09:58:49.5 24 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:58:50.5 - 10:03:48.5 25 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:03:49.5 - 10:08:47.5 26 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:08:48.5 - 10:13:47.5 27 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:13:48.5 - 10:15:36.5 28 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:15:37.5 - 10:20:55.5 29 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:20:56.5 - 10:25:55.5 30 3 3C391 C2 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:25:56.5 - 10:30:54.5 31 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:30:55.5 - 10:35:53.5 32 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:35:54.5 - 10:40:52.5 33 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:40:53.5 - 10:45:51.5 34 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:45:52.5 - 10:50:51.5 35 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:50:52.5 - 10:52:40.5 36 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:52:41.5 - 10:57:39.5 37 0 J1331+3030 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:57:40.5 - 11:02:39.5 38 1 J1822-0938 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:02:40.5 - 11:07:58.5 39 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:07:59.5 - 11:12:47.5 40 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:12:48.5 - 11:17:36.5 41 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:17:37.5 - 11:22:25.5 42 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:22:26.5 - 11:27:15.5 43 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:27:16.5 - 11:32:04.5 44 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:32:05.5 - 11:36:53.5 45 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:36:54.5 - 11:38:43.5 46 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:38:44.5 - 11:44:02.5 47 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:44:03.5 - 11:48:51.5 48 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:48:52.5 - 11:53:40.5 49 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:53:41.5 - 11:58:29.5 50 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:58:30.5 - 12:03:19.5 51 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:03:20.5 - 12:08:08.5 52 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:08:09.5 - 12:12:57.5 53 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:12:58.5 - 12:14:47.5 54 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:14:48.5 - 12:20:06.5 55 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:20:07.5 - 12:24:55.5 56 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:24:56.5 - 12:29:44.5 57 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:29:45.5 - 12:34:34.5 58 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:34:35.5 - 12:39:23.5 59 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:39:24.5 - 12:44:12.5 60 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:44:13.5 - 12:49:01.5 61 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:49:02.5 - 12:50:51.5 62 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:50:52.5 - 12:56:10.5 63 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:56:11.5 - 13:00:59.5 64 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:01:00.5 - 13:05:48.5 65 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:05:49.5 - 13:10:38.5 66 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:10:39.5 - 13:15:27.5 67 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:15:28.5 - 13:20:16.5 68 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:20:17.5 - 13:25:05.5 69 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:25:06.5 - 13:26:55.5 70 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:26:56.5 - 13:32:14.5 71 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:32:15.5 - 13:37:03.5 72 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:37:04.5 - 13:41:52.5 73 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:41:53.5 - 13:46:42.5 74 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:46:43.5 - 13:51:31.5 75 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:51:32.5 - 13:56:20.5 76 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:56:21.5 - 14:01:09.5 77 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:01:10.5 - 14:02:59.5 78 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:03:00.5 - 14:08:18.5 79 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:08:19.5 - 14:13:07.5 80 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:13:08.5 - 14:17:57.5 81 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:17:58.5 - 14:22:46.5 82 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:22:47.5 - 14:27:35.5 83 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:27:36.5 - 14:32:24.5 84 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:32:25.5 - 14:37:13.5 85 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:37:14.5 - 14:39:03.5 86 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:39:04.5 - 14:44:22.5 87 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:44:23.5 - 14:49:11.5 88 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:49:12.5 - 14:54:01.5 89 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:54:02.5 - 14:58:50.5 90 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:58:51.5 - 15:03:39.5 91 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:03:40.5 - 15:08:28.5 92 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:08:29.5 - 15:13:17.5 93 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:13:18.5 - 15:15:07.5 94 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:15:08.5 - 15:20:26.5 95 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:20:27.5 - 15:25:15.5 96 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:25:16.5 - 15:30:05.5 97 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:30:06.5 - 15:34:54.5 98 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:34:55.5 - 15:39:43.5 99 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:39:44.5 - 15:44:32.5 100 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:44:33.5 - 15:49:22.5 101 8 3C391 C7 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:49:23.5 - 15:51:11.5 102 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:51:12.5 - 16:00:10.5 103 9 J0319+4130 350350 1 [0, 1]<br />
INFO listobs::ms::summary (nVis = Total number of time/baseline visibilities per scan) <br />
INFO listobs::ms::summary Fields: 10<br />
INFO listobs::ms::summary+ ID Code Name RA Decl Epoch SrcId nVis <br />
INFO listobs::ms::summary+ 0 N J1331+3030 13:31:08.2880 +30.30.32.9589 J2000 0 774800 <br />
INFO listobs::ms::summary+ 1 J J1822-0938 18:22:28.7042 -09.38.56.8350 J2000 1 1361750<br />
INFO listobs::ms::summary+ 2 NONE 3C391 C1 18:49:24.2440 -00.55.40.5800 J2000 2 2488850<br />
INFO listobs::ms::summary+ 3 NONE 3C391 C2 18:49:29.1490 -00.57.48.0000 J2000 3 2280850<br />
INFO listobs::ms::summary+ 4 NONE 3C391 C3 18:49:19.3390 -00.57.48.0000 J2000 4 2282150<br />
INFO listobs::ms::summary+ 5 NONE 3C391 C4 18:49:14.4340 -00.55.40.5800 J2000 5 2282150<br />
INFO listobs::ms::summary+ 6 NONE 3C391 C5 18:49:19.3390 -00.53.33.1600 J2000 6 2281500<br />
INFO listobs::ms::summary+ 7 NONE 3C391 C6 18:49:29.1490 -00.53.33.1600 J2000 7 2281500<br />
INFO listobs::ms::summary+ 8 NONE 3C391 C7 18:49:34.0540 -00.55.40.5800 J2000 8 2282150<br />
INFO listobs::ms::summary+ 9 Z J0319+4130 03:19:48.1601 +41.30.42.1030 J2000 9 350350 <br />
INFO listobs::ms::summary+ (nVis = Total number of time/baseline visibilities per field) <br />
INFO listobs::ms::summary Spectral Windows: (2 unique spectral windows and 1 unique polarization setups)<br />
INFO listobs::ms::summary+ SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
INFO listobs::ms::summary+ 0 64 TOPO 4536 2000 128000 4536 RR RL LR LL <br />
INFO listobs::ms::summary+ 1 64 TOPO 7436 2000 128000 7436 RR RL LR LL <br />
INFO listobs::ms::summary Sources: 20<br />
INFO listobs::ms::summary+ ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
INFO listobs::ms::summary+ 0 J1331+3030 0 - - <br />
INFO listobs::ms::summary+ 0 J1331+3030 1 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 0 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 1 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 0 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 1 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 0 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 1 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 0 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 1 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 0 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 1 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 0 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 1 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 0 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 1 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 0 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 1 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 0 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 1 - - <br />
INFO listobs::ms::summary Antennas: 26:<br />
INFO listobs::ms::summary+ ID Name Station Diam. Long. Lat. <br />
INFO listobs::ms::summary+ 0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
INFO listobs::ms::summary+ 1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
INFO listobs::ms::summary+ 2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
INFO listobs::ms::summary+ 3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
INFO listobs::ms::summary+ 4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
INFO listobs::ms::summary+ 5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
INFO listobs::ms::summary+ 6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
INFO listobs::ms::summary+ 7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
INFO listobs::ms::summary+ 8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
INFO listobs::ms::summary+ 9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
INFO listobs::ms::summary+ 10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
INFO listobs::ms::summary+ 11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
INFO listobs::ms::summary+ 12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
INFO listobs::ms::summary+ 13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
INFO listobs::ms::summary+ 14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
INFO listobs::ms::summary+ 15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
INFO listobs::ms::summary+ 16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
INFO listobs::ms::summary+ 17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
INFO listobs::ms::summary+ 18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
INFO listobs::ms::summary+ 19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
INFO listobs::ms::summary+ 20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
INFO listobs::ms::summary+ 21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
INFO listobs::ms::summary+ 22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
INFO listobs::ms::summary+ 23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
INFO listobs::ms::summary+ 24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
INFO listobs::ms::summary+ 25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
INFO listobs::::casa <br />
INFO listobs::::casa ##### End Task: listobs #####<br />
INFO listobs::::casa ##########################################<br />
</pre><br />
<br />
Note that the antenna IDs (which are numbered sequentially up to the total number of antennas in the array; 0 through 25 in this instance) do not correspond to the actual antenna names (ea01 through ea28; these numbers correspond to those painted on the side of the dishes). During our data reduction, we can refer to the antennas using either convention; ''antenna='22' '' would correspond to ea25, whereas ''antenna='ea22' '' would correspond to ea22. Note that the antenna numbers in the observer log correspond to the actual antenna names, i.e. the 'ea??' numbers given in listobs.<br />
<br />
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!). <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotants(vis='3c391_ctm_mosaic_10s_spw0.ms',figfile='3c391_ctm_mosaic_antenna_layout.png')<br />
clearstat() # This removes the table lock generated by plotants in script mode<br />
</source><br />
<br />
[[Image:3c391_ctm_plotants_parameters.jpg|200px|thumb|left|plotants parameters]]<br />
[[Image:3C391_mosaic-plotants.png|200px|thumb|center|plotants figure]]<br />
<br />
== Examining and Editing the Data ==<br />
<br />
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.<br />
<br />
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 less than 1 minute long.) This first scan can safely be deleted.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,scan='1')<br />
</source><br />
<br />
[[Image:3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
* <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.)<br />
* <strong>mode='manualflag'</strong> : Specific data are going to be selected to be edited. <br />
* <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 ''help 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.)<br />
<br />
If satisfied with the inputs, run this task. The initial display in the logger will include <br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: flagdata #####<br />
flagdata::::casa<br />
attached MS [...]<br />
Saving current flags to manualflag_1 before applying new flags<br />
Creating new backup flag file called manualflag_1<br />
</pre><br />
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_1. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used.<br />
<br />
<br />
<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea13,ea15')<br />
</source><br />
* antenna='ea13' : Once again, this parameter requires a string input. Remember that antenna='ea13' and 'antenna='13' are <em>not</em> the same antenna. (See the discussion after our call to {{listobs}} above.)<br />
<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',mode='quack',quackinterval=10.0,quackmode='beg')<br />
</source><br />
* mode='quack' : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* 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.<br />
* 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.<br />
<br />
<br />
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}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat() # This removes any existing table locks generated by flagdata<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',xaxis='',yaxis='',averagedata=False,transform=False,extendflag=False,<br />
plotfile='',selectdata=True,field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* xaxis=' ', yaxis=' ' : One can choose the axes of the plot, i.e., the way of visualizing the data, by using the GUI display once the task is executed.<br />
* averagedata=F : It is possible to average the data in time, frequency, etc. <br />
* transform=F : It is possible to change the velocity reference frame of the data.<br />
* 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.<br />
* plotfile=' ' : It is possible to produce a hard copy (e.g., for a paper, report, or Web site) by specifying a file.<br />
* selectdata=T : One can choose to plot only subsets of the data.<br />
* field='0': The entire dataset is rather large, and different sources have very different amplitudes, so it is advisable to start by loading a subset of the data. One can later loop through the different fields (i.e. sources) and spectral windows using the GUI interface.<br />
<br />
In this case, many other 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.<br />
<br />
{{plotms}} should produce a GUI, with the default view being to show the visibility amplitude as a function of time. The figure at right shows the result of running {{plotms}} without the field selection (''field='0' '') discussed above.<br />
[[Image:plotms-default.png|200px|right|thumb|plotms default GUI view, having loaded all fields at once]]<br />
{{plotms}} allows one to select and view the data in many ways. Across the top of the left 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.<br />
<br />
In the default view, the 'Plots' tab is visible, and there are a number of tabs running down the side of the left 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.<br />
<br />
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 (baseline length, in meters), 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., <math>\sqrt{u^2+v^2}</math>). 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.) <br />
<br />
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]. To plot baseline length in wavelengths rather than meters, one needs to select ''UVDist_L'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view of 3C 391]]<br />
<br />
<br />
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.<br />
<br />
'''Do not''' close the plotms GUI after running {{plotms}}, or you will need to exit casapy and restart if at any point you wish to run plotms again, otherwise the GUI will not come up a second time.<br />
<br />
== Calibrating the Data ==<br />
<br />
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. <br />
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.<br />
<br />
Recall that the observed visibility <math>V^{\prime}</math> between two antennas <math>(i,j)</math> is related to the "true" visibility <math>V</math> by <br />
<br />
<math><br />
V^{\prime}_{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)\,e^{i [\theta_i(t) - \theta_j(t)]} <br />
</math><br />
<br />
Here, for generality, we show the visibility as a function of frequency <math>f</math> and spatial wavenumbers <math>u</math> and <math>v</math>. The other terms are <br />
* <math>g_i</math> and <math>\theta_i</math> 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 <math>t</math> to indicate that they can change with temperature, atmospheric conditions, etc.<br />
* <math>B_i</math> is the complex bandpass, the instrumental response as a function of frequency, <math>f</math>. As shown here, the bandpass may also vary as a function of time.<br />
* <math>b(t)</math> 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. <br />
Strictly, the equation above is a simplification of a more general measurement equation formalism, but it is a useful simplification in many cases.<br />
<br />
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., a priori models for the calibrators, and those derived 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. If you have started with the 10s-averaged dataset suggested at the top of this tutorial, this step has already been done for you, so may be omitted.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',spw='')<br />
</source><br />
<br />
All parameters are set to blank so that the initialization occurs for all sources and spectral windows.<br />
<br />
<br />
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 <math>g_i</math> values.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',<br />
modimage='/home/casa/data/nrao/VLA/CalModels/3C286_C.im',standard='Perley-Taylor 99',<br />
fluxdensity=-1)<br />
</source><br />
<br />
[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]<br />
* 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.<br />
* 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.<br />
* 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.<br />
* fluxdensity=-1 : It is possible to specify (i.e., force) the flux density of the source to be a particular value. Setting ''fluxdensity = -1'' (as done here) asks {{setjy}} to calculate the value based on a set of standard models if the source is one of the standard flux calibrators (i.e. 3C 286, 3C 48, or 3C 147).<br />
* spw='0' : The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw, but it will not hurt to do so. Had the spectral window 0 not been split off, as has been done here, we might wish to specify the spectral window because, in this observation, the spectral windows were sufficiently separated that two different model images for 3C 286 would be appropriate; 3C286_C.im at 4.6 GHz and 3C286_X.im at 7.5 GHz. This would require two separate runs of {{setjy}}, one for each spectral window. If the spectral windows were much closer together, it might be possible to calibrate both using the same model.<br />
<br />
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.<br />
<br />
The output from {{setjy}} should look similar to the following.<br />
<pre style="background-color: #ffe4b5;"><br />
INFO taskmanager::::casa ##### async task launch: setjy ########################<br />
INFO setjy::imager::setjy() J1331+3030 spwid= 0 [I=7.747, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
INFO setjy::imager::setjy() Using model image /home/casa/data/nrao/VLA/CalModels/3C286_C.im<br />
INFO setjy::imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
INFO setjy::imager::setjy() Scaling model image to I=7.74664 Jy for visibility prediction.<br />
INFO setjy::imager::data selection Selecting data<br />
</pre><br />
As set, the flux density scale is being set only for spectral window 0 (''spw='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. <br />
<br />
<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass.png|200px|thumb|right|bandpass illustration]]<br />
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 right. 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 as well. The variations with frequency are a reflection of the (slightly) different antenna bandpasses. (<em>Exercise for the reader, reproduce this plot using {{plotms}}.</em>)<br />
<br />
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. While amplitude variations will have little effect on the bandpass solutions, it is important to solve for any phase variations with time to prevent decorrelation when vector averaging the data in computing the bandpass solutions.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal0',field='J1331+3030',<br />
refant='ea21',spw='0:27~36',calmode='p',solint='int',minsnr=5,solnorm=T)<br />
</source><br />
<br />
[[Image:3C391_gaincal0.png|200px|thumb|right|gaincal inputs for first gain solutions]]<br />
* caltable='3c391_ctm_mosaic.gcal0' : The gain solutions will be stored in an external table.<br />
* 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.<br />
* 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.<br />
* spw='0: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. Also note that, even though these data have only a single spectral window, the syntax requires specifying the spectral window in order to specify the spectral channels.<br />
* calmode='p' : Solve for only the phase portion of the gain.<br />
* 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)<br />
* 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.<br />
* solnorm=T : Strictly, for a phase-only solution, the amplitudes should be normalized by zero. This setting enforces that.<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-R.png')<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='L',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-L.png')<br />
</source><br />
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.<br />
[[Image:plotcal-3C286-G0-phase-R.png|200px|thumb|left|gain phases for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-phase-L.png|200px|thumb|center|gain phases for 3C 286, L polarization]]<br />
<br />
<br />
Alternatively, one can choose to inspect solutions for a single antenna at a time, stepping through each antenna in sequence:<br />
<source lang="python"><br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',iteration='antenna',plotrange=[-1,-1,-180,180],timerange='08:02:00~08:17:00')<br />
</source><br />
Antennas which have been flagged will show a blank plot, since there are no solutions for these antennas. Note the phase jump on antenna ea05. You may wish to flag this antenna:<br />
<source lang="python"><br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea05',field='J1331+3030',timerange='08:02:00~08:17:00')<br />
</source><br />
<br />
Now form the bandpass itself, using the phase solutions just derived.<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='3c391_ctm_mosaic_10s_spw0.ms',gaintable='3c391_ctm_mosaic.gcal0',caltable='3c391_ctm_mosaic.bcal0',<br />
field='J1331+3030',spw='',refant='ea21',solnorm=True,combine='scan',solint='inf',bandtype='B')<br />
</source><br />
<br />
[[Image:3C391_bandpass.png|200px|thumb|right|bandpass inputs]]<br />
* 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.<br />
* caltable='3c391_ctm_mosaic.bcal0' : Specify where to store the bandpass corrections.<br />
* solnorm=T : Make sure that the amplitudes of the bandpass corrections are normalized to unity.<br />
* 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.<br />
* 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.<br />
<br />
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. We use ''iteration='antenna' '' to step through separate plots for each antenna.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='R',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-R.png')<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='L',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-L.png')<br />
</source><br />
<br />
[[Image:plotcal-3C286-G0-bandpass-R.png|200px|thumb|left|bandpass for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-bandpass-L.png|200px|thumb|center|bandpass for 3C 286, L polarization]]<br />
<br />
<br />
=== Gain Calibration ===<br />
<br />
The next step is to derive corrections for the complex antenna gains, <math>g_i</math> and <math>\theta_i</math>. As discussed in the lectures and above, the absolute magnitude of the gain amplitudes <math>g_i</math> are determined by reference to a standard flux density calibrator. In order to determine the appropriate complex gains for the target source, one wants to observe a so-called phase calibrator that is much closer to the target, in order to minimize differences through the atmosphere (neutral and/or ionized) between the lines of sight to the phase calibrator and the target source. If we determine the relative gain amplitudes and phases for different antennas using the phase calibrator, we can later determine the absolute flux density scale by comparing the gain amplitudes <math>g_i</math> derived for 3C 286 with those derived for the phase calibrator. This will eventually be done using the task {{fluxscale}}. Since there is no such thing as absolute phase, we determine a zero phase by selecting a reference antenna for which the gain phase is defined to be zero.<br />
<br />
In principle, one could determine the complex antenna gains for all sources with a single invocation of {{gaincal}}; for clarity here, two separate invocations will be used.<br />
<br />
In the first step, we derive the appropriate complex gains <math>g_i</math> and <math>\theta_i</math> for the flux density calibrator 3C 286.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1331+3030',spw='0:5~58',<br />
refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',solint='inf')<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' : Produce a new calibration table containing these gain solutions. In order to make the bookkeeping easier, a '1' is appended to the file name to distinguish it from the earlier set of gain solutions, which are effectively being "thrown away."<br />
* spw='0:5~58' : From the inspection of the bandpass, one can determine the range of edge channels that are affected by the bandpass filter rolloff. Because the amplitude is dropping rapidly in these channels, one does not want to include them in the solution.<br />
* gaintype='G' and calmode='ap' : Solve for the complex antenna gains for 3C 286.<br />
* solint='inf' : Produce a solution for each scan.<br />
* gaintable='3c391_ctm_mosaic.bcal0' : Use the bandpass solutions determined earlier to correct for the bandpass shape before solving for the gain amplitudes.<br />
After reviewing the inputs to {{gaincal}} and running it, one could use {{plotcal}} to plot the solutions. While a useful sanity check, the plots themselves will be rather sparse as only a single gain amplitude is being determined for each antenna for each scan.<br />
<br />
<br />
In the second step, the appropriate complex gains for a direction on the sky close to the target source will be determined from the phase calibrator J1822-0938. We also determine the complex gains for the polarization calibrator source J0319+4130.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1822-0938,J0319+4130',<br />
spw='0:5~58',refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',<br />
solint='inf',append=True)<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' and append=True : In all previous invocations of {{gaincal}}, append has been set to False. Here, the gain solutions from the phase calibrators are going to be appended to the existing set from 3C 286. In following steps, all of these gain solutions will then be used together to derive a set of complex gains that are applied to the science data for the target source.<br />
If one checks the gain phase solutions using {{plotcal}}, one should see several solutions for each antenna as a function of time. In order to track the phases, the phase calibrator is typically observed much more frequently during the course of an observation than is the flux density calibrator. In the examples shown below, note that one of the panels is blank, which corresponds to antenna 13, the one flagged earlier in the process.<br />
<br />
[[Image:plotcal-J1822-0398-phase-R.png|200px|thumb|left|gain phase solutions for J1822-0398, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0398, L polarization]]<br />
<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Applying_the_calibration Applying the Calibration]].]</strong><br />
<br />
Having set the complex gains, we now 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).<br />
<br />
Our initial run of {{setjy}} only set the total intensity of our flux calibrator source, 3C 286. This source is known to have a fairly stable fractional polarization of 11.2% at C-band, and a polarization position angle of 66 degrees. NRAO conducted regular monitoring of a number of polarization calibrators (including 3C 286) from 1999 through 2009. If you go to the [http://www.vla.nrao.edu/astro/calib/polar/ polarization calibration webpage] and follow the link for a particular year, then search for '1331+305 C band' (1331+305 is better known as 3C 286), you will see in the table the measured values for the percentage polarization and polarization position angle.<br />
<br />
In order to calibrate the position angle, we need to set the appropriate values for Stokes Q and U. Examining our casapy.log file to find the output of {{setjy}}, we find that the total intensity was set to 7.74664 Jy in spw0. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U.<br />
<br />
<source lang="python"><br />
# In CASA<br />
i0=7.74664 # Stokes I value for spw 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0<br />
</source><br />
<br />
We now set the values of Stokes Q and U for 3C 286, using {{setjy}} as we did before.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',modimage='',spw='0',fluxdensity=[i0,q0,u0,0])<br />
</source><br />
* modimage=' ' : A model image is not used here.<br />
<br />
Note that the Stokes V flux value is set to zero, corresponding to no circular polarization.<br />
<br />
==== Solving for the Leakage Terms ====<br />
<br />
The task we will use to do all the polarization calibration is {{polcal}}. In this data set, we observed the unpolarized calibrator J0319+4130 (a.k.a. 3C 84) in order to solve for the instrumental polarization. {{polcal}} uses the Stokes IQU values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The final function call is:<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.pcal0',field='J0319+4130',<br />
spw='',refant=refant,poltype='Df',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'],<br />
gainfield=['J0319+4130', 'J1331+3030'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* caltable='3c391_ctm_mosaic.pcal0' : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the ''caltable'' argument.<br />
* field='J0319+4130' : We use the unpolarized source J0319+4130 (a.k.a. 3C 84) to solve for the leakages.<br />
* poltype='Df' : We will solve for the leakages (''D'') on a per-channel basis (''f''). Had we have 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' '').<br />
* gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'] : We apply our existing gain and bandpass tables on-the-fly by specifying them in a Python list.<br />
* gainfield=['J0319+4130','J1331+3030'] : Use only the specified sources from 3c391_ctm_mosaic.gcal1 and 3c391_ctm_mosaic.bcal0, respectively, when applying these previous gain and bandpass corrections.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.pcal0',xaxis='chan',yaxis='amp',spw='',field='',iteration='antenna')<br />
</source><br />
<br />
<br />
[[Image:3c391_ctm_plotcal_Df_solutions.jpg|thumb|{{plotcal}} GUI showing the Df solutions from {{polcal}} ]]<br />
This will produce plots similar to that shown at right.<br />
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.<br />
<br />
==== Solving for the R-L polarization angle ====<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.xcal0',poltype='Xf',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0', '3c391_ctm_mosaic.pcal0'],<br />
field='J1331+3030',refant='ea21')<br />
</source><br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.xcal0',xaxis='chan',yaxis='phase',iteration='antenna')<br />
</source><br />
<br />
[[Image:3c391_ctm_plotcal_Xf_solutions.jpg|thumb|{{plotcal}} GUI showing Xf solutions from {{polcal}} ]]<br />
<br />
At this point, your dataset contains all the necessary polarization calibration, which will shortly be applied to the data.<br />
<br />
== Applying the Calibration ==<br />
<br />
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 ''u''-''v'' 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.<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',fluxtable='3c391_ctm_mosaic.fluxscale1',<br />
reference='J1331+3030',transfer='J1822-0938,J0319+4130',append=True)<br />
</source><br />
<br />
[[Image:3C391_fluxscale.png|200px|thumb|right|fluxscale inputs]]<br />
* caltable='3c391_ctm_mosaic.gcal1' : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier<br />
* fluxtable='3c391_ctm_mosaic.fluxscale1' : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains. <br />
* reference='J1331+3030' : We specify the source with the known flux density.<br />
* transfer='J1822-0938,J0319+4130' : We specify the sources whose amplitude gains are to be rescaled.<br />
<br />
{{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. If one's data set has more than 1 spectral window, depending upon where they are spaced and the spectrum of the source, it is quite possible to find (quite) different flux densities at the different frequencies for the secondary calibrators. Example output for this data set would be<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO fluxscale::::casa ##########################################<br />
INFO fluxscale::::casa ##### Begin Task: fluxscale #####<br />
INFO fluxscale::::casa<br />
INFO fluxscale::calibrater::open Opening MS: 3c391_mosaic_10s.ms for calibration.<br />
INFO fluxscale::Calibrater:: Initializing nominal selection to the whole MS.<br />
INFO fluxscale::calibrater::fluxscale Beginning fluxscale--(MSSelection version)-------<br />
INFO fluxscale:::: Found reference field(s): J1331+3030<br />
INFO fluxscale:::: Found transfer field(s): J1822-0938 J0319+4130<br />
INFO fluxscale:::: Flux density for J1822-0938 in SpW=0 is: 2.32824 +/- 0.00706023 (SNR = 329.768, nAnt= 25)<br />
INFO fluxscale:::: Flux density for J0319+4130 in SpW=0 is: 13.7643 +/- 0.0348429 (SNR = 395.04, nAnt= 25)<br />
INFO fluxscale::Calibrater::fluxscale Appending result to 3c391_mosaic.fluxscale1<br />
INFO fluxscale:::: Appending solutions to table: 3c391_mosaic.fluxscale1<br />
INFO fluxscale::::casa<br />
INFO fluxscale::::casa ##### End Task: fluxscale #####<br />
</pre><br />
<br />
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 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.<br />
<br />
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.<br />
<br />
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). The relevant function calls are given below, although as explained presently, the calls to {{applycal}} will differ slightly if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1331+3030',gainfield=['J1331+3030','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J0319+4130',gainfield=['J0319+4130','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1822-0938',gainfield=['J1822-0938','','',''],interp=['nearest','','',''])<br />
</source><br />
<br />
* gaintable : We provide a Python list of the calibration tables to be applied. 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.<br />
* gainfield, interp : 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''.<br />
* parang : Since we have performed polarization calibration, we '''must''' set ''parang=True'', or we will discard all that hard work we did earlier. However, if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization_Calibration]] section, the tables 3c391_ctm_mosaic.pcal0 and 3c391_ctm_mosaic.xcal0 will not exist. In this case, you should leave out the final two tables in the ''gaintable'' list, and the final two sets of empty elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. 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.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
gainfield=['J1822-0938','','',''],<br />
interp=['linear','','',''],<br />
parang=True)<br />
</source><br />
<br />
[[Image:3C391_applycal.png|200px|thumb|right|applycal inputs]]<br />
* field : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* gainfield : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* interp : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
[[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]]<br />
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, for one of the parallel-hand correlations (RR or LL; the signal in the cross-hands, RL and LR is much smaller, and will be noiselike for an unpolarized calibrator). This should then 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.<br />
<br />
Inspecting the data at this stage may well show up previously-unnoticed bad data. Plotting up the '''corrected''' amplitude against UV distance, or against time is a good way to find such issues. If you find bad data, you can remove them via interactive flagging in {{plotms}}, or via manual flagging in {{flagdata}} once you have identified the offending antennas/baselines/channels/times. When you are happy that all data (particularly on your target source) look good, you may proceed.<br />
<br />
Now that the calibration has been applied to the target data, we can split off the science targets, creating a new, calibrated measurement set containing all the target fields.<br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='3c391_ctm_mosaic_10s_spw0.ms',outputvis='3c391_ctm_mosaic_spw0.ms',<br />
datacolumn='corrected',field='2~8')<br />
</source><br />
<br />
* outputvis : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* datacolumn : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* field : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Imaging ==<br />
<br />
Now that we have split off the target data into a separate measurement set with all the calibration applied, it's time to make an image. Recall from the lectures that the visibility data and the sky brightness distribution (a.k.a. image) are Fourier transform pairs<br />
<br />
<math><br />
I(l,m) = \int V(u,v) e^{[2\pi i(ul + vm)]} dudv<br />
</math><br />
<br />
The <math>u</math> and <math>v</math> coordinates are the baselines, measured in units of the observing wavelength while the <math>l</math> and <math>m</math> coordinates are the direction cosines on the sky. For generality, the sky coordinates are written in terms of direction cosines, but for most EVLA (and ALMA) observations they can be related simply to the right ascension (<math>l</math>) and declination (<math>m</math>). Also recall from the lectures that this equation is valid only if the <math>w</math> coordinate of the baselines can be neglected. This assumption is almost always true at high frequencies and smaller EVLA configurations (such as the 4.6 GHz, D-configuration observations here); the <math>w</math> coordinate cannot be neglected at lower frequencies and larger configurations (e.g., 0.33 GHz, A-configuration observations). This expression also neglects other factors, such as the shape of the primary beam. For more information on imaging, see [[http://casa.nrao.edu/docs/userman/UserManch5.html#x236-2330005 Synthesis Imaging]] within the CASA Reference Manual.<br />
<br />
<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image.<br />
Assuming you did the polarization calibration earlier, a command line call to image and deconvolve the dataset would be:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54], smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
If you previously skipped the polarization calibration, you should instead set ''stokes='I' '' and ''psfmode='clark' ''.<br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* mode='mfs' : Use multi-frequency synthesis imaging. The fractional bandwidth of these data is non-zero (128 MHz at a central frequency of 4.6 GHz). Recall that the u and v coordinates are defined as the baseline coordinates, measured in wavelengths. Thus, slight changes in the frequency from channel to channel result in slight changes in u and v. There is a concomitant improvement in u-v coverage if the visibility data from the multiple spectral channels are gridded separately onto the u-v plane, as opposed to treating all spectral channels as having the same frequency.<br />
* niter=5000,gain=0.1,threshold='1.0mJy' : Recall that the CLEAN gain is the amount by which a CLEAN component is subtracted during the CLEANing process. niter and threshold are (coupled) means of determining when to stop the CLEANing process, with niter specifying to find and subtract that many CLEAN components while threshold specifies a minimum flux density threshold a CLEAN component can have before CLEAN stops. See also interactive below. Imaging is an iterative process, and to set the threshold and number of iterations, it is usually wise to CLEAN interactively in the first instance, stopping when spurious emission from sidelobes (arising from gain errors) dominates the residual emission in the field. Here, we have used our experience in interactive mode to set a threshold level based on the rms noise in the resulting image. The number of iterations should then be set high enough to reach this threshold.<br />
* interactive=T : Very often, particularly when one is exploring how a source appears for the first time, it can be valuable to interact with the CLEANing process. If True, interactive causes a {{viewer}} window to appear. One can then set CLEAN regions, restricting where CLEAN searches for CLEAN components, as well as monitor the CLEANing process. A standard procedure is to set a large value for niter, and stop the CLEANing when it visually appears to be approaching the noise level. This procedure also allows one to change the CLEANing region, in cases when low-level intensity becomes visible as the CLEANing process proceeds. For more details, see [[http://casa.nrao.edu/docs/userman/UserMansu254.html#x292-2870005.3.14 Interactive Cleaning]], and also the discussion below.<br />
* imsize=[576,576], cell=['2.5arcsec','2.5arcsec'] : See the discussion below regarding the setting of the image size and cell size.<br />
* stokes='IQUV' and psfmode='clarkstokes' : Separate images will be made in all four polarizations (total intensity I, linear polarizations Q and U, and circular polarization V), and, with psfmode='clarkstokes', the Clark CLEAN algorithm will deconvolve each Stokes plane separately thereby making the polarization image more independent of the total intensity.<br />
* weighting='briggs',robust=0.0 : 3C 391 has diffuse, extended emission that is (at least partially) 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, Briggs weighting is used (intermediate between natural and uniform weighting), with a default robust factor of 0.<br />
* imagermode='mosaic', ftmachine='mosaic' : The data consist of a 7-pointing mosaic, since the supernova remnant fills almost the full primary beam at 4.6 GHz. A mosaic combines the data from all of the fields, with imaging and deconvolution being done jointly on all 7 fields. A mosaic both helps compensate for the shape of the primary beam and reduces the amount of large (angular) scale structure that is resolved out by the interferometer.<br />
* multiscale=[0, 6, 18, 54], smallscalebias=0.9 : A multi-scale CLEANing algorithm is used because the supernova remnant contains both diffuse, extended structure on large spatial scales and finer filamentary structure on smaller scales. The settings for multiscale are in units of pixels, with 0 pixels equivalent to the traditional delta-function CLEAN. The scales here are chosen to provide delta functions and then three logarithmically scaled sizes to fit to the data. The first scale (6 pixels) is chosen to be comparable to the size of the beam. The smallscalebias attempts to balance the weight given to larger scales, which often have more flux density, and the smaller scales, which often are brighter. Considerable experimentation is likely to be necessary; one of the authors of this document found that it was useful to CLEAN several rounds with this setting, change multiscale to be multiscale=[] and remove much of the smaller scale structure, then return to this setting.<br />
<br />
<br />
<br />
We need to select the appropriate pixel size to use. Using plotms to look at the newly-calibrated, target-only data set:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_spw0.ms',xaxis='uvdist_l',yaxis='amp')<br />
</source><br />
we select the axes tab on the left hand side, and select UVDist_L as the x-axis. <br />
[[Image:3c391 ctm spw0 uvplt.jpg|thumb|{{plotms}} GUI showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
This gives the plot shown at right.<br />
<br />
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.5 arcseconds in both co-ordinates by setting ''cell=['2.5arcsec','2.5arcsec']''. The supernova remnant is known to have a diameter of order 9 arcmin, which corresponds to about 216 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\times216</math>. We therefore set ''imsize=[576,576]''.<br />
<br />
[[Image:3C391 interactive clean.png|thumb|Example of interactive cleaning]]<br />
As mentioned above, we can guide the clean process by allowing it to find clean components only within a user-specified region. The easiest way to do this is via interactive clean. When {{clean}} runs in interactive mode, a viewer window will pop up as shown right. To get a more detailed view of the central regions containing the emission, zoom in by tracing out a rectangle with your left mouse button and double-clicking inside the zoom box you just made. Play with the color scale to bring out the emission better, by holding down the middle mouse button and moving it around. To create a clean box (a region within which components may be found), you can either hold down the right mouse button and trace out a rectangle around the source, then double click inside that rectangle to set it as a box. Alternatively, you can trace out a more generic shape to better enclose the irregular outline of the supernova remnant. To do that, right-click on the icon highlighted in green in the figure shown at right. Then trace out a shape by right-clicking where you want the corners of that shape. Once you have come full circle, the shape will be traced out in green, with small squares at the corners. Double-click inside this region and the green outline will turn white. You have now set your clean region. To toggle back to the rectangle tracer again, right-click on the icon circled in green in the figure at right. If you have made a mistake with your clean box, click on the "Erase" button, trace out a rectangle around your erroneous region, and double click inside that rectangle. You can also set multiple clean regions. By default, all clean regions will apply only to the plane shown. To change this to select all regions, click the "All Channels" button at the top. <br />
<br />
When you are happy with your clean regions, press the green circular arrow button on the far right to continue deconvolution. After completing a cycle, a revised image will come up. As the brightest points are removed from the image ("cleaned" off), fainter emission may show up. You can adjust the clean boxes each cycle, to enclose all real emission. After many cycles, once only noise is left, you can hit the red and white cross icon to stop cleaning.<br />
<br />
<br />
[[Image:3c391_ctm_i_image.jpg|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391 at 4600 MHz]]<br />
{{clean}} will make several output files, all named with the prefix given as ''imagename''. These include:<br />
* .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<br />
* .flux - the effective response of the telescope (the primary beam)<br />
* .flux.pbcoverage - the effective response of the full mosaic image<br />
* .mask - the areas where you have permitted imager to find clean components<br />
* .model - the sum of all the clean components, which has been stored as the model_data column in the measurement set<br />
* .psf - the dirty beam, which is being deconvolved from the true sky brightness during the clean process<br />
* .residual - what is left at the end of the deconvolution process; this is useful to diagnose whether or not to clean more deeply<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
<br />
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).<br />
<br />
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.<br />
<br />
The example above illustrates multi-scale CLEAN. Not all sources or fields will require multi-scale CLEAN; for reference, here is the same data set, but without multi-scale CLEANing.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_no_multiscale_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
== Next Steps ==<br />
<br />
There are a variety of additional analyses that could be done, including extracting the statistics of the images just produced, continuing with the polarization imaging, and self-calibration of the data. Examples of these topics are included in <br />
[[EVLA Advanced Topics 3C391]].<br />
<br />
If one is reading this as part of the Day 1 Summer School Tutorial, and there is time, one could consider beginning one of these advanced topics.</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=3681EVLA Continuum Tutorial 3C3912010-06-03T19:28:16Z<p>Jgallimo: /* Gain Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
<br />
== Overview ==<br />
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]]. As an alternative to the function calls as provided by the script extractor, all tasks may be run interactively by typing ''default taskname'' to load the task, ''inp'' to examine the inputs, and ''go'' once those inputs have been set to your satisfaction. Allowed inputs are shown in blue, and bad inputs are colored red. If you prefer this more interactive CASA experience, screenshots of the inputs to the different tasks used in the data reduction are provided, to illustrate which parameters need to be set. The attentive reader will see that all non-default inputs to the tasks correspond exactly to the parameters set in the function calls derived from the script extractor.<br />
<br />
Should you use the script generated by the [[Extracting_scripts_from_these_tutorials | script extractor]], be aware that it will require some small amount of interaction, occasionally suggesting that you close the graphics window and hitting return in the terminal to proceed. It is in fact unnecessary to close the graphics windows (it is suggested that you do so purely to keep your desktop uncluttered), and in one case (that of {{plotms}}), you '''must''' leave the graphics window open, as the GUI cannot be reopened without first exiting from CASA.<br />
<br />
== Obtaining the Data ==<br />
<br />
For the purposes of this tutorial, we have created a "starting" data set, upon which several initial processing steps have already been conducted. This data set may already be present on the machine that you are using; if not, obtain it from the<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz CASA data archive].<br />
<br />
We are providing this "starting" data set, rather than the "true" initial data set for (at least) two reasons. First, many of these initial processing steps can be rather time consuming (> 1 hr), and the time for the data reduction tutorial is limited. Second, while necessary, many of these steps are not fundamental to the calibration and imaging process, upon which we want to focus today. For completeness, however, here are the steps that were taken from the initial data set to produce the "starting" data set:<br />
* The data loaded into CASA, converting the initial Science Data Model (SDM) file into a measurement set.<br />
* Basic data flagging was applied, to account for "shadowing" of the antennas. These data are from the D configuration, in which antennas are particularly susceptible to being blocked or "shadowed" by other antennas in the array, depending upon the elevation of the source.<br />
* The data were averaged to 10-second samples, from the initial 1-second correlator sample time. In the D configuration, the fringe rate is relatively slow and time-average smearing is less of a concern.<br />
* The data were acquired with two spectral windows (around 4.6 and 7.5 GHz). Because of disk space concerns on some machines, the focus will be on only one of the two spectral windows.<br />
<br />
We emphasize that, were this a real science observation, all of these steps would need to be run. Detailed instructions on obtaining the data from the archive and creating this "starting" data set may be found in the [[Obtaining EVLA Data: 3C 391 Example]] tutorial.<br />
<br />
== Examining the Data ==<br />
<br />
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. From this, we find the following:<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Information from observing log:<br />
There is no C-band receivers on ea13<br />
Antenna ea06 is out of the array<br />
Antenna ea15 has some corrupted data<br />
Antennas ea10, ea12, ea22 do not have good baseline positions<br />
Gusty winds, mixed clouds, API rms up to 11.5.<br />
</pre><br />
<br />
Before beginning our data reduction, we must start CASA. If you have not used CASA before, some helpful tips are available on the [[Getting Started in CASA]] page.<br />
<br />
Once you have CASA up and running in the directory containing the data, then start your data reduction by getting some basic information about the data. The task {{listobs}} can be used to get a listing of the individual scans comprising the observation, the frequency setup, source list, and antenna locations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='3c391_ctm_mosaic_10s_spw0.ms',verbose=T)<br />
</source><br />
<br />
{{listobs}} should now produce output similar to the following in the casa logger. (Note that the listing shown is for both spectral windows.)<br />
<br />
<pre style="background-color: #ffe4b5;"><br />
INFO listobs::::casa ##########################################<br />
INFO listobs::::casa ##### Begin Task: listobs #####<br />
INFO listobs::::casa <br />
INFO listobs::ms::summary ================================================================================<br />
INFO listobs::ms::summary+ MeasurementSet Name: /export/home/hamal/jmiller/TDEM0001_sb1218006/3c391_mosaic_fullres.ms MS Version 2<br />
INFO listobs::ms::summary+ ================================================================================<br />
INFO listobs::ms::summary+ Observer: Dr. James Miller-Jones Project: T.B.D. <br />
INFO listobs::ms::summary+ Observation: EVLA<br />
INFO listobs::ms::summary Data records: 18666050 Total integration time = 28716 seconds<br />
INFO listobs::ms::summary+ Observed from 24-Apr-2010/08:01:34.5 to 24-Apr-2010/16:00:10.5 (UTC)<br />
INFO listobs::ms::summary <br />
INFO listobs::ms::summary+ ObservationID = 0 ArrayID = 0<br />
INFO listobs::ms::summary+ Date Timerange (UTC) Scan FldId FieldName nVis Int(s) SpwIds<br />
INFO listobs::ms::summary+ 24-Apr-2010/08:01:34.5 - 08:02:28.5 1 0 J1331+3030 35750 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:02:29.5 - 08:09:27.5 2 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:09:28.5 - 08:16:26.5 3 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:16:27.5 - 08:24:25.5 4 1 J1822-0938 311350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:24:26.5 - 08:29:44.5 5 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:29:45.5 - 08:34:43.5 6 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:34:44.5 - 08:39:42.5 7 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:39:43.5 - 08:44:41.5 8 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:44:42.5 - 08:49:40.5 9 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:49:41.5 - 08:54:40.5 10 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:54:41.5 - 08:59:39.5 11 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:59:40.5 - 09:01:29.5 12 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:01:30.5 - 09:06:48.5 13 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:06:49.5 - 09:11:47.5 14 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:11:48.5 - 09:16:46.5 15 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:16:47.5 - 09:21:45.5 16 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:21:46.5 - 09:26:44.5 17 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:26:45.5 - 09:31:44.5 18 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:31:45.5 - 09:36:43.5 19 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:36:44.5 - 09:38:32.5 20 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:38:33.5 - 09:43:52.5 21 2 3C391 C1 208000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:43:53.5 - 09:48:51.5 22 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:48:52.5 - 09:53:50.5 23 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:53:51.5 - 09:58:49.5 24 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:58:50.5 - 10:03:48.5 25 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:03:49.5 - 10:08:47.5 26 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:08:48.5 - 10:13:47.5 27 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:13:48.5 - 10:15:36.5 28 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:15:37.5 - 10:20:55.5 29 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:20:56.5 - 10:25:55.5 30 3 3C391 C2 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:25:56.5 - 10:30:54.5 31 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:30:55.5 - 10:35:53.5 32 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:35:54.5 - 10:40:52.5 33 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:40:53.5 - 10:45:51.5 34 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:45:52.5 - 10:50:51.5 35 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:50:52.5 - 10:52:40.5 36 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:52:41.5 - 10:57:39.5 37 0 J1331+3030 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:57:40.5 - 11:02:39.5 38 1 J1822-0938 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:02:40.5 - 11:07:58.5 39 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:07:59.5 - 11:12:47.5 40 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:12:48.5 - 11:17:36.5 41 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:17:37.5 - 11:22:25.5 42 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:22:26.5 - 11:27:15.5 43 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:27:16.5 - 11:32:04.5 44 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:32:05.5 - 11:36:53.5 45 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:36:54.5 - 11:38:43.5 46 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:38:44.5 - 11:44:02.5 47 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:44:03.5 - 11:48:51.5 48 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:48:52.5 - 11:53:40.5 49 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:53:41.5 - 11:58:29.5 50 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:58:30.5 - 12:03:19.5 51 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:03:20.5 - 12:08:08.5 52 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:08:09.5 - 12:12:57.5 53 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:12:58.5 - 12:14:47.5 54 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:14:48.5 - 12:20:06.5 55 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:20:07.5 - 12:24:55.5 56 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:24:56.5 - 12:29:44.5 57 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:29:45.5 - 12:34:34.5 58 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:34:35.5 - 12:39:23.5 59 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:39:24.5 - 12:44:12.5 60 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:44:13.5 - 12:49:01.5 61 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:49:02.5 - 12:50:51.5 62 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:50:52.5 - 12:56:10.5 63 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:56:11.5 - 13:00:59.5 64 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:01:00.5 - 13:05:48.5 65 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:05:49.5 - 13:10:38.5 66 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:10:39.5 - 13:15:27.5 67 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:15:28.5 - 13:20:16.5 68 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:20:17.5 - 13:25:05.5 69 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:25:06.5 - 13:26:55.5 70 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:26:56.5 - 13:32:14.5 71 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:32:15.5 - 13:37:03.5 72 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:37:04.5 - 13:41:52.5 73 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:41:53.5 - 13:46:42.5 74 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:46:43.5 - 13:51:31.5 75 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:51:32.5 - 13:56:20.5 76 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:56:21.5 - 14:01:09.5 77 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:01:10.5 - 14:02:59.5 78 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:03:00.5 - 14:08:18.5 79 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:08:19.5 - 14:13:07.5 80 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:13:08.5 - 14:17:57.5 81 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:17:58.5 - 14:22:46.5 82 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:22:47.5 - 14:27:35.5 83 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:27:36.5 - 14:32:24.5 84 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:32:25.5 - 14:37:13.5 85 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:37:14.5 - 14:39:03.5 86 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:39:04.5 - 14:44:22.5 87 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:44:23.5 - 14:49:11.5 88 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:49:12.5 - 14:54:01.5 89 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:54:02.5 - 14:58:50.5 90 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:58:51.5 - 15:03:39.5 91 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:03:40.5 - 15:08:28.5 92 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:08:29.5 - 15:13:17.5 93 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:13:18.5 - 15:15:07.5 94 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:15:08.5 - 15:20:26.5 95 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:20:27.5 - 15:25:15.5 96 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:25:16.5 - 15:30:05.5 97 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:30:06.5 - 15:34:54.5 98 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:34:55.5 - 15:39:43.5 99 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:39:44.5 - 15:44:32.5 100 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:44:33.5 - 15:49:22.5 101 8 3C391 C7 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:49:23.5 - 15:51:11.5 102 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:51:12.5 - 16:00:10.5 103 9 J0319+4130 350350 1 [0, 1]<br />
INFO listobs::ms::summary (nVis = Total number of time/baseline visibilities per scan) <br />
INFO listobs::ms::summary Fields: 10<br />
INFO listobs::ms::summary+ ID Code Name RA Decl Epoch SrcId nVis <br />
INFO listobs::ms::summary+ 0 N J1331+3030 13:31:08.2880 +30.30.32.9589 J2000 0 774800 <br />
INFO listobs::ms::summary+ 1 J J1822-0938 18:22:28.7042 -09.38.56.8350 J2000 1 1361750<br />
INFO listobs::ms::summary+ 2 NONE 3C391 C1 18:49:24.2440 -00.55.40.5800 J2000 2 2488850<br />
INFO listobs::ms::summary+ 3 NONE 3C391 C2 18:49:29.1490 -00.57.48.0000 J2000 3 2280850<br />
INFO listobs::ms::summary+ 4 NONE 3C391 C3 18:49:19.3390 -00.57.48.0000 J2000 4 2282150<br />
INFO listobs::ms::summary+ 5 NONE 3C391 C4 18:49:14.4340 -00.55.40.5800 J2000 5 2282150<br />
INFO listobs::ms::summary+ 6 NONE 3C391 C5 18:49:19.3390 -00.53.33.1600 J2000 6 2281500<br />
INFO listobs::ms::summary+ 7 NONE 3C391 C6 18:49:29.1490 -00.53.33.1600 J2000 7 2281500<br />
INFO listobs::ms::summary+ 8 NONE 3C391 C7 18:49:34.0540 -00.55.40.5800 J2000 8 2282150<br />
INFO listobs::ms::summary+ 9 Z J0319+4130 03:19:48.1601 +41.30.42.1030 J2000 9 350350 <br />
INFO listobs::ms::summary+ (nVis = Total number of time/baseline visibilities per field) <br />
INFO listobs::ms::summary Spectral Windows: (2 unique spectral windows and 1 unique polarization setups)<br />
INFO listobs::ms::summary+ SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
INFO listobs::ms::summary+ 0 64 TOPO 4536 2000 128000 4536 RR RL LR LL <br />
INFO listobs::ms::summary+ 1 64 TOPO 7436 2000 128000 7436 RR RL LR LL <br />
INFO listobs::ms::summary Sources: 20<br />
INFO listobs::ms::summary+ ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
INFO listobs::ms::summary+ 0 J1331+3030 0 - - <br />
INFO listobs::ms::summary+ 0 J1331+3030 1 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 0 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 1 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 0 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 1 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 0 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 1 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 0 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 1 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 0 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 1 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 0 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 1 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 0 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 1 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 0 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 1 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 0 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 1 - - <br />
INFO listobs::ms::summary Antennas: 26:<br />
INFO listobs::ms::summary+ ID Name Station Diam. Long. Lat. <br />
INFO listobs::ms::summary+ 0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
INFO listobs::ms::summary+ 1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
INFO listobs::ms::summary+ 2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
INFO listobs::ms::summary+ 3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
INFO listobs::ms::summary+ 4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
INFO listobs::ms::summary+ 5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
INFO listobs::ms::summary+ 6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
INFO listobs::ms::summary+ 7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
INFO listobs::ms::summary+ 8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
INFO listobs::ms::summary+ 9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
INFO listobs::ms::summary+ 10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
INFO listobs::ms::summary+ 11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
INFO listobs::ms::summary+ 12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
INFO listobs::ms::summary+ 13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
INFO listobs::ms::summary+ 14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
INFO listobs::ms::summary+ 15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
INFO listobs::ms::summary+ 16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
INFO listobs::ms::summary+ 17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
INFO listobs::ms::summary+ 18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
INFO listobs::ms::summary+ 19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
INFO listobs::ms::summary+ 20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
INFO listobs::ms::summary+ 21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
INFO listobs::ms::summary+ 22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
INFO listobs::ms::summary+ 23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
INFO listobs::ms::summary+ 24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
INFO listobs::ms::summary+ 25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
INFO listobs::::casa <br />
INFO listobs::::casa ##### End Task: listobs #####<br />
INFO listobs::::casa ##########################################<br />
</pre><br />
<br />
Note that the antenna IDs (which are numbered sequentially up to the total number of antennas in the array; 0 through 25 in this instance) do not correspond to the actual antenna names (ea01 through ea28; these numbers correspond to those painted on the side of the dishes). During our data reduction, we can refer to the antennas using either convention; ''antenna='22' '' would correspond to ea25, whereas ''antenna='ea22' '' would correspond to ea22. Note that the antenna numbers in the observer log correspond to the actual antenna names, i.e. the 'ea??' numbers given in listobs.<br />
<br />
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!). <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotants(vis='3c391_ctm_mosaic_10s_spw0.ms',figfile='3c391_ctm_mosaic_antenna_layout.png')<br />
clearstat() # This removes the table lock generated by plotants in script mode<br />
</source><br />
<br />
[[Image:3c391_ctm_plotants_parameters.jpg|200px|thumb|left|plotants parameters]]<br />
[[Image:3C391_mosaic-plotants.png|200px|thumb|center|plotants figure]]<br />
<br />
== Examining and Editing the Data ==<br />
<br />
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.<br />
<br />
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 less than 1 minute long.) This first scan can safely be deleted.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,scan='1')<br />
</source><br />
<br />
[[Image:3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
* <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.)<br />
* <strong>mode='manualflag'</strong> : Specific data are going to be selected to be edited. <br />
* <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 ''help 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.)<br />
<br />
If satisfied with the inputs, run this task. The initial display in the logger will include <br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: flagdata #####<br />
flagdata::::casa<br />
attached MS [...]<br />
Saving current flags to manualflag_1 before applying new flags<br />
Creating new backup flag file called manualflag_1<br />
</pre><br />
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_1. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used.<br />
<br />
<br />
<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea13,ea15')<br />
</source><br />
* antenna='ea13' : Once again, this parameter requires a string input. Remember that antenna='ea13' and 'antenna='13' are <em>not</em> the same antenna. (See the discussion after our call to {{listobs}} above.)<br />
<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',mode='quack',quackinterval=10.0,quackmode='beg')<br />
</source><br />
* mode='quack' : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* 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.<br />
* 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.<br />
<br />
<br />
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}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat() # This removes any existing table locks generated by flagdata<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',xaxis='',yaxis='',averagedata=False,transform=False,extendflag=False,<br />
plotfile='',selectdata=True,field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* xaxis=' ', yaxis=' ' : One can choose the axes of the plot, i.e., the way of visualizing the data, by using the GUI display once the task is executed.<br />
* averagedata=F : It is possible to average the data in time, frequency, etc. <br />
* transform=F : It is possible to change the velocity reference frame of the data.<br />
* 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.<br />
* plotfile=' ' : It is possible to produce a hard copy (e.g., for a paper, report, or Web site) by specifying a file.<br />
* selectdata=T : One can choose to plot only subsets of the data.<br />
* field='0': The entire dataset is rather large, and different sources have very different amplitudes, so it is advisable to start by loading a subset of the data. One can later loop through the different fields (i.e. sources) and spectral windows using the GUI interface.<br />
<br />
In this case, many other 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.<br />
<br />
{{plotms}} should produce a GUI, with the default view being to show the visibility amplitude as a function of time. The figure at right shows the result of running {{plotms}} without the field selection (''field='0' '') discussed above.<br />
[[Image:plotms-default.png|200px|right|thumb|plotms default GUI view, having loaded all fields at once]]<br />
{{plotms}} allows one to select and view the data in many ways. Across the top of the left 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.<br />
<br />
In the default view, the 'Plots' tab is visible, and there are a number of tabs running down the side of the left 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.<br />
<br />
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 (baseline length, in meters), 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., <math>\sqrt{u^2+v^2}</math>). 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.) <br />
<br />
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]. To plot baseline length in wavelengths rather than meters, one needs to select ''UVDist_L'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view of 3C 391]]<br />
<br />
<br />
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.<br />
<br />
'''Do not''' close the plotms GUI after running {{plotms}}, or you will need to exit casapy and restart if at any point you wish to run plotms again, otherwise the GUI will not come up a second time.<br />
<br />
== Calibrating the Data ==<br />
<br />
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. <br />
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.<br />
<br />
Recall that the observed visibility <math>V^{\prime}</math> between two antennas <math>(i,j)</math> is related to the "true" visibility <math>V</math> by <br />
<br />
<math><br />
V^{\prime}_{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)\,e^{i [\theta_i(t) - \theta_j(t)]} <br />
</math><br />
<br />
Here, for generality, we show the visibility as a function of frequency <math>f</math> and spatial wavenumbers <math>u</math> and <math>v</math>. The other terms are <br />
* <math>g_i</math> and <math>\theta_i</math> 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 <math>t</math> to indicate that they can change with temperature, atmospheric conditions, etc.<br />
* <math>B_i</math> is the complex bandpass, the instrumental response as a function of frequency, <math>f</math>. As shown here, the bandpass may also vary as a function of time.<br />
* <math>b(t)</math> 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. <br />
Strictly, the equation above is a simplification of a more general measurement equation formalism, but it is a useful simplification in many cases.<br />
<br />
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., a priori models for the calibrators, and those derived 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. If you have started with the 10s-averaged dataset suggested at the top of this tutorial, this step has already been done for you, so may be omitted.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',spw='')<br />
</source><br />
<br />
All parameters are set to blank so that the initialization occurs for all sources and spectral windows.<br />
<br />
<br />
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 <math>g_i</math> values.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',<br />
modimage='/home/casa/data/nrao/VLA/CalModels/3C286_C.im',standard='Perley-Taylor 99',<br />
fluxdensity=-1)<br />
</source><br />
<br />
[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]<br />
* 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.<br />
* 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.<br />
* 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.<br />
* fluxdensity=-1 : It is possible to specify (i.e., force) the flux density of the source to be a particular value. Setting ''fluxdensity = -1'' (as done here) asks {{setjy}} to calculate the value based on a set of standard models if the source is one of the standard flux calibrators (i.e. 3C 286, 3C 48, or 3C 147).<br />
* spw='0' : The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw, but it will not hurt to do so. Had the spectral window 0 not been split off, as has been done here, we might wish to specify the spectral window because, in this observation, the spectral windows were sufficiently separated that two different model images for 3C 286 would be appropriate; 3C286_C.im at 4.6 GHz and 3C286_X.im at 7.5 GHz. This would require two separate runs of {{setjy}}, one for each spectral window. If the spectral windows were much closer together, it might be possible to calibrate both using the same model.<br />
<br />
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.<br />
<br />
The output from {{setjy}} should look similar to the following.<br />
<pre style="background-color: #ffe4b5;"><br />
INFO taskmanager::::casa ##### async task launch: setjy ########################<br />
INFO setjy::imager::setjy() J1331+3030 spwid= 0 [I=7.747, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
INFO setjy::imager::setjy() Using model image /home/casa/data/nrao/VLA/CalModels/3C286_C.im<br />
INFO setjy::imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
INFO setjy::imager::setjy() Scaling model image to I=7.74664 Jy for visibility prediction.<br />
INFO setjy::imager::data selection Selecting data<br />
</pre><br />
As set, the flux density scale is being set only for spectral window 0 (''spw='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. <br />
<br />
<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass.png|200px|thumb|right|bandpass illustration]]<br />
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 right. 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 as well. The variations with frequency are a reflection of the (slightly) different antenna bandpasses. (<em>Exercise for the reader, reproduce this plot using {{plotms}}.</em>)<br />
<br />
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. While amplitude variations will have little effect on the bandpass solutions, it is important to solve for any phase variations with time to prevent decorrelation when vector averaging the data in computing the bandpass solutions.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal0',field='J1331+3030',<br />
refant='ea21',spw='0:27~36',calmode='p',solint='int',minsnr=5,solnorm=T)<br />
</source><br />
<br />
[[Image:3C391_gaincal0.png|200px|thumb|right|gaincal inputs for first gain solutions]]<br />
* caltable='3c391_ctm_mosaic.gcal0' : The gain solutions will be stored in an external table.<br />
* 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.<br />
* 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.<br />
* spw='0: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. Also note that, even though these data have only a single spectral window, the syntax requires specifying the spectral window in order to specify the spectral channels.<br />
* calmode='p' : Solve for only the phase portion of the gain.<br />
* 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)<br />
* 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.<br />
* solnorm=T : Strictly, for a phase-only solution, the amplitudes should be normalized by zero. This setting enforces that.<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-R.png')<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='L',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-L.png')<br />
</source><br />
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.<br />
[[Image:plotcal-3C286-G0-phase-R.png|200px|thumb|left|gain phases for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-phase-L.png|200px|thumb|center|gain phases for 3C 286, L polarization]]<br />
<br />
<br />
Alternatively, one can choose to inspect solutions for a single antenna at a time, stepping through each antenna in sequence:<br />
<source lang="python"><br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',iteration='antenna',plotrange=[-1,-1,-180,180],timerange='08:02:00~08:17:00')<br />
</source><br />
Antennas which have been flagged will show a blank plot, since there are no solutions for these antennas. Note the phase jump on antenna ea05. You may wish to flag this antenna:<br />
<source lang="python"><br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea05',field='J1331+3030',timerange='08:02:00~08:17:00')<br />
</source><br />
<br />
Now form the bandpass itself, using the phase solutions just derived.<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='3c391_ctm_mosaic_10s_spw0.ms',gaintable='3c391_ctm_mosaic.gcal0',caltable='3c391_ctm_mosaic.bcal0',<br />
field='J1331+3030',spw='',refant='ea21',solnorm=True,combine='scan',solint='inf',bandtype='B')<br />
</source><br />
<br />
[[Image:3C391_bandpass.png|200px|thumb|right|bandpass inputs]]<br />
* 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.<br />
* caltable='3c391_ctm_mosaic.bcal0' : Specify where to store the bandpass corrections.<br />
* solnorm=T : Make sure that the amplitudes of the bandpass corrections are normalized to unity.<br />
* 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.<br />
* 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.<br />
<br />
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. We use ''iteration='antenna' '' to step through separate plots for each antenna.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='R',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-R.png')<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='L',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-L.png')<br />
</source><br />
<br />
[[Image:plotcal-3C286-G0-bandpass-R.png|200px|thumb|left|bandpass for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-bandpass-L.png|200px|thumb|center|bandpass for 3C 286, L polarization]]<br />
<br />
<br />
=== Gain Calibration ===<br />
<br />
The next step is to derive corrections for the complex antenna gains, <math>g_i</math> and <math>\theta_i</math>. As discussed in the lectures and above, the absolute magnitude of the gain amplitudes <math>g_i</math> are determined by reference to a standard flux density calibrator. In order to determine the appropriate complex gains for the target source, one wants to observe a so-called phase calibrator that is much closer to the target, in order to minimize differences through the atmosphere (neutral and/or ionized) between the lines of sight to the phase calibrator and the target source. If we determine the relative gain amplitudes and phases for different antennas using the phase calibrator, we can later determine the absolute flux density scale by comparing the gain amplitudes <math>g_i</math> derived for 3C 286 with those derived for the phase calibrator. This will eventually be done using the task {{fluxscale}}. Since there is no such thing as absolute phase, we determine a zero phase by selecting a reference antenna for which the gain phase is defined to be zero.<br />
<br />
In principle, one could determine the complex antenna gains for all sources with a single invocation of {{gaincal}}; for clarity here, two separate invocations will be used.<br />
<br />
In the first step, we derive the appropriate complex gains <math>g_i</math> and <math>\theta_i</math> for the flux density calibrator 3C 286.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1331+3030',spw='0:5~58',<br />
refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',solint='inf')<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' : Produce a new calibration table containing these gain solutions. In order to make the bookkeeping easier, a '1' is appended to the file name to distinguish it from the earlier set of gain solutions, which are effectively being "thrown away."<br />
* spw='0:5~58' : From the inspection of the bandpass, one can determine the range of edge channels that are affected by the bandpass filter rolloff. Because the amplitude is dropping rapidly in these channels, one does not want to include them in the solution.<br />
* gaintype='G' and calmode='ap' : Solve for the complex antenna gains for 3C 286.<br />
* solint='inf' : Produce a solution for each scan.<br />
* gaintable='3c391_ctm_mosaic.bcal0' : Use the bandpass solutions determined earlier to correct for the bandpass shape before solving for the gain amplitudes.<br />
After reviewing the inputs to {{gaincal}} and running it, one could use {{plotcal}} to plot the solutions. While a useful sanity check, the plots themselves will be rather sparse as only a single gain amplitude is being determined for each antenna for each scan.<br />
<br />
<br />
In the second step, the appropriate complex gains for a direction on the sky close to the target source will be determined from the phase calibrator J1822-0938. We also determine the complex gains for the polarization calibrator source J0319+4130.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1822-0938,J0319+4130',<br />
spw='0:5~58',refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',<br />
solint='inf',append=True)<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' and append=True : In all previous invocations of {{gaincal}}, append has been set to False. Here, the gain solutions from the phase calibrators are going to be appended to the existing set from 3C 286. In following steps, all of these gain solutions will then be used together to derive a set of complex gains that are applied to the science data for the target source.<br />
If one checks the gain phase solutions using {{plotcal}}, one should see several solutions for each antenna as a function of time. In order to track the phases, the phase calibrator is typically observed much more frequently during the course of an observation than is the flux density calibrator. In the examples shown below, note that one of the panels is blank, which corresponds to antenna 13, the one flagged earlier in the process.<br />
<br />
[[Image:plotcal-J1822-0398-phase-R.png|200px|thumb|left|gain phase solutions for J1822-0398, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0398, L polarization]]<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Applying_the_calibration Applying the Calibration]].]</strong><br />
<br />
Having set the complex gains, we now 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).<br />
<br />
Our initial run of {{setjy}} only set the total intensity of our flux calibrator source, 3C 286. This source is known to have a fairly stable fractional polarization of 11.2% at C-band, and a polarization position angle of 66 degrees. NRAO conducted regular monitoring of a number of polarization calibrators (including 3C 286) from 1999 through 2009. If you go to the [http://www.vla.nrao.edu/astro/calib/polar/ polarization calibration webpage] and follow the link for a particular year, then search for '1331+305 C band' (1331+305 is better known as 3C 286), you will see in the table the measured values for the percentage polarization and polarization position angle.<br />
<br />
In order to calibrate the position angle, we need to set the appropriate values for Stokes Q and U. Examining our casapy.log file to find the output of {{setjy}}, we find that the total intensity was set to 7.74664 Jy in spw0. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U.<br />
<br />
<source lang="python"><br />
# In CASA<br />
i0=7.74664 # Stokes I value for spw 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0<br />
</source><br />
<br />
We now set the values of Stokes Q and U for 3C 286, using {{setjy}} as we did before.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',modimage='',spw='0',fluxdensity=[i0,q0,u0,0])<br />
</source><br />
* modimage=' ' : A model image is not used here.<br />
<br />
Note that the Stokes V flux value is set to zero, corresponding to no circular polarization.<br />
<br />
==== Solving for the Leakage Terms ====<br />
<br />
The task we will use to do all the polarization calibration is {{polcal}}. In this data set, we observed the unpolarized calibrator J0319+4130 (a.k.a. 3C 84) in order to solve for the instrumental polarization. {{polcal}} uses the Stokes IQU values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The final function call is:<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.pcal0',field='J0319+4130',<br />
spw='',refant=refant,poltype='Df',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'],<br />
gainfield=['J0319+4130', 'J1331+3030'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* caltable='3c391_ctm_mosaic.pcal0' : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the ''caltable'' argument.<br />
* field='J0319+4130' : We use the unpolarized source J0319+4130 (a.k.a. 3C 84) to solve for the leakages.<br />
* poltype='Df' : We will solve for the leakages (''D'') on a per-channel basis (''f''). Had we have 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' '').<br />
* gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'] : We apply our existing gain and bandpass tables on-the-fly by specifying them in a Python list.<br />
* gainfield=['J0319+4130','J1331+3030'] : Use only the specified sources from 3c391_ctm_mosaic.gcal1 and 3c391_ctm_mosaic.bcal0, respectively, when applying these previous gain and bandpass corrections.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.pcal0',xaxis='chan',yaxis='amp',spw='',field='',iteration='antenna')<br />
</source><br />
<br />
<br />
[[Image:3c391_ctm_plotcal_Df_solutions.jpg|thumb|{{plotcal}} GUI showing the Df solutions from {{polcal}} ]]<br />
This will produce plots similar to that shown at right.<br />
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.<br />
<br />
==== Solving for the R-L polarization angle ====<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.xcal0',poltype='Xf',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0', '3c391_ctm_mosaic.pcal0'],<br />
field='J1331+3030',refant='ea21')<br />
</source><br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.xcal0',xaxis='chan',yaxis='phase',iteration='antenna')<br />
</source><br />
<br />
[[Image:3c391_ctm_plotcal_Xf_solutions.jpg|thumb|{{plotcal}} GUI showing Xf solutions from {{polcal}} ]]<br />
<br />
At this point, your dataset contains all the necessary polarization calibration, which will shortly be applied to the data.<br />
<br />
== Applying the Calibration ==<br />
<br />
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 ''u''-''v'' 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.<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',fluxtable='3c391_ctm_mosaic.fluxscale1',<br />
reference='J1331+3030',transfer='J1822-0938,J0319+4130',append=True)<br />
</source><br />
<br />
[[Image:3C391_fluxscale.png|200px|thumb|right|fluxscale inputs]]<br />
* caltable='3c391_ctm_mosaic.gcal1' : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier<br />
* fluxtable='3c391_ctm_mosaic.fluxscale1' : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains. <br />
* reference='J1331+3030' : We specify the source with the known flux density.<br />
* transfer='J1822-0938,J0319+4130' : We specify the sources whose amplitude gains are to be rescaled.<br />
<br />
{{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. If one's data set has more than 1 spectral window, depending upon where they are spaced and the spectrum of the source, it is quite possible to find (quite) different flux densities at the different frequencies for the secondary calibrators. Example output for this data set would be<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO fluxscale::::casa ##########################################<br />
INFO fluxscale::::casa ##### Begin Task: fluxscale #####<br />
INFO fluxscale::::casa<br />
INFO fluxscale::calibrater::open Opening MS: 3c391_mosaic_10s.ms for calibration.<br />
INFO fluxscale::Calibrater:: Initializing nominal selection to the whole MS.<br />
INFO fluxscale::calibrater::fluxscale Beginning fluxscale--(MSSelection version)-------<br />
INFO fluxscale:::: Found reference field(s): J1331+3030<br />
INFO fluxscale:::: Found transfer field(s): J1822-0938 J0319+4130<br />
INFO fluxscale:::: Flux density for J1822-0938 in SpW=0 is: 2.32824 +/- 0.00706023 (SNR = 329.768, nAnt= 25)<br />
INFO fluxscale:::: Flux density for J0319+4130 in SpW=0 is: 13.7643 +/- 0.0348429 (SNR = 395.04, nAnt= 25)<br />
INFO fluxscale::Calibrater::fluxscale Appending result to 3c391_mosaic.fluxscale1<br />
INFO fluxscale:::: Appending solutions to table: 3c391_mosaic.fluxscale1<br />
INFO fluxscale::::casa<br />
INFO fluxscale::::casa ##### End Task: fluxscale #####<br />
</pre><br />
<br />
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 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.<br />
<br />
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.<br />
<br />
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). The relevant function calls are given below, although as explained presently, the calls to {{applycal}} will differ slightly if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1331+3030',gainfield=['J1331+3030','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J0319+4130',gainfield=['J0319+4130','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1822-0938',gainfield=['J1822-0938','','',''],interp=['nearest','','',''])<br />
</source><br />
<br />
* gaintable : We provide a Python list of the calibration tables to be applied. 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.<br />
* gainfield, interp : 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''.<br />
* parang : Since we have performed polarization calibration, we '''must''' set ''parang=True'', or we will discard all that hard work we did earlier. However, if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization_Calibration]] section, the tables 3c391_ctm_mosaic.pcal0 and 3c391_ctm_mosaic.xcal0 will not exist. In this case, you should leave out the final two tables in the ''gaintable'' list, and the final two sets of empty elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. 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.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
gainfield=['J1822-0938','','',''],<br />
interp=['linear','','',''],<br />
parang=True)<br />
</source><br />
<br />
[[Image:3C391_applycal.png|200px|thumb|right|applycal inputs]]<br />
* field : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* gainfield : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* interp : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
[[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]]<br />
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, for one of the parallel-hand correlations (RR or LL; the signal in the cross-hands, RL and LR is much smaller, and will be noiselike for an unpolarized calibrator). This should then 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.<br />
<br />
Inspecting the data at this stage may well show up previously-unnoticed bad data. Plotting up the '''corrected''' amplitude against UV distance, or against time is a good way to find such issues. If you find bad data, you can remove them via interactive flagging in {{plotms}}, or via manual flagging in {{flagdata}} once you have identified the offending antennas/baselines/channels/times. When you are happy that all data (particularly on your target source) look good, you may proceed.<br />
<br />
Now that the calibration has been applied to the target data, we can split off the science targets, creating a new, calibrated measurement set containing all the target fields.<br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='3c391_ctm_mosaic_10s_spw0.ms',outputvis='3c391_ctm_mosaic_spw0.ms',<br />
datacolumn='corrected',field='2~8')<br />
</source><br />
<br />
* outputvis : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* datacolumn : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* field : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Imaging ==<br />
<br />
Now that we have split off the target data into a separate measurement set with all the calibration applied, it's time to make an image. Recall from the lectures that the visibility data and the sky brightness distribution (a.k.a. image) are Fourier transform pairs<br />
<br />
<math><br />
I(l,m) = \int V(u,v) e^{[2\pi i(ul + vm)]} dudv<br />
</math><br />
<br />
The <math>u</math> and <math>v</math> coordinates are the baselines, measured in units of the observing wavelength while the <math>l</math> and <math>m</math> coordinates are the direction cosines on the sky. For generality, the sky coordinates are written in terms of direction cosines, but for most EVLA (and ALMA) observations they can be related simply to the right ascension (<math>l</math>) and declination (<math>m</math>). Also recall from the lectures that this equation is valid only if the <math>w</math> coordinate of the baselines can be neglected. This assumption is almost always true at high frequencies and smaller EVLA configurations (such as the 4.6 GHz, D-configuration observations here); the <math>w</math> coordinate cannot be neglected at lower frequencies and larger configurations (e.g., 0.33 GHz, A-configuration observations). This expression also neglects other factors, such as the shape of the primary beam. For more information on imaging, see [[http://casa.nrao.edu/docs/userman/UserManch5.html#x236-2330005 Synthesis Imaging]] within the CASA Reference Manual.<br />
<br />
<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image.<br />
Assuming you did the polarization calibration earlier, a command line call to image and deconvolve the dataset would be:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54], smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
If you previously skipped the polarization calibration, you should instead set ''stokes='I' '' and ''psfmode='clark' ''.<br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* mode='mfs' : Use multi-frequency synthesis imaging. The fractional bandwidth of these data is non-zero (128 MHz at a central frequency of 4.6 GHz). Recall that the u and v coordinates are defined as the baseline coordinates, measured in wavelengths. Thus, slight changes in the frequency from channel to channel result in slight changes in u and v. There is a concomitant improvement in u-v coverage if the visibility data from the multiple spectral channels are gridded separately onto the u-v plane, as opposed to treating all spectral channels as having the same frequency.<br />
* niter=5000,gain=0.1,threshold='1.0mJy' : Recall that the CLEAN gain is the amount by which a CLEAN component is subtracted during the CLEANing process. niter and threshold are (coupled) means of determining when to stop the CLEANing process, with niter specifying to find and subtract that many CLEAN components while threshold specifies a minimum flux density threshold a CLEAN component can have before CLEAN stops. See also interactive below. Imaging is an iterative process, and to set the threshold and number of iterations, it is usually wise to CLEAN interactively in the first instance, stopping when spurious emission from sidelobes (arising from gain errors) dominates the residual emission in the field. Here, we have used our experience in interactive mode to set a threshold level based on the rms noise in the resulting image. The number of iterations should then be set high enough to reach this threshold.<br />
* interactive=T : Very often, particularly when one is exploring how a source appears for the first time, it can be valuable to interact with the CLEANing process. If True, interactive causes a {{viewer}} window to appear. One can then set CLEAN regions, restricting where CLEAN searches for CLEAN components, as well as monitor the CLEANing process. A standard procedure is to set a large value for niter, and stop the CLEANing when it visually appears to be approaching the noise level. This procedure also allows one to change the CLEANing region, in cases when low-level intensity becomes visible as the CLEANing process proceeds. For more details, see [[http://casa.nrao.edu/docs/userman/UserMansu254.html#x292-2870005.3.14 Interactive Cleaning]], and also the discussion below.<br />
* imsize=[576,576], cell=['2.5arcsec','2.5arcsec'] : See the discussion below regarding the setting of the image size and cell size.<br />
* stokes='IQUV' and psfmode='clarkstokes' : Separate images will be made in all four polarizations (total intensity I, linear polarizations Q and U, and circular polarization V), and, with psfmode='clarkstokes', the Clark CLEAN algorithm will deconvolve each Stokes plane separately thereby making the polarization image more independent of the total intensity.<br />
* weighting='briggs',robust=0.0 : 3C 391 has diffuse, extended emission that is (at least partially) 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, Briggs weighting is used (intermediate between natural and uniform weighting), with a default robust factor of 0.<br />
* imagermode='mosaic', ftmachine='mosaic' : The data consist of a 7-pointing mosaic, since the supernova remnant fills almost the full primary beam at 4.6 GHz. A mosaic combines the data from all of the fields, with imaging and deconvolution being done jointly on all 7 fields. A mosaic both helps compensate for the shape of the primary beam and reduces the amount of large (angular) scale structure that is resolved out by the interferometer.<br />
* multiscale=[0, 6, 18, 54], smallscalebias=0.9 : A multi-scale CLEANing algorithm is used because the supernova remnant contains both diffuse, extended structure on large spatial scales and finer filamentary structure on smaller scales. The settings for multiscale are in units of pixels, with 0 pixels equivalent to the traditional delta-function CLEAN. The scales here are chosen to provide delta functions and then three logarithmically scaled sizes to fit to the data. The first scale (6 pixels) is chosen to be comparable to the size of the beam. The smallscalebias attempts to balance the weight given to larger scales, which often have more flux density, and the smaller scales, which often are brighter. Considerable experimentation is likely to be necessary; one of the authors of this document found that it was useful to CLEAN several rounds with this setting, change multiscale to be multiscale=[] and remove much of the smaller scale structure, then return to this setting.<br />
<br />
<br />
<br />
We need to select the appropriate pixel size to use. Using plotms to look at the newly-calibrated, target-only data set:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_spw0.ms',xaxis='uvdist_l',yaxis='amp')<br />
</source><br />
we select the axes tab on the left hand side, and select UVDist_L as the x-axis. <br />
[[Image:3c391 ctm spw0 uvplt.jpg|thumb|{{plotms}} GUI showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
This gives the plot shown at right.<br />
<br />
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.5 arcseconds in both co-ordinates by setting ''cell=['2.5arcsec','2.5arcsec']''. The supernova remnant is known to have a diameter of order 9 arcmin, which corresponds to about 216 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\times216</math>. We therefore set ''imsize=[576,576]''.<br />
<br />
[[Image:3C391 interactive clean.png|thumb|Example of interactive cleaning]]<br />
As mentioned above, we can guide the clean process by allowing it to find clean components only within a user-specified region. The easiest way to do this is via interactive clean. When {{clean}} runs in interactive mode, a viewer window will pop up as shown right. To get a more detailed view of the central regions containing the emission, zoom in by tracing out a rectangle with your left mouse button and double-clicking inside the zoom box you just made. Play with the color scale to bring out the emission better, by holding down the middle mouse button and moving it around. To create a clean box (a region within which components may be found), you can either hold down the right mouse button and trace out a rectangle around the source, then double click inside that rectangle to set it as a box. Alternatively, you can trace out a more generic shape to better enclose the irregular outline of the supernova remnant. To do that, right-click on the icon highlighted in green in the figure shown at right. Then trace out a shape by right-clicking where you want the corners of that shape. Once you have come full circle, the shape will be traced out in green, with small squares at the corners. Double-click inside this region and the green outline will turn white. You have now set your clean region. To toggle back to the rectangle tracer again, right-click on the icon circled in green in the figure at right. If you have made a mistake with your clean box, click on the "Erase" button, trace out a rectangle around your erroneous region, and double click inside that rectangle. You can also set multiple clean regions. By default, all clean regions will apply only to the plane shown. To change this to select all regions, click the "All Channels" button at the top. <br />
<br />
When you are happy with your clean regions, press the green circular arrow button on the far right to continue deconvolution. After completing a cycle, a revised image will come up. As the brightest points are removed from the image ("cleaned" off), fainter emission may show up. You can adjust the clean boxes each cycle, to enclose all real emission. After many cycles, once only noise is left, you can hit the red and white cross icon to stop cleaning.<br />
<br />
<br />
[[Image:3c391_ctm_i_image.jpg|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391 at 4600 MHz]]<br />
{{clean}} will make several output files, all named with the prefix given as ''imagename''. These include:<br />
* .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<br />
* .flux - the effective response of the telescope (the primary beam)<br />
* .flux.pbcoverage - the effective response of the full mosaic image<br />
* .mask - the areas where you have permitted imager to find clean components<br />
* .model - the sum of all the clean components, which has been stored as the model_data column in the measurement set<br />
* .psf - the dirty beam, which is being deconvolved from the true sky brightness during the clean process<br />
* .residual - what is left at the end of the deconvolution process; this is useful to diagnose whether or not to clean more deeply<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
<br />
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).<br />
<br />
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.<br />
<br />
The example above illustrates multi-scale CLEAN. Not all sources or fields will require multi-scale CLEAN; for reference, here is the same data set, but without multi-scale CLEANing.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_no_multiscale_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
== Next Steps ==<br />
<br />
There are a variety of additional analyses that could be done, including extracting the statistics of the images just produced, continuing with the polarization imaging, and self-calibration of the data. Examples of these topics are included in <br />
[[EVLA Advanced Topics 3C391]].<br />
<br />
If one is reading this as part of the Day 1 Summer School Tutorial, and there is time, one could consider beginning one of these advanced topics.</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=3680EVLA Continuum Tutorial 3C3912010-06-03T19:27:47Z<p>Jgallimo: /* Bandpass Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
<br />
== Overview ==<br />
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]]. As an alternative to the function calls as provided by the script extractor, all tasks may be run interactively by typing ''default taskname'' to load the task, ''inp'' to examine the inputs, and ''go'' once those inputs have been set to your satisfaction. Allowed inputs are shown in blue, and bad inputs are colored red. If you prefer this more interactive CASA experience, screenshots of the inputs to the different tasks used in the data reduction are provided, to illustrate which parameters need to be set. The attentive reader will see that all non-default inputs to the tasks correspond exactly to the parameters set in the function calls derived from the script extractor.<br />
<br />
Should you use the script generated by the [[Extracting_scripts_from_these_tutorials | script extractor]], be aware that it will require some small amount of interaction, occasionally suggesting that you close the graphics window and hitting return in the terminal to proceed. It is in fact unnecessary to close the graphics windows (it is suggested that you do so purely to keep your desktop uncluttered), and in one case (that of {{plotms}}), you '''must''' leave the graphics window open, as the GUI cannot be reopened without first exiting from CASA.<br />
<br />
== Obtaining the Data ==<br />
<br />
For the purposes of this tutorial, we have created a "starting" data set, upon which several initial processing steps have already been conducted. This data set may already be present on the machine that you are using; if not, obtain it from the<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz CASA data archive].<br />
<br />
We are providing this "starting" data set, rather than the "true" initial data set for (at least) two reasons. First, many of these initial processing steps can be rather time consuming (> 1 hr), and the time for the data reduction tutorial is limited. Second, while necessary, many of these steps are not fundamental to the calibration and imaging process, upon which we want to focus today. For completeness, however, here are the steps that were taken from the initial data set to produce the "starting" data set:<br />
* The data loaded into CASA, converting the initial Science Data Model (SDM) file into a measurement set.<br />
* Basic data flagging was applied, to account for "shadowing" of the antennas. These data are from the D configuration, in which antennas are particularly susceptible to being blocked or "shadowed" by other antennas in the array, depending upon the elevation of the source.<br />
* The data were averaged to 10-second samples, from the initial 1-second correlator sample time. In the D configuration, the fringe rate is relatively slow and time-average smearing is less of a concern.<br />
* The data were acquired with two spectral windows (around 4.6 and 7.5 GHz). Because of disk space concerns on some machines, the focus will be on only one of the two spectral windows.<br />
<br />
We emphasize that, were this a real science observation, all of these steps would need to be run. Detailed instructions on obtaining the data from the archive and creating this "starting" data set may be found in the [[Obtaining EVLA Data: 3C 391 Example]] tutorial.<br />
<br />
== Examining the Data ==<br />
<br />
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. From this, we find the following:<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Information from observing log:<br />
There is no C-band receivers on ea13<br />
Antenna ea06 is out of the array<br />
Antenna ea15 has some corrupted data<br />
Antennas ea10, ea12, ea22 do not have good baseline positions<br />
Gusty winds, mixed clouds, API rms up to 11.5.<br />
</pre><br />
<br />
Before beginning our data reduction, we must start CASA. If you have not used CASA before, some helpful tips are available on the [[Getting Started in CASA]] page.<br />
<br />
Once you have CASA up and running in the directory containing the data, then start your data reduction by getting some basic information about the data. The task {{listobs}} can be used to get a listing of the individual scans comprising the observation, the frequency setup, source list, and antenna locations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='3c391_ctm_mosaic_10s_spw0.ms',verbose=T)<br />
</source><br />
<br />
{{listobs}} should now produce output similar to the following in the casa logger. (Note that the listing shown is for both spectral windows.)<br />
<br />
<pre style="background-color: #ffe4b5;"><br />
INFO listobs::::casa ##########################################<br />
INFO listobs::::casa ##### Begin Task: listobs #####<br />
INFO listobs::::casa <br />
INFO listobs::ms::summary ================================================================================<br />
INFO listobs::ms::summary+ MeasurementSet Name: /export/home/hamal/jmiller/TDEM0001_sb1218006/3c391_mosaic_fullres.ms MS Version 2<br />
INFO listobs::ms::summary+ ================================================================================<br />
INFO listobs::ms::summary+ Observer: Dr. James Miller-Jones Project: T.B.D. <br />
INFO listobs::ms::summary+ Observation: EVLA<br />
INFO listobs::ms::summary Data records: 18666050 Total integration time = 28716 seconds<br />
INFO listobs::ms::summary+ Observed from 24-Apr-2010/08:01:34.5 to 24-Apr-2010/16:00:10.5 (UTC)<br />
INFO listobs::ms::summary <br />
INFO listobs::ms::summary+ ObservationID = 0 ArrayID = 0<br />
INFO listobs::ms::summary+ Date Timerange (UTC) Scan FldId FieldName nVis Int(s) SpwIds<br />
INFO listobs::ms::summary+ 24-Apr-2010/08:01:34.5 - 08:02:28.5 1 0 J1331+3030 35750 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:02:29.5 - 08:09:27.5 2 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:09:28.5 - 08:16:26.5 3 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:16:27.5 - 08:24:25.5 4 1 J1822-0938 311350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:24:26.5 - 08:29:44.5 5 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:29:45.5 - 08:34:43.5 6 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:34:44.5 - 08:39:42.5 7 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:39:43.5 - 08:44:41.5 8 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:44:42.5 - 08:49:40.5 9 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:49:41.5 - 08:54:40.5 10 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:54:41.5 - 08:59:39.5 11 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:59:40.5 - 09:01:29.5 12 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:01:30.5 - 09:06:48.5 13 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:06:49.5 - 09:11:47.5 14 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:11:48.5 - 09:16:46.5 15 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:16:47.5 - 09:21:45.5 16 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:21:46.5 - 09:26:44.5 17 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:26:45.5 - 09:31:44.5 18 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:31:45.5 - 09:36:43.5 19 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:36:44.5 - 09:38:32.5 20 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:38:33.5 - 09:43:52.5 21 2 3C391 C1 208000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:43:53.5 - 09:48:51.5 22 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:48:52.5 - 09:53:50.5 23 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:53:51.5 - 09:58:49.5 24 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:58:50.5 - 10:03:48.5 25 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:03:49.5 - 10:08:47.5 26 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:08:48.5 - 10:13:47.5 27 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:13:48.5 - 10:15:36.5 28 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:15:37.5 - 10:20:55.5 29 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:20:56.5 - 10:25:55.5 30 3 3C391 C2 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:25:56.5 - 10:30:54.5 31 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:30:55.5 - 10:35:53.5 32 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:35:54.5 - 10:40:52.5 33 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:40:53.5 - 10:45:51.5 34 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:45:52.5 - 10:50:51.5 35 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:50:52.5 - 10:52:40.5 36 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:52:41.5 - 10:57:39.5 37 0 J1331+3030 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:57:40.5 - 11:02:39.5 38 1 J1822-0938 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:02:40.5 - 11:07:58.5 39 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:07:59.5 - 11:12:47.5 40 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:12:48.5 - 11:17:36.5 41 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:17:37.5 - 11:22:25.5 42 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:22:26.5 - 11:27:15.5 43 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:27:16.5 - 11:32:04.5 44 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:32:05.5 - 11:36:53.5 45 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:36:54.5 - 11:38:43.5 46 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:38:44.5 - 11:44:02.5 47 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:44:03.5 - 11:48:51.5 48 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:48:52.5 - 11:53:40.5 49 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:53:41.5 - 11:58:29.5 50 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:58:30.5 - 12:03:19.5 51 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:03:20.5 - 12:08:08.5 52 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:08:09.5 - 12:12:57.5 53 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:12:58.5 - 12:14:47.5 54 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:14:48.5 - 12:20:06.5 55 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:20:07.5 - 12:24:55.5 56 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:24:56.5 - 12:29:44.5 57 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:29:45.5 - 12:34:34.5 58 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:34:35.5 - 12:39:23.5 59 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:39:24.5 - 12:44:12.5 60 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:44:13.5 - 12:49:01.5 61 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:49:02.5 - 12:50:51.5 62 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:50:52.5 - 12:56:10.5 63 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:56:11.5 - 13:00:59.5 64 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:01:00.5 - 13:05:48.5 65 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:05:49.5 - 13:10:38.5 66 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:10:39.5 - 13:15:27.5 67 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:15:28.5 - 13:20:16.5 68 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:20:17.5 - 13:25:05.5 69 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:25:06.5 - 13:26:55.5 70 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:26:56.5 - 13:32:14.5 71 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:32:15.5 - 13:37:03.5 72 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:37:04.5 - 13:41:52.5 73 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:41:53.5 - 13:46:42.5 74 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:46:43.5 - 13:51:31.5 75 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:51:32.5 - 13:56:20.5 76 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:56:21.5 - 14:01:09.5 77 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:01:10.5 - 14:02:59.5 78 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:03:00.5 - 14:08:18.5 79 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:08:19.5 - 14:13:07.5 80 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:13:08.5 - 14:17:57.5 81 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:17:58.5 - 14:22:46.5 82 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:22:47.5 - 14:27:35.5 83 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:27:36.5 - 14:32:24.5 84 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:32:25.5 - 14:37:13.5 85 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:37:14.5 - 14:39:03.5 86 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:39:04.5 - 14:44:22.5 87 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:44:23.5 - 14:49:11.5 88 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:49:12.5 - 14:54:01.5 89 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:54:02.5 - 14:58:50.5 90 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:58:51.5 - 15:03:39.5 91 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:03:40.5 - 15:08:28.5 92 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:08:29.5 - 15:13:17.5 93 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:13:18.5 - 15:15:07.5 94 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:15:08.5 - 15:20:26.5 95 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:20:27.5 - 15:25:15.5 96 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:25:16.5 - 15:30:05.5 97 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:30:06.5 - 15:34:54.5 98 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:34:55.5 - 15:39:43.5 99 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:39:44.5 - 15:44:32.5 100 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:44:33.5 - 15:49:22.5 101 8 3C391 C7 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:49:23.5 - 15:51:11.5 102 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:51:12.5 - 16:00:10.5 103 9 J0319+4130 350350 1 [0, 1]<br />
INFO listobs::ms::summary (nVis = Total number of time/baseline visibilities per scan) <br />
INFO listobs::ms::summary Fields: 10<br />
INFO listobs::ms::summary+ ID Code Name RA Decl Epoch SrcId nVis <br />
INFO listobs::ms::summary+ 0 N J1331+3030 13:31:08.2880 +30.30.32.9589 J2000 0 774800 <br />
INFO listobs::ms::summary+ 1 J J1822-0938 18:22:28.7042 -09.38.56.8350 J2000 1 1361750<br />
INFO listobs::ms::summary+ 2 NONE 3C391 C1 18:49:24.2440 -00.55.40.5800 J2000 2 2488850<br />
INFO listobs::ms::summary+ 3 NONE 3C391 C2 18:49:29.1490 -00.57.48.0000 J2000 3 2280850<br />
INFO listobs::ms::summary+ 4 NONE 3C391 C3 18:49:19.3390 -00.57.48.0000 J2000 4 2282150<br />
INFO listobs::ms::summary+ 5 NONE 3C391 C4 18:49:14.4340 -00.55.40.5800 J2000 5 2282150<br />
INFO listobs::ms::summary+ 6 NONE 3C391 C5 18:49:19.3390 -00.53.33.1600 J2000 6 2281500<br />
INFO listobs::ms::summary+ 7 NONE 3C391 C6 18:49:29.1490 -00.53.33.1600 J2000 7 2281500<br />
INFO listobs::ms::summary+ 8 NONE 3C391 C7 18:49:34.0540 -00.55.40.5800 J2000 8 2282150<br />
INFO listobs::ms::summary+ 9 Z J0319+4130 03:19:48.1601 +41.30.42.1030 J2000 9 350350 <br />
INFO listobs::ms::summary+ (nVis = Total number of time/baseline visibilities per field) <br />
INFO listobs::ms::summary Spectral Windows: (2 unique spectral windows and 1 unique polarization setups)<br />
INFO listobs::ms::summary+ SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
INFO listobs::ms::summary+ 0 64 TOPO 4536 2000 128000 4536 RR RL LR LL <br />
INFO listobs::ms::summary+ 1 64 TOPO 7436 2000 128000 7436 RR RL LR LL <br />
INFO listobs::ms::summary Sources: 20<br />
INFO listobs::ms::summary+ ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
INFO listobs::ms::summary+ 0 J1331+3030 0 - - <br />
INFO listobs::ms::summary+ 0 J1331+3030 1 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 0 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 1 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 0 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 1 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 0 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 1 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 0 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 1 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 0 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 1 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 0 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 1 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 0 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 1 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 0 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 1 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 0 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 1 - - <br />
INFO listobs::ms::summary Antennas: 26:<br />
INFO listobs::ms::summary+ ID Name Station Diam. Long. Lat. <br />
INFO listobs::ms::summary+ 0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
INFO listobs::ms::summary+ 1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
INFO listobs::ms::summary+ 2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
INFO listobs::ms::summary+ 3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
INFO listobs::ms::summary+ 4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
INFO listobs::ms::summary+ 5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
INFO listobs::ms::summary+ 6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
INFO listobs::ms::summary+ 7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
INFO listobs::ms::summary+ 8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
INFO listobs::ms::summary+ 9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
INFO listobs::ms::summary+ 10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
INFO listobs::ms::summary+ 11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
INFO listobs::ms::summary+ 12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
INFO listobs::ms::summary+ 13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
INFO listobs::ms::summary+ 14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
INFO listobs::ms::summary+ 15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
INFO listobs::ms::summary+ 16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
INFO listobs::ms::summary+ 17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
INFO listobs::ms::summary+ 18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
INFO listobs::ms::summary+ 19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
INFO listobs::ms::summary+ 20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
INFO listobs::ms::summary+ 21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
INFO listobs::ms::summary+ 22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
INFO listobs::ms::summary+ 23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
INFO listobs::ms::summary+ 24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
INFO listobs::ms::summary+ 25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
INFO listobs::::casa <br />
INFO listobs::::casa ##### End Task: listobs #####<br />
INFO listobs::::casa ##########################################<br />
</pre><br />
<br />
Note that the antenna IDs (which are numbered sequentially up to the total number of antennas in the array; 0 through 25 in this instance) do not correspond to the actual antenna names (ea01 through ea28; these numbers correspond to those painted on the side of the dishes). During our data reduction, we can refer to the antennas using either convention; ''antenna='22' '' would correspond to ea25, whereas ''antenna='ea22' '' would correspond to ea22. Note that the antenna numbers in the observer log correspond to the actual antenna names, i.e. the 'ea??' numbers given in listobs.<br />
<br />
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!). <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotants(vis='3c391_ctm_mosaic_10s_spw0.ms',figfile='3c391_ctm_mosaic_antenna_layout.png')<br />
clearstat() # This removes the table lock generated by plotants in script mode<br />
</source><br />
<br />
[[Image:3c391_ctm_plotants_parameters.jpg|200px|thumb|left|plotants parameters]]<br />
[[Image:3C391_mosaic-plotants.png|200px|thumb|center|plotants figure]]<br />
<br />
== Examining and Editing the Data ==<br />
<br />
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.<br />
<br />
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 less than 1 minute long.) This first scan can safely be deleted.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,scan='1')<br />
</source><br />
<br />
[[Image:3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
* <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.)<br />
* <strong>mode='manualflag'</strong> : Specific data are going to be selected to be edited. <br />
* <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 ''help 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.)<br />
<br />
If satisfied with the inputs, run this task. The initial display in the logger will include <br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: flagdata #####<br />
flagdata::::casa<br />
attached MS [...]<br />
Saving current flags to manualflag_1 before applying new flags<br />
Creating new backup flag file called manualflag_1<br />
</pre><br />
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_1. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used.<br />
<br />
<br />
<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea13,ea15')<br />
</source><br />
* antenna='ea13' : Once again, this parameter requires a string input. Remember that antenna='ea13' and 'antenna='13' are <em>not</em> the same antenna. (See the discussion after our call to {{listobs}} above.)<br />
<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',mode='quack',quackinterval=10.0,quackmode='beg')<br />
</source><br />
* mode='quack' : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* 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.<br />
* 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.<br />
<br />
<br />
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}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat() # This removes any existing table locks generated by flagdata<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',xaxis='',yaxis='',averagedata=False,transform=False,extendflag=False,<br />
plotfile='',selectdata=True,field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* xaxis=' ', yaxis=' ' : One can choose the axes of the plot, i.e., the way of visualizing the data, by using the GUI display once the task is executed.<br />
* averagedata=F : It is possible to average the data in time, frequency, etc. <br />
* transform=F : It is possible to change the velocity reference frame of the data.<br />
* 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.<br />
* plotfile=' ' : It is possible to produce a hard copy (e.g., for a paper, report, or Web site) by specifying a file.<br />
* selectdata=T : One can choose to plot only subsets of the data.<br />
* field='0': The entire dataset is rather large, and different sources have very different amplitudes, so it is advisable to start by loading a subset of the data. One can later loop through the different fields (i.e. sources) and spectral windows using the GUI interface.<br />
<br />
In this case, many other 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.<br />
<br />
{{plotms}} should produce a GUI, with the default view being to show the visibility amplitude as a function of time. The figure at right shows the result of running {{plotms}} without the field selection (''field='0' '') discussed above.<br />
[[Image:plotms-default.png|200px|right|thumb|plotms default GUI view, having loaded all fields at once]]<br />
{{plotms}} allows one to select and view the data in many ways. Across the top of the left 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.<br />
<br />
In the default view, the 'Plots' tab is visible, and there are a number of tabs running down the side of the left 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.<br />
<br />
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 (baseline length, in meters), 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., <math>\sqrt{u^2+v^2}</math>). 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.) <br />
<br />
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]. To plot baseline length in wavelengths rather than meters, one needs to select ''UVDist_L'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view of 3C 391]]<br />
<br />
<br />
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.<br />
<br />
'''Do not''' close the plotms GUI after running {{plotms}}, or you will need to exit casapy and restart if at any point you wish to run plotms again, otherwise the GUI will not come up a second time.<br />
<br />
== Calibrating the Data ==<br />
<br />
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. <br />
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.<br />
<br />
Recall that the observed visibility <math>V^{\prime}</math> between two antennas <math>(i,j)</math> is related to the "true" visibility <math>V</math> by <br />
<br />
<math><br />
V^{\prime}_{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)\,e^{i [\theta_i(t) - \theta_j(t)]} <br />
</math><br />
<br />
Here, for generality, we show the visibility as a function of frequency <math>f</math> and spatial wavenumbers <math>u</math> and <math>v</math>. The other terms are <br />
* <math>g_i</math> and <math>\theta_i</math> 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 <math>t</math> to indicate that they can change with temperature, atmospheric conditions, etc.<br />
* <math>B_i</math> is the complex bandpass, the instrumental response as a function of frequency, <math>f</math>. As shown here, the bandpass may also vary as a function of time.<br />
* <math>b(t)</math> 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. <br />
Strictly, the equation above is a simplification of a more general measurement equation formalism, but it is a useful simplification in many cases.<br />
<br />
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., a priori models for the calibrators, and those derived 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. If you have started with the 10s-averaged dataset suggested at the top of this tutorial, this step has already been done for you, so may be omitted.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',spw='')<br />
</source><br />
<br />
All parameters are set to blank so that the initialization occurs for all sources and spectral windows.<br />
<br />
<br />
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 <math>g_i</math> values.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',<br />
modimage='/home/casa/data/nrao/VLA/CalModels/3C286_C.im',standard='Perley-Taylor 99',<br />
fluxdensity=-1)<br />
</source><br />
<br />
[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]<br />
* 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.<br />
* 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.<br />
* 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.<br />
* fluxdensity=-1 : It is possible to specify (i.e., force) the flux density of the source to be a particular value. Setting ''fluxdensity = -1'' (as done here) asks {{setjy}} to calculate the value based on a set of standard models if the source is one of the standard flux calibrators (i.e. 3C 286, 3C 48, or 3C 147).<br />
* spw='0' : The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw, but it will not hurt to do so. Had the spectral window 0 not been split off, as has been done here, we might wish to specify the spectral window because, in this observation, the spectral windows were sufficiently separated that two different model images for 3C 286 would be appropriate; 3C286_C.im at 4.6 GHz and 3C286_X.im at 7.5 GHz. This would require two separate runs of {{setjy}}, one for each spectral window. If the spectral windows were much closer together, it might be possible to calibrate both using the same model.<br />
<br />
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.<br />
<br />
The output from {{setjy}} should look similar to the following.<br />
<pre style="background-color: #ffe4b5;"><br />
INFO taskmanager::::casa ##### async task launch: setjy ########################<br />
INFO setjy::imager::setjy() J1331+3030 spwid= 0 [I=7.747, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
INFO setjy::imager::setjy() Using model image /home/casa/data/nrao/VLA/CalModels/3C286_C.im<br />
INFO setjy::imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
INFO setjy::imager::setjy() Scaling model image to I=7.74664 Jy for visibility prediction.<br />
INFO setjy::imager::data selection Selecting data<br />
</pre><br />
As set, the flux density scale is being set only for spectral window 0 (''spw='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. <br />
<br />
<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass.png|200px|thumb|right|bandpass illustration]]<br />
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 right. 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 as well. The variations with frequency are a reflection of the (slightly) different antenna bandpasses. (<em>Exercise for the reader, reproduce this plot using {{plotms}}.</em>)<br />
<br />
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. While amplitude variations will have little effect on the bandpass solutions, it is important to solve for any phase variations with time to prevent decorrelation when vector averaging the data in computing the bandpass solutions.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal0',field='J1331+3030',<br />
refant='ea21',spw='0:27~36',calmode='p',solint='int',minsnr=5,solnorm=T)<br />
</source><br />
<br />
[[Image:3C391_gaincal0.png|200px|thumb|right|gaincal inputs for first gain solutions]]<br />
* caltable='3c391_ctm_mosaic.gcal0' : The gain solutions will be stored in an external table.<br />
* 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.<br />
* 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.<br />
* spw='0: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. Also note that, even though these data have only a single spectral window, the syntax requires specifying the spectral window in order to specify the spectral channels.<br />
* calmode='p' : Solve for only the phase portion of the gain.<br />
* 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)<br />
* 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.<br />
* solnorm=T : Strictly, for a phase-only solution, the amplitudes should be normalized by zero. This setting enforces that.<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-R.png')<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='L',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-L.png')<br />
</source><br />
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.<br />
[[Image:plotcal-3C286-G0-phase-R.png|200px|thumb|left|gain phases for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-phase-L.png|200px|thumb|center|gain phases for 3C 286, L polarization]]<br />
<br />
<br />
Alternatively, one can choose to inspect solutions for a single antenna at a time, stepping through each antenna in sequence:<br />
<source lang="python"><br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',iteration='antenna',plotrange=[-1,-1,-180,180],timerange='08:02:00~08:17:00')<br />
</source><br />
Antennas which have been flagged will show a blank plot, since there are no solutions for these antennas. Note the phase jump on antenna ea05. You may wish to flag this antenna:<br />
<source lang="python"><br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea05',field='J1331+3030',timerange='08:02:00~08:17:00')<br />
</source><br />
<br />
Now form the bandpass itself, using the phase solutions just derived.<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='3c391_ctm_mosaic_10s_spw0.ms',gaintable='3c391_ctm_mosaic.gcal0',caltable='3c391_ctm_mosaic.bcal0',<br />
field='J1331+3030',spw='',refant='ea21',solnorm=True,combine='scan',solint='inf',bandtype='B')<br />
</source><br />
<br />
[[Image:3C391_bandpass.png|200px|thumb|right|bandpass inputs]]<br />
* 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.<br />
* caltable='3c391_ctm_mosaic.bcal0' : Specify where to store the bandpass corrections.<br />
* solnorm=T : Make sure that the amplitudes of the bandpass corrections are normalized to unity.<br />
* 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.<br />
* 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.<br />
<br />
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. We use ''iteration='antenna' '' to step through separate plots for each antenna.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='R',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-R.png')<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='L',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-L.png')<br />
</source><br />
<br />
[[Image:plotcal-3C286-G0-bandpass-R.png|200px|thumb|left|bandpass for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-bandpass-L.png|200px|thumb|center|bandpass for 3C 286, L polarization]]<br />
<br />
=== Gain Calibration ===<br />
<br />
The next step is to derive corrections for the complex antenna gains, <math>g_i</math> and <math>\theta_i</math>. As discussed in the lectures and above, the absolute magnitude of the gain amplitudes <math>g_i</math> are determined by reference to a standard flux density calibrator. In order to determine the appropriate complex gains for the target source, one wants to observe a so-called phase calibrator that is much closer to the target, in order to minimize differences through the atmosphere (neutral and/or ionized) between the lines of sight to the phase calibrator and the target source. If we determine the relative gain amplitudes and phases for different antennas using the phase calibrator, we can later determine the absolute flux density scale by comparing the gain amplitudes <math>g_i</math> derived for 3C 286 with those derived for the phase calibrator. This will eventually be done using the task {{fluxscale}}. Since there is no such thing as absolute phase, we determine a zero phase by selecting a reference antenna for which the gain phase is defined to be zero.<br />
<br />
In principle, one could determine the complex antenna gains for all sources with a single invocation of {{gaincal}}; for clarity here, two separate invocations will be used.<br />
<br />
In the first step, we derive the appropriate complex gains <math>g_i</math> and <math>\theta_i</math> for the flux density calibrator 3C 286.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1331+3030',spw='0:5~58',<br />
refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',solint='inf')<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' : Produce a new calibration table containing these gain solutions. In order to make the bookkeeping easier, a '1' is appended to the file name to distinguish it from the earlier set of gain solutions, which are effectively being "thrown away."<br />
* spw='0:5~58' : From the inspection of the bandpass, one can determine the range of edge channels that are affected by the bandpass filter rolloff. Because the amplitude is dropping rapidly in these channels, one does not want to include them in the solution.<br />
* gaintype='G' and calmode='ap' : Solve for the complex antenna gains for 3C 286.<br />
* solint='inf' : Produce a solution for each scan.<br />
* gaintable='3c391_ctm_mosaic.bcal0' : Use the bandpass solutions determined earlier to correct for the bandpass shape before solving for the gain amplitudes.<br />
After reviewing the inputs to {{gaincal}} and running it, one could use {{plotcal}} to plot the solutions. While a useful sanity check, the plots themselves will be rather sparse as only a single gain amplitude is being determined for each antenna for each scan.<br />
<br />
<br />
In the second step, the appropriate complex gains for a direction on the sky close to the target source will be determined from the phase calibrator J1822-0938. We also determine the complex gains for the polarization calibrator source J0319+4130.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1822-0938,J0319+4130',<br />
spw='0:5~58',refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',<br />
solint='inf',append=True)<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' and append=True : In all previous invocations of {{gaincal}}, append has been set to False. Here, the gain solutions from the phase calibrators are going to be appended to the existing set from 3C 286. In following steps, all of these gain solutions will then be used together to derive a set of complex gains that are applied to the science data for the target source.<br />
If one checks the gain phase solutions using {{plotcal}}, one should see several solutions for each antenna as a function of time. In order to track the phases, the phase calibrator is typically observed much more frequently during the course of an observation than is the flux density calibrator. In the examples shown below, note that one of the panels is blank, which corresponds to antenna 13, the one flagged earlier in the process.<br />
<br />
[[Image:plotcal-J1822-0398-phase-R.png|200px|thumb|left|gain phase solutions for J1822-0398, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0398, L polarization]]<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Applying_the_calibration Applying the Calibration]].]</strong><br />
<br />
Having set the complex gains, we now 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).<br />
<br />
Our initial run of {{setjy}} only set the total intensity of our flux calibrator source, 3C 286. This source is known to have a fairly stable fractional polarization of 11.2% at C-band, and a polarization position angle of 66 degrees. NRAO conducted regular monitoring of a number of polarization calibrators (including 3C 286) from 1999 through 2009. If you go to the [http://www.vla.nrao.edu/astro/calib/polar/ polarization calibration webpage] and follow the link for a particular year, then search for '1331+305 C band' (1331+305 is better known as 3C 286), you will see in the table the measured values for the percentage polarization and polarization position angle.<br />
<br />
In order to calibrate the position angle, we need to set the appropriate values for Stokes Q and U. Examining our casapy.log file to find the output of {{setjy}}, we find that the total intensity was set to 7.74664 Jy in spw0. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U.<br />
<br />
<source lang="python"><br />
# In CASA<br />
i0=7.74664 # Stokes I value for spw 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0<br />
</source><br />
<br />
We now set the values of Stokes Q and U for 3C 286, using {{setjy}} as we did before.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',modimage='',spw='0',fluxdensity=[i0,q0,u0,0])<br />
</source><br />
* modimage=' ' : A model image is not used here.<br />
<br />
Note that the Stokes V flux value is set to zero, corresponding to no circular polarization.<br />
<br />
==== Solving for the Leakage Terms ====<br />
<br />
The task we will use to do all the polarization calibration is {{polcal}}. In this data set, we observed the unpolarized calibrator J0319+4130 (a.k.a. 3C 84) in order to solve for the instrumental polarization. {{polcal}} uses the Stokes IQU values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The final function call is:<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.pcal0',field='J0319+4130',<br />
spw='',refant=refant,poltype='Df',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'],<br />
gainfield=['J0319+4130', 'J1331+3030'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* caltable='3c391_ctm_mosaic.pcal0' : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the ''caltable'' argument.<br />
* field='J0319+4130' : We use the unpolarized source J0319+4130 (a.k.a. 3C 84) to solve for the leakages.<br />
* poltype='Df' : We will solve for the leakages (''D'') on a per-channel basis (''f''). Had we have 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' '').<br />
* gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'] : We apply our existing gain and bandpass tables on-the-fly by specifying them in a Python list.<br />
* gainfield=['J0319+4130','J1331+3030'] : Use only the specified sources from 3c391_ctm_mosaic.gcal1 and 3c391_ctm_mosaic.bcal0, respectively, when applying these previous gain and bandpass corrections.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.pcal0',xaxis='chan',yaxis='amp',spw='',field='',iteration='antenna')<br />
</source><br />
<br />
<br />
[[Image:3c391_ctm_plotcal_Df_solutions.jpg|thumb|{{plotcal}} GUI showing the Df solutions from {{polcal}} ]]<br />
This will produce plots similar to that shown at right.<br />
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.<br />
<br />
==== Solving for the R-L polarization angle ====<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.xcal0',poltype='Xf',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0', '3c391_ctm_mosaic.pcal0'],<br />
field='J1331+3030',refant='ea21')<br />
</source><br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.xcal0',xaxis='chan',yaxis='phase',iteration='antenna')<br />
</source><br />
<br />
[[Image:3c391_ctm_plotcal_Xf_solutions.jpg|thumb|{{plotcal}} GUI showing Xf solutions from {{polcal}} ]]<br />
<br />
At this point, your dataset contains all the necessary polarization calibration, which will shortly be applied to the data.<br />
<br />
== Applying the Calibration ==<br />
<br />
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 ''u''-''v'' 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.<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',fluxtable='3c391_ctm_mosaic.fluxscale1',<br />
reference='J1331+3030',transfer='J1822-0938,J0319+4130',append=True)<br />
</source><br />
<br />
[[Image:3C391_fluxscale.png|200px|thumb|right|fluxscale inputs]]<br />
* caltable='3c391_ctm_mosaic.gcal1' : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier<br />
* fluxtable='3c391_ctm_mosaic.fluxscale1' : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains. <br />
* reference='J1331+3030' : We specify the source with the known flux density.<br />
* transfer='J1822-0938,J0319+4130' : We specify the sources whose amplitude gains are to be rescaled.<br />
<br />
{{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. If one's data set has more than 1 spectral window, depending upon where they are spaced and the spectrum of the source, it is quite possible to find (quite) different flux densities at the different frequencies for the secondary calibrators. Example output for this data set would be<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO fluxscale::::casa ##########################################<br />
INFO fluxscale::::casa ##### Begin Task: fluxscale #####<br />
INFO fluxscale::::casa<br />
INFO fluxscale::calibrater::open Opening MS: 3c391_mosaic_10s.ms for calibration.<br />
INFO fluxscale::Calibrater:: Initializing nominal selection to the whole MS.<br />
INFO fluxscale::calibrater::fluxscale Beginning fluxscale--(MSSelection version)-------<br />
INFO fluxscale:::: Found reference field(s): J1331+3030<br />
INFO fluxscale:::: Found transfer field(s): J1822-0938 J0319+4130<br />
INFO fluxscale:::: Flux density for J1822-0938 in SpW=0 is: 2.32824 +/- 0.00706023 (SNR = 329.768, nAnt= 25)<br />
INFO fluxscale:::: Flux density for J0319+4130 in SpW=0 is: 13.7643 +/- 0.0348429 (SNR = 395.04, nAnt= 25)<br />
INFO fluxscale::Calibrater::fluxscale Appending result to 3c391_mosaic.fluxscale1<br />
INFO fluxscale:::: Appending solutions to table: 3c391_mosaic.fluxscale1<br />
INFO fluxscale::::casa<br />
INFO fluxscale::::casa ##### End Task: fluxscale #####<br />
</pre><br />
<br />
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 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.<br />
<br />
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.<br />
<br />
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). The relevant function calls are given below, although as explained presently, the calls to {{applycal}} will differ slightly if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1331+3030',gainfield=['J1331+3030','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J0319+4130',gainfield=['J0319+4130','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1822-0938',gainfield=['J1822-0938','','',''],interp=['nearest','','',''])<br />
</source><br />
<br />
* gaintable : We provide a Python list of the calibration tables to be applied. 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.<br />
* gainfield, interp : 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''.<br />
* parang : Since we have performed polarization calibration, we '''must''' set ''parang=True'', or we will discard all that hard work we did earlier. However, if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization_Calibration]] section, the tables 3c391_ctm_mosaic.pcal0 and 3c391_ctm_mosaic.xcal0 will not exist. In this case, you should leave out the final two tables in the ''gaintable'' list, and the final two sets of empty elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. 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.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
gainfield=['J1822-0938','','',''],<br />
interp=['linear','','',''],<br />
parang=True)<br />
</source><br />
<br />
[[Image:3C391_applycal.png|200px|thumb|right|applycal inputs]]<br />
* field : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* gainfield : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* interp : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
[[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]]<br />
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, for one of the parallel-hand correlations (RR or LL; the signal in the cross-hands, RL and LR is much smaller, and will be noiselike for an unpolarized calibrator). This should then 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.<br />
<br />
Inspecting the data at this stage may well show up previously-unnoticed bad data. Plotting up the '''corrected''' amplitude against UV distance, or against time is a good way to find such issues. If you find bad data, you can remove them via interactive flagging in {{plotms}}, or via manual flagging in {{flagdata}} once you have identified the offending antennas/baselines/channels/times. When you are happy that all data (particularly on your target source) look good, you may proceed.<br />
<br />
Now that the calibration has been applied to the target data, we can split off the science targets, creating a new, calibrated measurement set containing all the target fields.<br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='3c391_ctm_mosaic_10s_spw0.ms',outputvis='3c391_ctm_mosaic_spw0.ms',<br />
datacolumn='corrected',field='2~8')<br />
</source><br />
<br />
* outputvis : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* datacolumn : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* field : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Imaging ==<br />
<br />
Now that we have split off the target data into a separate measurement set with all the calibration applied, it's time to make an image. Recall from the lectures that the visibility data and the sky brightness distribution (a.k.a. image) are Fourier transform pairs<br />
<br />
<math><br />
I(l,m) = \int V(u,v) e^{[2\pi i(ul + vm)]} dudv<br />
</math><br />
<br />
The <math>u</math> and <math>v</math> coordinates are the baselines, measured in units of the observing wavelength while the <math>l</math> and <math>m</math> coordinates are the direction cosines on the sky. For generality, the sky coordinates are written in terms of direction cosines, but for most EVLA (and ALMA) observations they can be related simply to the right ascension (<math>l</math>) and declination (<math>m</math>). Also recall from the lectures that this equation is valid only if the <math>w</math> coordinate of the baselines can be neglected. This assumption is almost always true at high frequencies and smaller EVLA configurations (such as the 4.6 GHz, D-configuration observations here); the <math>w</math> coordinate cannot be neglected at lower frequencies and larger configurations (e.g., 0.33 GHz, A-configuration observations). This expression also neglects other factors, such as the shape of the primary beam. For more information on imaging, see [[http://casa.nrao.edu/docs/userman/UserManch5.html#x236-2330005 Synthesis Imaging]] within the CASA Reference Manual.<br />
<br />
<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image.<br />
Assuming you did the polarization calibration earlier, a command line call to image and deconvolve the dataset would be:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54], smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
If you previously skipped the polarization calibration, you should instead set ''stokes='I' '' and ''psfmode='clark' ''.<br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* mode='mfs' : Use multi-frequency synthesis imaging. The fractional bandwidth of these data is non-zero (128 MHz at a central frequency of 4.6 GHz). Recall that the u and v coordinates are defined as the baseline coordinates, measured in wavelengths. Thus, slight changes in the frequency from channel to channel result in slight changes in u and v. There is a concomitant improvement in u-v coverage if the visibility data from the multiple spectral channels are gridded separately onto the u-v plane, as opposed to treating all spectral channels as having the same frequency.<br />
* niter=5000,gain=0.1,threshold='1.0mJy' : Recall that the CLEAN gain is the amount by which a CLEAN component is subtracted during the CLEANing process. niter and threshold are (coupled) means of determining when to stop the CLEANing process, with niter specifying to find and subtract that many CLEAN components while threshold specifies a minimum flux density threshold a CLEAN component can have before CLEAN stops. See also interactive below. Imaging is an iterative process, and to set the threshold and number of iterations, it is usually wise to CLEAN interactively in the first instance, stopping when spurious emission from sidelobes (arising from gain errors) dominates the residual emission in the field. Here, we have used our experience in interactive mode to set a threshold level based on the rms noise in the resulting image. The number of iterations should then be set high enough to reach this threshold.<br />
* interactive=T : Very often, particularly when one is exploring how a source appears for the first time, it can be valuable to interact with the CLEANing process. If True, interactive causes a {{viewer}} window to appear. One can then set CLEAN regions, restricting where CLEAN searches for CLEAN components, as well as monitor the CLEANing process. A standard procedure is to set a large value for niter, and stop the CLEANing when it visually appears to be approaching the noise level. This procedure also allows one to change the CLEANing region, in cases when low-level intensity becomes visible as the CLEANing process proceeds. For more details, see [[http://casa.nrao.edu/docs/userman/UserMansu254.html#x292-2870005.3.14 Interactive Cleaning]], and also the discussion below.<br />
* imsize=[576,576], cell=['2.5arcsec','2.5arcsec'] : See the discussion below regarding the setting of the image size and cell size.<br />
* stokes='IQUV' and psfmode='clarkstokes' : Separate images will be made in all four polarizations (total intensity I, linear polarizations Q and U, and circular polarization V), and, with psfmode='clarkstokes', the Clark CLEAN algorithm will deconvolve each Stokes plane separately thereby making the polarization image more independent of the total intensity.<br />
* weighting='briggs',robust=0.0 : 3C 391 has diffuse, extended emission that is (at least partially) 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, Briggs weighting is used (intermediate between natural and uniform weighting), with a default robust factor of 0.<br />
* imagermode='mosaic', ftmachine='mosaic' : The data consist of a 7-pointing mosaic, since the supernova remnant fills almost the full primary beam at 4.6 GHz. A mosaic combines the data from all of the fields, with imaging and deconvolution being done jointly on all 7 fields. A mosaic both helps compensate for the shape of the primary beam and reduces the amount of large (angular) scale structure that is resolved out by the interferometer.<br />
* multiscale=[0, 6, 18, 54], smallscalebias=0.9 : A multi-scale CLEANing algorithm is used because the supernova remnant contains both diffuse, extended structure on large spatial scales and finer filamentary structure on smaller scales. The settings for multiscale are in units of pixels, with 0 pixels equivalent to the traditional delta-function CLEAN. The scales here are chosen to provide delta functions and then three logarithmically scaled sizes to fit to the data. The first scale (6 pixels) is chosen to be comparable to the size of the beam. The smallscalebias attempts to balance the weight given to larger scales, which often have more flux density, and the smaller scales, which often are brighter. Considerable experimentation is likely to be necessary; one of the authors of this document found that it was useful to CLEAN several rounds with this setting, change multiscale to be multiscale=[] and remove much of the smaller scale structure, then return to this setting.<br />
<br />
<br />
<br />
We need to select the appropriate pixel size to use. Using plotms to look at the newly-calibrated, target-only data set:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_spw0.ms',xaxis='uvdist_l',yaxis='amp')<br />
</source><br />
we select the axes tab on the left hand side, and select UVDist_L as the x-axis. <br />
[[Image:3c391 ctm spw0 uvplt.jpg|thumb|{{plotms}} GUI showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
This gives the plot shown at right.<br />
<br />
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.5 arcseconds in both co-ordinates by setting ''cell=['2.5arcsec','2.5arcsec']''. The supernova remnant is known to have a diameter of order 9 arcmin, which corresponds to about 216 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\times216</math>. We therefore set ''imsize=[576,576]''.<br />
<br />
[[Image:3C391 interactive clean.png|thumb|Example of interactive cleaning]]<br />
As mentioned above, we can guide the clean process by allowing it to find clean components only within a user-specified region. The easiest way to do this is via interactive clean. When {{clean}} runs in interactive mode, a viewer window will pop up as shown right. To get a more detailed view of the central regions containing the emission, zoom in by tracing out a rectangle with your left mouse button and double-clicking inside the zoom box you just made. Play with the color scale to bring out the emission better, by holding down the middle mouse button and moving it around. To create a clean box (a region within which components may be found), you can either hold down the right mouse button and trace out a rectangle around the source, then double click inside that rectangle to set it as a box. Alternatively, you can trace out a more generic shape to better enclose the irregular outline of the supernova remnant. To do that, right-click on the icon highlighted in green in the figure shown at right. Then trace out a shape by right-clicking where you want the corners of that shape. Once you have come full circle, the shape will be traced out in green, with small squares at the corners. Double-click inside this region and the green outline will turn white. You have now set your clean region. To toggle back to the rectangle tracer again, right-click on the icon circled in green in the figure at right. If you have made a mistake with your clean box, click on the "Erase" button, trace out a rectangle around your erroneous region, and double click inside that rectangle. You can also set multiple clean regions. By default, all clean regions will apply only to the plane shown. To change this to select all regions, click the "All Channels" button at the top. <br />
<br />
When you are happy with your clean regions, press the green circular arrow button on the far right to continue deconvolution. After completing a cycle, a revised image will come up. As the brightest points are removed from the image ("cleaned" off), fainter emission may show up. You can adjust the clean boxes each cycle, to enclose all real emission. After many cycles, once only noise is left, you can hit the red and white cross icon to stop cleaning.<br />
<br />
<br />
[[Image:3c391_ctm_i_image.jpg|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391 at 4600 MHz]]<br />
{{clean}} will make several output files, all named with the prefix given as ''imagename''. These include:<br />
* .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<br />
* .flux - the effective response of the telescope (the primary beam)<br />
* .flux.pbcoverage - the effective response of the full mosaic image<br />
* .mask - the areas where you have permitted imager to find clean components<br />
* .model - the sum of all the clean components, which has been stored as the model_data column in the measurement set<br />
* .psf - the dirty beam, which is being deconvolved from the true sky brightness during the clean process<br />
* .residual - what is left at the end of the deconvolution process; this is useful to diagnose whether or not to clean more deeply<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
<br />
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).<br />
<br />
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.<br />
<br />
The example above illustrates multi-scale CLEAN. Not all sources or fields will require multi-scale CLEAN; for reference, here is the same data set, but without multi-scale CLEANing.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_no_multiscale_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
== Next Steps ==<br />
<br />
There are a variety of additional analyses that could be done, including extracting the statistics of the images just produced, continuing with the polarization imaging, and self-calibration of the data. Examples of these topics are included in <br />
[[EVLA Advanced Topics 3C391]].<br />
<br />
If one is reading this as part of the Day 1 Summer School Tutorial, and there is time, one could consider beginning one of these advanced topics.</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=3679EVLA Continuum Tutorial 3C3912010-06-03T19:26:41Z<p>Jgallimo: /* Bandpass Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
<br />
== Overview ==<br />
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]]. As an alternative to the function calls as provided by the script extractor, all tasks may be run interactively by typing ''default taskname'' to load the task, ''inp'' to examine the inputs, and ''go'' once those inputs have been set to your satisfaction. Allowed inputs are shown in blue, and bad inputs are colored red. If you prefer this more interactive CASA experience, screenshots of the inputs to the different tasks used in the data reduction are provided, to illustrate which parameters need to be set. The attentive reader will see that all non-default inputs to the tasks correspond exactly to the parameters set in the function calls derived from the script extractor.<br />
<br />
Should you use the script generated by the [[Extracting_scripts_from_these_tutorials | script extractor]], be aware that it will require some small amount of interaction, occasionally suggesting that you close the graphics window and hitting return in the terminal to proceed. It is in fact unnecessary to close the graphics windows (it is suggested that you do so purely to keep your desktop uncluttered), and in one case (that of {{plotms}}), you '''must''' leave the graphics window open, as the GUI cannot be reopened without first exiting from CASA.<br />
<br />
== Obtaining the Data ==<br />
<br />
For the purposes of this tutorial, we have created a "starting" data set, upon which several initial processing steps have already been conducted. This data set may already be present on the machine that you are using; if not, obtain it from the<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz CASA data archive].<br />
<br />
We are providing this "starting" data set, rather than the "true" initial data set for (at least) two reasons. First, many of these initial processing steps can be rather time consuming (> 1 hr), and the time for the data reduction tutorial is limited. Second, while necessary, many of these steps are not fundamental to the calibration and imaging process, upon which we want to focus today. For completeness, however, here are the steps that were taken from the initial data set to produce the "starting" data set:<br />
* The data loaded into CASA, converting the initial Science Data Model (SDM) file into a measurement set.<br />
* Basic data flagging was applied, to account for "shadowing" of the antennas. These data are from the D configuration, in which antennas are particularly susceptible to being blocked or "shadowed" by other antennas in the array, depending upon the elevation of the source.<br />
* The data were averaged to 10-second samples, from the initial 1-second correlator sample time. In the D configuration, the fringe rate is relatively slow and time-average smearing is less of a concern.<br />
* The data were acquired with two spectral windows (around 4.6 and 7.5 GHz). Because of disk space concerns on some machines, the focus will be on only one of the two spectral windows.<br />
<br />
We emphasize that, were this a real science observation, all of these steps would need to be run. Detailed instructions on obtaining the data from the archive and creating this "starting" data set may be found in the [[Obtaining EVLA Data: 3C 391 Example]] tutorial.<br />
<br />
== Examining the Data ==<br />
<br />
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. From this, we find the following:<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Information from observing log:<br />
There is no C-band receivers on ea13<br />
Antenna ea06 is out of the array<br />
Antenna ea15 has some corrupted data<br />
Antennas ea10, ea12, ea22 do not have good baseline positions<br />
Gusty winds, mixed clouds, API rms up to 11.5.<br />
</pre><br />
<br />
Before beginning our data reduction, we must start CASA. If you have not used CASA before, some helpful tips are available on the [[Getting Started in CASA]] page.<br />
<br />
Once you have CASA up and running in the directory containing the data, then start your data reduction by getting some basic information about the data. The task {{listobs}} can be used to get a listing of the individual scans comprising the observation, the frequency setup, source list, and antenna locations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='3c391_ctm_mosaic_10s_spw0.ms',verbose=T)<br />
</source><br />
<br />
{{listobs}} should now produce output similar to the following in the casa logger. (Note that the listing shown is for both spectral windows.)<br />
<br />
<pre style="background-color: #ffe4b5;"><br />
INFO listobs::::casa ##########################################<br />
INFO listobs::::casa ##### Begin Task: listobs #####<br />
INFO listobs::::casa <br />
INFO listobs::ms::summary ================================================================================<br />
INFO listobs::ms::summary+ MeasurementSet Name: /export/home/hamal/jmiller/TDEM0001_sb1218006/3c391_mosaic_fullres.ms MS Version 2<br />
INFO listobs::ms::summary+ ================================================================================<br />
INFO listobs::ms::summary+ Observer: Dr. James Miller-Jones Project: T.B.D. <br />
INFO listobs::ms::summary+ Observation: EVLA<br />
INFO listobs::ms::summary Data records: 18666050 Total integration time = 28716 seconds<br />
INFO listobs::ms::summary+ Observed from 24-Apr-2010/08:01:34.5 to 24-Apr-2010/16:00:10.5 (UTC)<br />
INFO listobs::ms::summary <br />
INFO listobs::ms::summary+ ObservationID = 0 ArrayID = 0<br />
INFO listobs::ms::summary+ Date Timerange (UTC) Scan FldId FieldName nVis Int(s) SpwIds<br />
INFO listobs::ms::summary+ 24-Apr-2010/08:01:34.5 - 08:02:28.5 1 0 J1331+3030 35750 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:02:29.5 - 08:09:27.5 2 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:09:28.5 - 08:16:26.5 3 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:16:27.5 - 08:24:25.5 4 1 J1822-0938 311350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:24:26.5 - 08:29:44.5 5 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:29:45.5 - 08:34:43.5 6 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:34:44.5 - 08:39:42.5 7 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:39:43.5 - 08:44:41.5 8 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:44:42.5 - 08:49:40.5 9 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:49:41.5 - 08:54:40.5 10 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:54:41.5 - 08:59:39.5 11 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:59:40.5 - 09:01:29.5 12 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:01:30.5 - 09:06:48.5 13 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:06:49.5 - 09:11:47.5 14 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:11:48.5 - 09:16:46.5 15 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:16:47.5 - 09:21:45.5 16 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:21:46.5 - 09:26:44.5 17 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:26:45.5 - 09:31:44.5 18 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:31:45.5 - 09:36:43.5 19 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:36:44.5 - 09:38:32.5 20 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:38:33.5 - 09:43:52.5 21 2 3C391 C1 208000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:43:53.5 - 09:48:51.5 22 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:48:52.5 - 09:53:50.5 23 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:53:51.5 - 09:58:49.5 24 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:58:50.5 - 10:03:48.5 25 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:03:49.5 - 10:08:47.5 26 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:08:48.5 - 10:13:47.5 27 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:13:48.5 - 10:15:36.5 28 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:15:37.5 - 10:20:55.5 29 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:20:56.5 - 10:25:55.5 30 3 3C391 C2 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:25:56.5 - 10:30:54.5 31 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:30:55.5 - 10:35:53.5 32 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:35:54.5 - 10:40:52.5 33 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:40:53.5 - 10:45:51.5 34 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:45:52.5 - 10:50:51.5 35 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:50:52.5 - 10:52:40.5 36 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:52:41.5 - 10:57:39.5 37 0 J1331+3030 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:57:40.5 - 11:02:39.5 38 1 J1822-0938 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:02:40.5 - 11:07:58.5 39 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:07:59.5 - 11:12:47.5 40 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:12:48.5 - 11:17:36.5 41 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:17:37.5 - 11:22:25.5 42 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:22:26.5 - 11:27:15.5 43 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:27:16.5 - 11:32:04.5 44 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:32:05.5 - 11:36:53.5 45 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:36:54.5 - 11:38:43.5 46 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:38:44.5 - 11:44:02.5 47 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:44:03.5 - 11:48:51.5 48 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:48:52.5 - 11:53:40.5 49 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:53:41.5 - 11:58:29.5 50 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:58:30.5 - 12:03:19.5 51 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:03:20.5 - 12:08:08.5 52 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:08:09.5 - 12:12:57.5 53 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:12:58.5 - 12:14:47.5 54 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:14:48.5 - 12:20:06.5 55 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:20:07.5 - 12:24:55.5 56 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:24:56.5 - 12:29:44.5 57 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:29:45.5 - 12:34:34.5 58 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:34:35.5 - 12:39:23.5 59 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:39:24.5 - 12:44:12.5 60 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:44:13.5 - 12:49:01.5 61 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:49:02.5 - 12:50:51.5 62 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:50:52.5 - 12:56:10.5 63 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:56:11.5 - 13:00:59.5 64 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:01:00.5 - 13:05:48.5 65 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:05:49.5 - 13:10:38.5 66 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:10:39.5 - 13:15:27.5 67 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:15:28.5 - 13:20:16.5 68 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:20:17.5 - 13:25:05.5 69 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:25:06.5 - 13:26:55.5 70 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:26:56.5 - 13:32:14.5 71 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:32:15.5 - 13:37:03.5 72 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:37:04.5 - 13:41:52.5 73 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:41:53.5 - 13:46:42.5 74 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:46:43.5 - 13:51:31.5 75 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:51:32.5 - 13:56:20.5 76 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:56:21.5 - 14:01:09.5 77 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:01:10.5 - 14:02:59.5 78 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:03:00.5 - 14:08:18.5 79 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:08:19.5 - 14:13:07.5 80 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:13:08.5 - 14:17:57.5 81 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:17:58.5 - 14:22:46.5 82 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:22:47.5 - 14:27:35.5 83 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:27:36.5 - 14:32:24.5 84 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:32:25.5 - 14:37:13.5 85 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:37:14.5 - 14:39:03.5 86 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:39:04.5 - 14:44:22.5 87 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:44:23.5 - 14:49:11.5 88 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:49:12.5 - 14:54:01.5 89 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:54:02.5 - 14:58:50.5 90 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:58:51.5 - 15:03:39.5 91 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:03:40.5 - 15:08:28.5 92 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:08:29.5 - 15:13:17.5 93 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:13:18.5 - 15:15:07.5 94 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:15:08.5 - 15:20:26.5 95 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:20:27.5 - 15:25:15.5 96 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:25:16.5 - 15:30:05.5 97 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:30:06.5 - 15:34:54.5 98 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:34:55.5 - 15:39:43.5 99 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:39:44.5 - 15:44:32.5 100 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:44:33.5 - 15:49:22.5 101 8 3C391 C7 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:49:23.5 - 15:51:11.5 102 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:51:12.5 - 16:00:10.5 103 9 J0319+4130 350350 1 [0, 1]<br />
INFO listobs::ms::summary (nVis = Total number of time/baseline visibilities per scan) <br />
INFO listobs::ms::summary Fields: 10<br />
INFO listobs::ms::summary+ ID Code Name RA Decl Epoch SrcId nVis <br />
INFO listobs::ms::summary+ 0 N J1331+3030 13:31:08.2880 +30.30.32.9589 J2000 0 774800 <br />
INFO listobs::ms::summary+ 1 J J1822-0938 18:22:28.7042 -09.38.56.8350 J2000 1 1361750<br />
INFO listobs::ms::summary+ 2 NONE 3C391 C1 18:49:24.2440 -00.55.40.5800 J2000 2 2488850<br />
INFO listobs::ms::summary+ 3 NONE 3C391 C2 18:49:29.1490 -00.57.48.0000 J2000 3 2280850<br />
INFO listobs::ms::summary+ 4 NONE 3C391 C3 18:49:19.3390 -00.57.48.0000 J2000 4 2282150<br />
INFO listobs::ms::summary+ 5 NONE 3C391 C4 18:49:14.4340 -00.55.40.5800 J2000 5 2282150<br />
INFO listobs::ms::summary+ 6 NONE 3C391 C5 18:49:19.3390 -00.53.33.1600 J2000 6 2281500<br />
INFO listobs::ms::summary+ 7 NONE 3C391 C6 18:49:29.1490 -00.53.33.1600 J2000 7 2281500<br />
INFO listobs::ms::summary+ 8 NONE 3C391 C7 18:49:34.0540 -00.55.40.5800 J2000 8 2282150<br />
INFO listobs::ms::summary+ 9 Z J0319+4130 03:19:48.1601 +41.30.42.1030 J2000 9 350350 <br />
INFO listobs::ms::summary+ (nVis = Total number of time/baseline visibilities per field) <br />
INFO listobs::ms::summary Spectral Windows: (2 unique spectral windows and 1 unique polarization setups)<br />
INFO listobs::ms::summary+ SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
INFO listobs::ms::summary+ 0 64 TOPO 4536 2000 128000 4536 RR RL LR LL <br />
INFO listobs::ms::summary+ 1 64 TOPO 7436 2000 128000 7436 RR RL LR LL <br />
INFO listobs::ms::summary Sources: 20<br />
INFO listobs::ms::summary+ ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
INFO listobs::ms::summary+ 0 J1331+3030 0 - - <br />
INFO listobs::ms::summary+ 0 J1331+3030 1 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 0 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 1 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 0 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 1 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 0 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 1 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 0 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 1 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 0 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 1 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 0 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 1 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 0 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 1 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 0 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 1 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 0 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 1 - - <br />
INFO listobs::ms::summary Antennas: 26:<br />
INFO listobs::ms::summary+ ID Name Station Diam. Long. Lat. <br />
INFO listobs::ms::summary+ 0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
INFO listobs::ms::summary+ 1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
INFO listobs::ms::summary+ 2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
INFO listobs::ms::summary+ 3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
INFO listobs::ms::summary+ 4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
INFO listobs::ms::summary+ 5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
INFO listobs::ms::summary+ 6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
INFO listobs::ms::summary+ 7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
INFO listobs::ms::summary+ 8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
INFO listobs::ms::summary+ 9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
INFO listobs::ms::summary+ 10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
INFO listobs::ms::summary+ 11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
INFO listobs::ms::summary+ 12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
INFO listobs::ms::summary+ 13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
INFO listobs::ms::summary+ 14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
INFO listobs::ms::summary+ 15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
INFO listobs::ms::summary+ 16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
INFO listobs::ms::summary+ 17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
INFO listobs::ms::summary+ 18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
INFO listobs::ms::summary+ 19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
INFO listobs::ms::summary+ 20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
INFO listobs::ms::summary+ 21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
INFO listobs::ms::summary+ 22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
INFO listobs::ms::summary+ 23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
INFO listobs::ms::summary+ 24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
INFO listobs::ms::summary+ 25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
INFO listobs::::casa <br />
INFO listobs::::casa ##### End Task: listobs #####<br />
INFO listobs::::casa ##########################################<br />
</pre><br />
<br />
Note that the antenna IDs (which are numbered sequentially up to the total number of antennas in the array; 0 through 25 in this instance) do not correspond to the actual antenna names (ea01 through ea28; these numbers correspond to those painted on the side of the dishes). During our data reduction, we can refer to the antennas using either convention; ''antenna='22' '' would correspond to ea25, whereas ''antenna='ea22' '' would correspond to ea22. Note that the antenna numbers in the observer log correspond to the actual antenna names, i.e. the 'ea??' numbers given in listobs.<br />
<br />
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!). <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotants(vis='3c391_ctm_mosaic_10s_spw0.ms',figfile='3c391_ctm_mosaic_antenna_layout.png')<br />
clearstat() # This removes the table lock generated by plotants in script mode<br />
</source><br />
<br />
[[Image:3c391_ctm_plotants_parameters.jpg|200px|thumb|left|plotants parameters]]<br />
[[Image:3C391_mosaic-plotants.png|200px|thumb|center|plotants figure]]<br />
<br />
== Examining and Editing the Data ==<br />
<br />
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.<br />
<br />
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 less than 1 minute long.) This first scan can safely be deleted.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,scan='1')<br />
</source><br />
<br />
[[Image:3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
* <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.)<br />
* <strong>mode='manualflag'</strong> : Specific data are going to be selected to be edited. <br />
* <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 ''help 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.)<br />
<br />
If satisfied with the inputs, run this task. The initial display in the logger will include <br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: flagdata #####<br />
flagdata::::casa<br />
attached MS [...]<br />
Saving current flags to manualflag_1 before applying new flags<br />
Creating new backup flag file called manualflag_1<br />
</pre><br />
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_1. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used.<br />
<br />
<br />
<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea13,ea15')<br />
</source><br />
* antenna='ea13' : Once again, this parameter requires a string input. Remember that antenna='ea13' and 'antenna='13' are <em>not</em> the same antenna. (See the discussion after our call to {{listobs}} above.)<br />
<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',mode='quack',quackinterval=10.0,quackmode='beg')<br />
</source><br />
* mode='quack' : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* 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.<br />
* 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.<br />
<br />
<br />
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}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat() # This removes any existing table locks generated by flagdata<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',xaxis='',yaxis='',averagedata=False,transform=False,extendflag=False,<br />
plotfile='',selectdata=True,field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* xaxis=' ', yaxis=' ' : One can choose the axes of the plot, i.e., the way of visualizing the data, by using the GUI display once the task is executed.<br />
* averagedata=F : It is possible to average the data in time, frequency, etc. <br />
* transform=F : It is possible to change the velocity reference frame of the data.<br />
* 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.<br />
* plotfile=' ' : It is possible to produce a hard copy (e.g., for a paper, report, or Web site) by specifying a file.<br />
* selectdata=T : One can choose to plot only subsets of the data.<br />
* field='0': The entire dataset is rather large, and different sources have very different amplitudes, so it is advisable to start by loading a subset of the data. One can later loop through the different fields (i.e. sources) and spectral windows using the GUI interface.<br />
<br />
In this case, many other 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.<br />
<br />
{{plotms}} should produce a GUI, with the default view being to show the visibility amplitude as a function of time. The figure at right shows the result of running {{plotms}} without the field selection (''field='0' '') discussed above.<br />
[[Image:plotms-default.png|200px|right|thumb|plotms default GUI view, having loaded all fields at once]]<br />
{{plotms}} allows one to select and view the data in many ways. Across the top of the left 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.<br />
<br />
In the default view, the 'Plots' tab is visible, and there are a number of tabs running down the side of the left 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.<br />
<br />
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 (baseline length, in meters), 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., <math>\sqrt{u^2+v^2}</math>). 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.) <br />
<br />
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]. To plot baseline length in wavelengths rather than meters, one needs to select ''UVDist_L'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view of 3C 391]]<br />
<br />
<br />
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.<br />
<br />
'''Do not''' close the plotms GUI after running {{plotms}}, or you will need to exit casapy and restart if at any point you wish to run plotms again, otherwise the GUI will not come up a second time.<br />
<br />
== Calibrating the Data ==<br />
<br />
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. <br />
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.<br />
<br />
Recall that the observed visibility <math>V^{\prime}</math> between two antennas <math>(i,j)</math> is related to the "true" visibility <math>V</math> by <br />
<br />
<math><br />
V^{\prime}_{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)\,e^{i [\theta_i(t) - \theta_j(t)]} <br />
</math><br />
<br />
Here, for generality, we show the visibility as a function of frequency <math>f</math> and spatial wavenumbers <math>u</math> and <math>v</math>. The other terms are <br />
* <math>g_i</math> and <math>\theta_i</math> 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 <math>t</math> to indicate that they can change with temperature, atmospheric conditions, etc.<br />
* <math>B_i</math> is the complex bandpass, the instrumental response as a function of frequency, <math>f</math>. As shown here, the bandpass may also vary as a function of time.<br />
* <math>b(t)</math> 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. <br />
Strictly, the equation above is a simplification of a more general measurement equation formalism, but it is a useful simplification in many cases.<br />
<br />
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., a priori models for the calibrators, and those derived 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. If you have started with the 10s-averaged dataset suggested at the top of this tutorial, this step has already been done for you, so may be omitted.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',spw='')<br />
</source><br />
<br />
All parameters are set to blank so that the initialization occurs for all sources and spectral windows.<br />
<br />
<br />
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 <math>g_i</math> values.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',<br />
modimage='/home/casa/data/nrao/VLA/CalModels/3C286_C.im',standard='Perley-Taylor 99',<br />
fluxdensity=-1)<br />
</source><br />
<br />
[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]<br />
* 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.<br />
* 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.<br />
* 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.<br />
* fluxdensity=-1 : It is possible to specify (i.e., force) the flux density of the source to be a particular value. Setting ''fluxdensity = -1'' (as done here) asks {{setjy}} to calculate the value based on a set of standard models if the source is one of the standard flux calibrators (i.e. 3C 286, 3C 48, or 3C 147).<br />
* spw='0' : The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw, but it will not hurt to do so. Had the spectral window 0 not been split off, as has been done here, we might wish to specify the spectral window because, in this observation, the spectral windows were sufficiently separated that two different model images for 3C 286 would be appropriate; 3C286_C.im at 4.6 GHz and 3C286_X.im at 7.5 GHz. This would require two separate runs of {{setjy}}, one for each spectral window. If the spectral windows were much closer together, it might be possible to calibrate both using the same model.<br />
<br />
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.<br />
<br />
The output from {{setjy}} should look similar to the following.<br />
<pre style="background-color: #ffe4b5;"><br />
INFO taskmanager::::casa ##### async task launch: setjy ########################<br />
INFO setjy::imager::setjy() J1331+3030 spwid= 0 [I=7.747, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
INFO setjy::imager::setjy() Using model image /home/casa/data/nrao/VLA/CalModels/3C286_C.im<br />
INFO setjy::imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
INFO setjy::imager::setjy() Scaling model image to I=7.74664 Jy for visibility prediction.<br />
INFO setjy::imager::data selection Selecting data<br />
</pre><br />
As set, the flux density scale is being set only for spectral window 0 (''spw='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. <br />
<br />
<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass.png|200px|thumb|right|bandpass illustration]]<br />
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 right. 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 as well. The variations with frequency are a reflection of the (slightly) different antenna bandpasses. (<em>Exercise for the reader, reproduce this plot using {{plotms}}.</em>)<br />
<br />
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. While amplitude variations will have little effect on the bandpass solutions, it is important to solve for any phase variations with time to prevent decorrelation when vector averaging the data in computing the bandpass solutions.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal0',field='J1331+3030',<br />
refant='ea21',spw='0:27~36',calmode='p',solint='int',minsnr=5,solnorm=T)<br />
</source><br />
<br />
[[Image:3C391_gaincal0.png|200px|thumb|right|gaincal inputs for first gain solutions]]<br />
* caltable='3c391_ctm_mosaic.gcal0' : The gain solutions will be stored in an external table.<br />
* 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.<br />
* 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.<br />
* spw='0: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. Also note that, even though these data have only a single spectral window, the syntax requires specifying the spectral window in order to specify the spectral channels.<br />
* calmode='p' : Solve for only the phase portion of the gain.<br />
* 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)<br />
* 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.<br />
* solnorm=T : Strictly, for a phase-only solution, the amplitudes should be normalized by zero. This setting enforces that.<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-R.png')<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='L',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-L.png')<br />
</source><br />
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.<br />
[[Image:plotcal-3C286-G0-phase-R.png|200px|thumb|left|gain phases for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-phase-L.png|200px|thumb|center|gain phases for 3C 286, L polarization]]<br />
<br />
<br />
Alternatively, one can choose to inspect solutions for a single antenna at a time, stepping through each antenna in sequence:<br />
<source lang="python"><br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',iteration='antenna',plotrange=[-1,-1,-180,180],timerange='08:02:00~08:17:00')<br />
</source><br />
Antennas which have been flagged will show a blank plot, since there are no solutions for these antennas. Note the phase jump on antenna ea05. You may wish to flag this antenna:<br />
<source lang="python"><br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea05',field='J1331+3030',timerange='08:02:00~08:17:00')<br />
</source><br />
<br />
Now form the bandpass itself, using the phase solutions just derived.<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='3c391_ctm_mosaic_10s_spw0.ms',gaintable='3c391_ctm_mosaic.gcal0',caltable='3c391_ctm_mosaic.bcal0',<br />
field='J1331+3030',spw='',refant='ea21',solnorm=True,combine='scan',solint='inf',bandtype='B')<br />
</source><br />
<br />
[[Image:3C391_bandpass.png|200px|thumb|right|bandpass inputs]]<br />
* 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.<br />
* caltable='3c391_ctm_mosaic.bcal0' : Specify where to store the bandpass corrections.<br />
* solnorm=T : Make sure that the amplitudes of the bandpass corrections are normalized to unity.<br />
* 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.<br />
* 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.<br />
<br />
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. We use ''iteration='antenna' '' to step through separate plots for each antenna.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='R',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-R.png')<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='L',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-L.png')<br />
</source><br />
[[Image:plotcal-3C286-G0-bandpass-R.png|200px|thumb|left|bandpass for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-bandpass-L.png|200px|thumb|center|bandpass for 3C 286, L polarization]]<br />
<br />
=== Gain Calibration ===<br />
<br />
The next step is to derive corrections for the complex antenna gains, <math>g_i</math> and <math>\theta_i</math>. As discussed in the lectures and above, the absolute magnitude of the gain amplitudes <math>g_i</math> are determined by reference to a standard flux density calibrator. In order to determine the appropriate complex gains for the target source, one wants to observe a so-called phase calibrator that is much closer to the target, in order to minimize differences through the atmosphere (neutral and/or ionized) between the lines of sight to the phase calibrator and the target source. If we determine the relative gain amplitudes and phases for different antennas using the phase calibrator, we can later determine the absolute flux density scale by comparing the gain amplitudes <math>g_i</math> derived for 3C 286 with those derived for the phase calibrator. This will eventually be done using the task {{fluxscale}}. Since there is no such thing as absolute phase, we determine a zero phase by selecting a reference antenna for which the gain phase is defined to be zero.<br />
<br />
In principle, one could determine the complex antenna gains for all sources with a single invocation of {{gaincal}}; for clarity here, two separate invocations will be used.<br />
<br />
In the first step, we derive the appropriate complex gains <math>g_i</math> and <math>\theta_i</math> for the flux density calibrator 3C 286.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1331+3030',spw='0:5~58',<br />
refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',solint='inf')<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' : Produce a new calibration table containing these gain solutions. In order to make the bookkeeping easier, a '1' is appended to the file name to distinguish it from the earlier set of gain solutions, which are effectively being "thrown away."<br />
* spw='0:5~58' : From the inspection of the bandpass, one can determine the range of edge channels that are affected by the bandpass filter rolloff. Because the amplitude is dropping rapidly in these channels, one does not want to include them in the solution.<br />
* gaintype='G' and calmode='ap' : Solve for the complex antenna gains for 3C 286.<br />
* solint='inf' : Produce a solution for each scan.<br />
* gaintable='3c391_ctm_mosaic.bcal0' : Use the bandpass solutions determined earlier to correct for the bandpass shape before solving for the gain amplitudes.<br />
After reviewing the inputs to {{gaincal}} and running it, one could use {{plotcal}} to plot the solutions. While a useful sanity check, the plots themselves will be rather sparse as only a single gain amplitude is being determined for each antenna for each scan.<br />
<br />
<br />
In the second step, the appropriate complex gains for a direction on the sky close to the target source will be determined from the phase calibrator J1822-0938. We also determine the complex gains for the polarization calibrator source J0319+4130.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1822-0938,J0319+4130',<br />
spw='0:5~58',refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',<br />
solint='inf',append=True)<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' and append=True : In all previous invocations of {{gaincal}}, append has been set to False. Here, the gain solutions from the phase calibrators are going to be appended to the existing set from 3C 286. In following steps, all of these gain solutions will then be used together to derive a set of complex gains that are applied to the science data for the target source.<br />
If one checks the gain phase solutions using {{plotcal}}, one should see several solutions for each antenna as a function of time. In order to track the phases, the phase calibrator is typically observed much more frequently during the course of an observation than is the flux density calibrator. In the examples shown below, note that one of the panels is blank, which corresponds to antenna 13, the one flagged earlier in the process.<br />
<br />
[[Image:plotcal-J1822-0398-phase-R.png|200px|thumb|left|gain phase solutions for J1822-0398, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0398, L polarization]]<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Applying_the_calibration Applying the Calibration]].]</strong><br />
<br />
Having set the complex gains, we now 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).<br />
<br />
Our initial run of {{setjy}} only set the total intensity of our flux calibrator source, 3C 286. This source is known to have a fairly stable fractional polarization of 11.2% at C-band, and a polarization position angle of 66 degrees. NRAO conducted regular monitoring of a number of polarization calibrators (including 3C 286) from 1999 through 2009. If you go to the [http://www.vla.nrao.edu/astro/calib/polar/ polarization calibration webpage] and follow the link for a particular year, then search for '1331+305 C band' (1331+305 is better known as 3C 286), you will see in the table the measured values for the percentage polarization and polarization position angle.<br />
<br />
In order to calibrate the position angle, we need to set the appropriate values for Stokes Q and U. Examining our casapy.log file to find the output of {{setjy}}, we find that the total intensity was set to 7.74664 Jy in spw0. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U.<br />
<br />
<source lang="python"><br />
# In CASA<br />
i0=7.74664 # Stokes I value for spw 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0<br />
</source><br />
<br />
We now set the values of Stokes Q and U for 3C 286, using {{setjy}} as we did before.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',modimage='',spw='0',fluxdensity=[i0,q0,u0,0])<br />
</source><br />
* modimage=' ' : A model image is not used here.<br />
<br />
Note that the Stokes V flux value is set to zero, corresponding to no circular polarization.<br />
<br />
==== Solving for the Leakage Terms ====<br />
<br />
The task we will use to do all the polarization calibration is {{polcal}}. In this data set, we observed the unpolarized calibrator J0319+4130 (a.k.a. 3C 84) in order to solve for the instrumental polarization. {{polcal}} uses the Stokes IQU values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The final function call is:<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.pcal0',field='J0319+4130',<br />
spw='',refant=refant,poltype='Df',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'],<br />
gainfield=['J0319+4130', 'J1331+3030'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* caltable='3c391_ctm_mosaic.pcal0' : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the ''caltable'' argument.<br />
* field='J0319+4130' : We use the unpolarized source J0319+4130 (a.k.a. 3C 84) to solve for the leakages.<br />
* poltype='Df' : We will solve for the leakages (''D'') on a per-channel basis (''f''). Had we have 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' '').<br />
* gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'] : We apply our existing gain and bandpass tables on-the-fly by specifying them in a Python list.<br />
* gainfield=['J0319+4130','J1331+3030'] : Use only the specified sources from 3c391_ctm_mosaic.gcal1 and 3c391_ctm_mosaic.bcal0, respectively, when applying these previous gain and bandpass corrections.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.pcal0',xaxis='chan',yaxis='amp',spw='',field='',iteration='antenna')<br />
</source><br />
<br />
<br />
[[Image:3c391_ctm_plotcal_Df_solutions.jpg|thumb|{{plotcal}} GUI showing the Df solutions from {{polcal}} ]]<br />
This will produce plots similar to that shown at right.<br />
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.<br />
<br />
==== Solving for the R-L polarization angle ====<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.xcal0',poltype='Xf',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0', '3c391_ctm_mosaic.pcal0'],<br />
field='J1331+3030',refant='ea21')<br />
</source><br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.xcal0',xaxis='chan',yaxis='phase',iteration='antenna')<br />
</source><br />
<br />
[[Image:3c391_ctm_plotcal_Xf_solutions.jpg|thumb|{{plotcal}} GUI showing Xf solutions from {{polcal}} ]]<br />
<br />
At this point, your dataset contains all the necessary polarization calibration, which will shortly be applied to the data.<br />
<br />
== Applying the Calibration ==<br />
<br />
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 ''u''-''v'' 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.<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',fluxtable='3c391_ctm_mosaic.fluxscale1',<br />
reference='J1331+3030',transfer='J1822-0938,J0319+4130',append=True)<br />
</source><br />
<br />
[[Image:3C391_fluxscale.png|200px|thumb|right|fluxscale inputs]]<br />
* caltable='3c391_ctm_mosaic.gcal1' : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier<br />
* fluxtable='3c391_ctm_mosaic.fluxscale1' : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains. <br />
* reference='J1331+3030' : We specify the source with the known flux density.<br />
* transfer='J1822-0938,J0319+4130' : We specify the sources whose amplitude gains are to be rescaled.<br />
<br />
{{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. If one's data set has more than 1 spectral window, depending upon where they are spaced and the spectrum of the source, it is quite possible to find (quite) different flux densities at the different frequencies for the secondary calibrators. Example output for this data set would be<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO fluxscale::::casa ##########################################<br />
INFO fluxscale::::casa ##### Begin Task: fluxscale #####<br />
INFO fluxscale::::casa<br />
INFO fluxscale::calibrater::open Opening MS: 3c391_mosaic_10s.ms for calibration.<br />
INFO fluxscale::Calibrater:: Initializing nominal selection to the whole MS.<br />
INFO fluxscale::calibrater::fluxscale Beginning fluxscale--(MSSelection version)-------<br />
INFO fluxscale:::: Found reference field(s): J1331+3030<br />
INFO fluxscale:::: Found transfer field(s): J1822-0938 J0319+4130<br />
INFO fluxscale:::: Flux density for J1822-0938 in SpW=0 is: 2.32824 +/- 0.00706023 (SNR = 329.768, nAnt= 25)<br />
INFO fluxscale:::: Flux density for J0319+4130 in SpW=0 is: 13.7643 +/- 0.0348429 (SNR = 395.04, nAnt= 25)<br />
INFO fluxscale::Calibrater::fluxscale Appending result to 3c391_mosaic.fluxscale1<br />
INFO fluxscale:::: Appending solutions to table: 3c391_mosaic.fluxscale1<br />
INFO fluxscale::::casa<br />
INFO fluxscale::::casa ##### End Task: fluxscale #####<br />
</pre><br />
<br />
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 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.<br />
<br />
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.<br />
<br />
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). The relevant function calls are given below, although as explained presently, the calls to {{applycal}} will differ slightly if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1331+3030',gainfield=['J1331+3030','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J0319+4130',gainfield=['J0319+4130','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1822-0938',gainfield=['J1822-0938','','',''],interp=['nearest','','',''])<br />
</source><br />
<br />
* gaintable : We provide a Python list of the calibration tables to be applied. 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.<br />
* gainfield, interp : 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''.<br />
* parang : Since we have performed polarization calibration, we '''must''' set ''parang=True'', or we will discard all that hard work we did earlier. However, if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization_Calibration]] section, the tables 3c391_ctm_mosaic.pcal0 and 3c391_ctm_mosaic.xcal0 will not exist. In this case, you should leave out the final two tables in the ''gaintable'' list, and the final two sets of empty elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. 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.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
gainfield=['J1822-0938','','',''],<br />
interp=['linear','','',''],<br />
parang=True)<br />
</source><br />
<br />
[[Image:3C391_applycal.png|200px|thumb|right|applycal inputs]]<br />
* field : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* gainfield : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* interp : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
[[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]]<br />
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, for one of the parallel-hand correlations (RR or LL; the signal in the cross-hands, RL and LR is much smaller, and will be noiselike for an unpolarized calibrator). This should then 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.<br />
<br />
Inspecting the data at this stage may well show up previously-unnoticed bad data. Plotting up the '''corrected''' amplitude against UV distance, or against time is a good way to find such issues. If you find bad data, you can remove them via interactive flagging in {{plotms}}, or via manual flagging in {{flagdata}} once you have identified the offending antennas/baselines/channels/times. When you are happy that all data (particularly on your target source) look good, you may proceed.<br />
<br />
Now that the calibration has been applied to the target data, we can split off the science targets, creating a new, calibrated measurement set containing all the target fields.<br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='3c391_ctm_mosaic_10s_spw0.ms',outputvis='3c391_ctm_mosaic_spw0.ms',<br />
datacolumn='corrected',field='2~8')<br />
</source><br />
<br />
* outputvis : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* datacolumn : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* field : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Imaging ==<br />
<br />
Now that we have split off the target data into a separate measurement set with all the calibration applied, it's time to make an image. Recall from the lectures that the visibility data and the sky brightness distribution (a.k.a. image) are Fourier transform pairs<br />
<br />
<math><br />
I(l,m) = \int V(u,v) e^{[2\pi i(ul + vm)]} dudv<br />
</math><br />
<br />
The <math>u</math> and <math>v</math> coordinates are the baselines, measured in units of the observing wavelength while the <math>l</math> and <math>m</math> coordinates are the direction cosines on the sky. For generality, the sky coordinates are written in terms of direction cosines, but for most EVLA (and ALMA) observations they can be related simply to the right ascension (<math>l</math>) and declination (<math>m</math>). Also recall from the lectures that this equation is valid only if the <math>w</math> coordinate of the baselines can be neglected. This assumption is almost always true at high frequencies and smaller EVLA configurations (such as the 4.6 GHz, D-configuration observations here); the <math>w</math> coordinate cannot be neglected at lower frequencies and larger configurations (e.g., 0.33 GHz, A-configuration observations). This expression also neglects other factors, such as the shape of the primary beam. For more information on imaging, see [[http://casa.nrao.edu/docs/userman/UserManch5.html#x236-2330005 Synthesis Imaging]] within the CASA Reference Manual.<br />
<br />
<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image.<br />
Assuming you did the polarization calibration earlier, a command line call to image and deconvolve the dataset would be:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54], smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
If you previously skipped the polarization calibration, you should instead set ''stokes='I' '' and ''psfmode='clark' ''.<br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* mode='mfs' : Use multi-frequency synthesis imaging. The fractional bandwidth of these data is non-zero (128 MHz at a central frequency of 4.6 GHz). Recall that the u and v coordinates are defined as the baseline coordinates, measured in wavelengths. Thus, slight changes in the frequency from channel to channel result in slight changes in u and v. There is a concomitant improvement in u-v coverage if the visibility data from the multiple spectral channels are gridded separately onto the u-v plane, as opposed to treating all spectral channels as having the same frequency.<br />
* niter=5000,gain=0.1,threshold='1.0mJy' : Recall that the CLEAN gain is the amount by which a CLEAN component is subtracted during the CLEANing process. niter and threshold are (coupled) means of determining when to stop the CLEANing process, with niter specifying to find and subtract that many CLEAN components while threshold specifies a minimum flux density threshold a CLEAN component can have before CLEAN stops. See also interactive below. Imaging is an iterative process, and to set the threshold and number of iterations, it is usually wise to CLEAN interactively in the first instance, stopping when spurious emission from sidelobes (arising from gain errors) dominates the residual emission in the field. Here, we have used our experience in interactive mode to set a threshold level based on the rms noise in the resulting image. The number of iterations should then be set high enough to reach this threshold.<br />
* interactive=T : Very often, particularly when one is exploring how a source appears for the first time, it can be valuable to interact with the CLEANing process. If True, interactive causes a {{viewer}} window to appear. One can then set CLEAN regions, restricting where CLEAN searches for CLEAN components, as well as monitor the CLEANing process. A standard procedure is to set a large value for niter, and stop the CLEANing when it visually appears to be approaching the noise level. This procedure also allows one to change the CLEANing region, in cases when low-level intensity becomes visible as the CLEANing process proceeds. For more details, see [[http://casa.nrao.edu/docs/userman/UserMansu254.html#x292-2870005.3.14 Interactive Cleaning]], and also the discussion below.<br />
* imsize=[576,576], cell=['2.5arcsec','2.5arcsec'] : See the discussion below regarding the setting of the image size and cell size.<br />
* stokes='IQUV' and psfmode='clarkstokes' : Separate images will be made in all four polarizations (total intensity I, linear polarizations Q and U, and circular polarization V), and, with psfmode='clarkstokes', the Clark CLEAN algorithm will deconvolve each Stokes plane separately thereby making the polarization image more independent of the total intensity.<br />
* weighting='briggs',robust=0.0 : 3C 391 has diffuse, extended emission that is (at least partially) 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, Briggs weighting is used (intermediate between natural and uniform weighting), with a default robust factor of 0.<br />
* imagermode='mosaic', ftmachine='mosaic' : The data consist of a 7-pointing mosaic, since the supernova remnant fills almost the full primary beam at 4.6 GHz. A mosaic combines the data from all of the fields, with imaging and deconvolution being done jointly on all 7 fields. A mosaic both helps compensate for the shape of the primary beam and reduces the amount of large (angular) scale structure that is resolved out by the interferometer.<br />
* multiscale=[0, 6, 18, 54], smallscalebias=0.9 : A multi-scale CLEANing algorithm is used because the supernova remnant contains both diffuse, extended structure on large spatial scales and finer filamentary structure on smaller scales. The settings for multiscale are in units of pixels, with 0 pixels equivalent to the traditional delta-function CLEAN. The scales here are chosen to provide delta functions and then three logarithmically scaled sizes to fit to the data. The first scale (6 pixels) is chosen to be comparable to the size of the beam. The smallscalebias attempts to balance the weight given to larger scales, which often have more flux density, and the smaller scales, which often are brighter. Considerable experimentation is likely to be necessary; one of the authors of this document found that it was useful to CLEAN several rounds with this setting, change multiscale to be multiscale=[] and remove much of the smaller scale structure, then return to this setting.<br />
<br />
<br />
<br />
We need to select the appropriate pixel size to use. Using plotms to look at the newly-calibrated, target-only data set:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_spw0.ms',xaxis='uvdist_l',yaxis='amp')<br />
</source><br />
we select the axes tab on the left hand side, and select UVDist_L as the x-axis. <br />
[[Image:3c391 ctm spw0 uvplt.jpg|thumb|{{plotms}} GUI showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
This gives the plot shown at right.<br />
<br />
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.5 arcseconds in both co-ordinates by setting ''cell=['2.5arcsec','2.5arcsec']''. The supernova remnant is known to have a diameter of order 9 arcmin, which corresponds to about 216 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\times216</math>. We therefore set ''imsize=[576,576]''.<br />
<br />
[[Image:3C391 interactive clean.png|thumb|Example of interactive cleaning]]<br />
As mentioned above, we can guide the clean process by allowing it to find clean components only within a user-specified region. The easiest way to do this is via interactive clean. When {{clean}} runs in interactive mode, a viewer window will pop up as shown right. To get a more detailed view of the central regions containing the emission, zoom in by tracing out a rectangle with your left mouse button and double-clicking inside the zoom box you just made. Play with the color scale to bring out the emission better, by holding down the middle mouse button and moving it around. To create a clean box (a region within which components may be found), you can either hold down the right mouse button and trace out a rectangle around the source, then double click inside that rectangle to set it as a box. Alternatively, you can trace out a more generic shape to better enclose the irregular outline of the supernova remnant. To do that, right-click on the icon highlighted in green in the figure shown at right. Then trace out a shape by right-clicking where you want the corners of that shape. Once you have come full circle, the shape will be traced out in green, with small squares at the corners. Double-click inside this region and the green outline will turn white. You have now set your clean region. To toggle back to the rectangle tracer again, right-click on the icon circled in green in the figure at right. If you have made a mistake with your clean box, click on the "Erase" button, trace out a rectangle around your erroneous region, and double click inside that rectangle. You can also set multiple clean regions. By default, all clean regions will apply only to the plane shown. To change this to select all regions, click the "All Channels" button at the top. <br />
<br />
When you are happy with your clean regions, press the green circular arrow button on the far right to continue deconvolution. After completing a cycle, a revised image will come up. As the brightest points are removed from the image ("cleaned" off), fainter emission may show up. You can adjust the clean boxes each cycle, to enclose all real emission. After many cycles, once only noise is left, you can hit the red and white cross icon to stop cleaning.<br />
<br />
<br />
[[Image:3c391_ctm_i_image.jpg|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391 at 4600 MHz]]<br />
{{clean}} will make several output files, all named with the prefix given as ''imagename''. These include:<br />
* .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<br />
* .flux - the effective response of the telescope (the primary beam)<br />
* .flux.pbcoverage - the effective response of the full mosaic image<br />
* .mask - the areas where you have permitted imager to find clean components<br />
* .model - the sum of all the clean components, which has been stored as the model_data column in the measurement set<br />
* .psf - the dirty beam, which is being deconvolved from the true sky brightness during the clean process<br />
* .residual - what is left at the end of the deconvolution process; this is useful to diagnose whether or not to clean more deeply<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
<br />
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).<br />
<br />
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.<br />
<br />
The example above illustrates multi-scale CLEAN. Not all sources or fields will require multi-scale CLEAN; for reference, here is the same data set, but without multi-scale CLEANing.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_no_multiscale_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
== Next Steps ==<br />
<br />
There are a variety of additional analyses that could be done, including extracting the statistics of the images just produced, continuing with the polarization imaging, and self-calibration of the data. Examples of these topics are included in <br />
[[EVLA Advanced Topics 3C391]].<br />
<br />
If one is reading this as part of the Day 1 Summer School Tutorial, and there is time, one could consider beginning one of these advanced topics.</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=3677EVLA Continuum Tutorial 3C3912010-06-03T19:22:09Z<p>Jgallimo: </p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
<br />
== Overview ==<br />
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]]. As an alternative to the function calls as provided by the script extractor, all tasks may be run interactively by typing ''default taskname'' to load the task, ''inp'' to examine the inputs, and ''go'' once those inputs have been set to your satisfaction. Allowed inputs are shown in blue, and bad inputs are colored red. If you prefer this more interactive CASA experience, screenshots of the inputs to the different tasks used in the data reduction are provided, to illustrate which parameters need to be set. The attentive reader will see that all non-default inputs to the tasks correspond exactly to the parameters set in the function calls derived from the script extractor.<br />
<br />
Should you use the script generated by the [[Extracting_scripts_from_these_tutorials | script extractor]], be aware that it will require some small amount of interaction, occasionally suggesting that you close the graphics window and hitting return in the terminal to proceed. It is in fact unnecessary to close the graphics windows (it is suggested that you do so purely to keep your desktop uncluttered), and in one case (that of {{plotms}}), you '''must''' leave the graphics window open, as the GUI cannot be reopened without first exiting from CASA.<br />
<br />
== Obtaining the Data ==<br />
<br />
For the purposes of this tutorial, we have created a "starting" data set, upon which several initial processing steps have already been conducted. This data set may already be present on the machine that you are using; if not, obtain it from the<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz CASA data archive].<br />
<br />
We are providing this "starting" data set, rather than the "true" initial data set for (at least) two reasons. First, many of these initial processing steps can be rather time consuming (> 1 hr), and the time for the data reduction tutorial is limited. Second, while necessary, many of these steps are not fundamental to the calibration and imaging process, upon which we want to focus today. For completeness, however, here are the steps that were taken from the initial data set to produce the "starting" data set:<br />
* The data loaded into CASA, converting the initial Science Data Model (SDM) file into a measurement set.<br />
* Basic data flagging was applied, to account for "shadowing" of the antennas. These data are from the D configuration, in which antennas are particularly susceptible to being blocked or "shadowed" by other antennas in the array, depending upon the elevation of the source.<br />
* The data were averaged to 10-second samples, from the initial 1-second correlator sample time. In the D configuration, the fringe rate is relatively slow and time-average smearing is less of a concern.<br />
* The data were acquired with two spectral windows (around 4.6 and 7.5 GHz). Because of disk space concerns on some machines, the focus will be on only one of the two spectral windows.<br />
<br />
We emphasize that, were this a real science observation, all of these steps would need to be run. Detailed instructions on obtaining the data from the archive and creating this "starting" data set may be found in the [[Obtaining EVLA Data: 3C 391 Example]] tutorial.<br />
<br />
== Examining the Data ==<br />
<br />
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. From this, we find the following:<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Information from observing log:<br />
There is no C-band receivers on ea13<br />
Antenna ea06 is out of the array<br />
Antenna ea15 has some corrupted data<br />
Antennas ea10, ea12, ea22 do not have good baseline positions<br />
Gusty winds, mixed clouds, API rms up to 11.5.<br />
</pre><br />
<br />
Before beginning our data reduction, we must start CASA. If you have not used CASA before, some helpful tips are available on the [[Getting Started in CASA]] page.<br />
<br />
Once you have CASA up and running in the directory containing the data, then start your data reduction by getting some basic information about the data. The task {{listobs}} can be used to get a listing of the individual scans comprising the observation, the frequency setup, source list, and antenna locations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='3c391_ctm_mosaic_10s_spw0.ms',verbose=T)<br />
</source><br />
<br />
{{listobs}} should now produce output similar to the following in the casa logger. (Note that the listing shown is for both spectral windows.)<br />
<br />
<pre style="background-color: #ffe4b5;"><br />
INFO listobs::::casa ##########################################<br />
INFO listobs::::casa ##### Begin Task: listobs #####<br />
INFO listobs::::casa <br />
INFO listobs::ms::summary ================================================================================<br />
INFO listobs::ms::summary+ MeasurementSet Name: /export/home/hamal/jmiller/TDEM0001_sb1218006/3c391_mosaic_fullres.ms MS Version 2<br />
INFO listobs::ms::summary+ ================================================================================<br />
INFO listobs::ms::summary+ Observer: Dr. James Miller-Jones Project: T.B.D. <br />
INFO listobs::ms::summary+ Observation: EVLA<br />
INFO listobs::ms::summary Data records: 18666050 Total integration time = 28716 seconds<br />
INFO listobs::ms::summary+ Observed from 24-Apr-2010/08:01:34.5 to 24-Apr-2010/16:00:10.5 (UTC)<br />
INFO listobs::ms::summary <br />
INFO listobs::ms::summary+ ObservationID = 0 ArrayID = 0<br />
INFO listobs::ms::summary+ Date Timerange (UTC) Scan FldId FieldName nVis Int(s) SpwIds<br />
INFO listobs::ms::summary+ 24-Apr-2010/08:01:34.5 - 08:02:28.5 1 0 J1331+3030 35750 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:02:29.5 - 08:09:27.5 2 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:09:28.5 - 08:16:26.5 3 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:16:27.5 - 08:24:25.5 4 1 J1822-0938 311350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:24:26.5 - 08:29:44.5 5 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:29:45.5 - 08:34:43.5 6 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:34:44.5 - 08:39:42.5 7 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:39:43.5 - 08:44:41.5 8 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:44:42.5 - 08:49:40.5 9 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:49:41.5 - 08:54:40.5 10 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:54:41.5 - 08:59:39.5 11 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:59:40.5 - 09:01:29.5 12 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:01:30.5 - 09:06:48.5 13 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:06:49.5 - 09:11:47.5 14 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:11:48.5 - 09:16:46.5 15 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:16:47.5 - 09:21:45.5 16 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:21:46.5 - 09:26:44.5 17 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:26:45.5 - 09:31:44.5 18 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:31:45.5 - 09:36:43.5 19 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:36:44.5 - 09:38:32.5 20 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:38:33.5 - 09:43:52.5 21 2 3C391 C1 208000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:43:53.5 - 09:48:51.5 22 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:48:52.5 - 09:53:50.5 23 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:53:51.5 - 09:58:49.5 24 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:58:50.5 - 10:03:48.5 25 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:03:49.5 - 10:08:47.5 26 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:08:48.5 - 10:13:47.5 27 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:13:48.5 - 10:15:36.5 28 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:15:37.5 - 10:20:55.5 29 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:20:56.5 - 10:25:55.5 30 3 3C391 C2 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:25:56.5 - 10:30:54.5 31 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:30:55.5 - 10:35:53.5 32 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:35:54.5 - 10:40:52.5 33 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:40:53.5 - 10:45:51.5 34 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:45:52.5 - 10:50:51.5 35 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:50:52.5 - 10:52:40.5 36 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:52:41.5 - 10:57:39.5 37 0 J1331+3030 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:57:40.5 - 11:02:39.5 38 1 J1822-0938 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:02:40.5 - 11:07:58.5 39 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:07:59.5 - 11:12:47.5 40 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:12:48.5 - 11:17:36.5 41 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:17:37.5 - 11:22:25.5 42 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:22:26.5 - 11:27:15.5 43 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:27:16.5 - 11:32:04.5 44 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:32:05.5 - 11:36:53.5 45 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:36:54.5 - 11:38:43.5 46 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:38:44.5 - 11:44:02.5 47 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:44:03.5 - 11:48:51.5 48 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:48:52.5 - 11:53:40.5 49 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:53:41.5 - 11:58:29.5 50 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:58:30.5 - 12:03:19.5 51 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:03:20.5 - 12:08:08.5 52 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:08:09.5 - 12:12:57.5 53 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:12:58.5 - 12:14:47.5 54 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:14:48.5 - 12:20:06.5 55 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:20:07.5 - 12:24:55.5 56 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:24:56.5 - 12:29:44.5 57 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:29:45.5 - 12:34:34.5 58 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:34:35.5 - 12:39:23.5 59 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:39:24.5 - 12:44:12.5 60 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:44:13.5 - 12:49:01.5 61 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:49:02.5 - 12:50:51.5 62 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:50:52.5 - 12:56:10.5 63 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:56:11.5 - 13:00:59.5 64 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:01:00.5 - 13:05:48.5 65 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:05:49.5 - 13:10:38.5 66 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:10:39.5 - 13:15:27.5 67 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:15:28.5 - 13:20:16.5 68 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:20:17.5 - 13:25:05.5 69 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:25:06.5 - 13:26:55.5 70 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:26:56.5 - 13:32:14.5 71 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:32:15.5 - 13:37:03.5 72 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:37:04.5 - 13:41:52.5 73 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:41:53.5 - 13:46:42.5 74 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:46:43.5 - 13:51:31.5 75 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:51:32.5 - 13:56:20.5 76 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:56:21.5 - 14:01:09.5 77 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:01:10.5 - 14:02:59.5 78 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:03:00.5 - 14:08:18.5 79 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:08:19.5 - 14:13:07.5 80 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:13:08.5 - 14:17:57.5 81 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:17:58.5 - 14:22:46.5 82 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:22:47.5 - 14:27:35.5 83 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:27:36.5 - 14:32:24.5 84 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:32:25.5 - 14:37:13.5 85 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:37:14.5 - 14:39:03.5 86 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:39:04.5 - 14:44:22.5 87 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:44:23.5 - 14:49:11.5 88 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:49:12.5 - 14:54:01.5 89 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:54:02.5 - 14:58:50.5 90 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:58:51.5 - 15:03:39.5 91 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:03:40.5 - 15:08:28.5 92 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:08:29.5 - 15:13:17.5 93 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:13:18.5 - 15:15:07.5 94 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:15:08.5 - 15:20:26.5 95 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:20:27.5 - 15:25:15.5 96 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:25:16.5 - 15:30:05.5 97 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:30:06.5 - 15:34:54.5 98 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:34:55.5 - 15:39:43.5 99 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:39:44.5 - 15:44:32.5 100 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:44:33.5 - 15:49:22.5 101 8 3C391 C7 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:49:23.5 - 15:51:11.5 102 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:51:12.5 - 16:00:10.5 103 9 J0319+4130 350350 1 [0, 1]<br />
INFO listobs::ms::summary (nVis = Total number of time/baseline visibilities per scan) <br />
INFO listobs::ms::summary Fields: 10<br />
INFO listobs::ms::summary+ ID Code Name RA Decl Epoch SrcId nVis <br />
INFO listobs::ms::summary+ 0 N J1331+3030 13:31:08.2880 +30.30.32.9589 J2000 0 774800 <br />
INFO listobs::ms::summary+ 1 J J1822-0938 18:22:28.7042 -09.38.56.8350 J2000 1 1361750<br />
INFO listobs::ms::summary+ 2 NONE 3C391 C1 18:49:24.2440 -00.55.40.5800 J2000 2 2488850<br />
INFO listobs::ms::summary+ 3 NONE 3C391 C2 18:49:29.1490 -00.57.48.0000 J2000 3 2280850<br />
INFO listobs::ms::summary+ 4 NONE 3C391 C3 18:49:19.3390 -00.57.48.0000 J2000 4 2282150<br />
INFO listobs::ms::summary+ 5 NONE 3C391 C4 18:49:14.4340 -00.55.40.5800 J2000 5 2282150<br />
INFO listobs::ms::summary+ 6 NONE 3C391 C5 18:49:19.3390 -00.53.33.1600 J2000 6 2281500<br />
INFO listobs::ms::summary+ 7 NONE 3C391 C6 18:49:29.1490 -00.53.33.1600 J2000 7 2281500<br />
INFO listobs::ms::summary+ 8 NONE 3C391 C7 18:49:34.0540 -00.55.40.5800 J2000 8 2282150<br />
INFO listobs::ms::summary+ 9 Z J0319+4130 03:19:48.1601 +41.30.42.1030 J2000 9 350350 <br />
INFO listobs::ms::summary+ (nVis = Total number of time/baseline visibilities per field) <br />
INFO listobs::ms::summary Spectral Windows: (2 unique spectral windows and 1 unique polarization setups)<br />
INFO listobs::ms::summary+ SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
INFO listobs::ms::summary+ 0 64 TOPO 4536 2000 128000 4536 RR RL LR LL <br />
INFO listobs::ms::summary+ 1 64 TOPO 7436 2000 128000 7436 RR RL LR LL <br />
INFO listobs::ms::summary Sources: 20<br />
INFO listobs::ms::summary+ ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
INFO listobs::ms::summary+ 0 J1331+3030 0 - - <br />
INFO listobs::ms::summary+ 0 J1331+3030 1 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 0 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 1 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 0 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 1 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 0 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 1 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 0 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 1 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 0 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 1 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 0 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 1 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 0 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 1 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 0 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 1 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 0 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 1 - - <br />
INFO listobs::ms::summary Antennas: 26:<br />
INFO listobs::ms::summary+ ID Name Station Diam. Long. Lat. <br />
INFO listobs::ms::summary+ 0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
INFO listobs::ms::summary+ 1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
INFO listobs::ms::summary+ 2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
INFO listobs::ms::summary+ 3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
INFO listobs::ms::summary+ 4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
INFO listobs::ms::summary+ 5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
INFO listobs::ms::summary+ 6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
INFO listobs::ms::summary+ 7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
INFO listobs::ms::summary+ 8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
INFO listobs::ms::summary+ 9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
INFO listobs::ms::summary+ 10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
INFO listobs::ms::summary+ 11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
INFO listobs::ms::summary+ 12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
INFO listobs::ms::summary+ 13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
INFO listobs::ms::summary+ 14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
INFO listobs::ms::summary+ 15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
INFO listobs::ms::summary+ 16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
INFO listobs::ms::summary+ 17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
INFO listobs::ms::summary+ 18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
INFO listobs::ms::summary+ 19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
INFO listobs::ms::summary+ 20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
INFO listobs::ms::summary+ 21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
INFO listobs::ms::summary+ 22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
INFO listobs::ms::summary+ 23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
INFO listobs::ms::summary+ 24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
INFO listobs::ms::summary+ 25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
INFO listobs::::casa <br />
INFO listobs::::casa ##### End Task: listobs #####<br />
INFO listobs::::casa ##########################################<br />
</pre><br />
<br />
Note that the antenna IDs (which are numbered sequentially up to the total number of antennas in the array; 0 through 25 in this instance) do not correspond to the actual antenna names (ea01 through ea28; these numbers correspond to those painted on the side of the dishes). During our data reduction, we can refer to the antennas using either convention; ''antenna='22' '' would correspond to ea25, whereas ''antenna='ea22' '' would correspond to ea22. Note that the antenna numbers in the observer log correspond to the actual antenna names, i.e. the 'ea??' numbers given in listobs.<br />
<br />
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!). <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotants(vis='3c391_ctm_mosaic_10s_spw0.ms',figfile='3c391_ctm_mosaic_antenna_layout.png')<br />
clearstat() # This removes the table lock generated by plotants in script mode<br />
</source><br />
<br />
[[Image:3c391_ctm_plotants_parameters.jpg|200px|thumb|left|plotants parameters]]<br />
[[Image:3C391_mosaic-plotants.png|200px|thumb|center|plotants figure]]<br />
<br />
== Examining and Editing the Data ==<br />
<br />
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.<br />
<br />
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 less than 1 minute long.) This first scan can safely be deleted.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,scan='1')<br />
</source><br />
<br />
[[Image:3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
* <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.)<br />
* <strong>mode='manualflag'</strong> : Specific data are going to be selected to be edited. <br />
* <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 ''help 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.)<br />
<br />
If satisfied with the inputs, run this task. The initial display in the logger will include <br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: flagdata #####<br />
flagdata::::casa<br />
attached MS [...]<br />
Saving current flags to manualflag_1 before applying new flags<br />
Creating new backup flag file called manualflag_1<br />
</pre><br />
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_1. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used.<br />
<br />
<br />
<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea13,ea15')<br />
</source><br />
* antenna='ea13' : Once again, this parameter requires a string input. Remember that antenna='ea13' and 'antenna='13' are <em>not</em> the same antenna. (See the discussion after our call to {{listobs}} above.)<br />
<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',mode='quack',quackinterval=10.0,quackmode='beg')<br />
</source><br />
* mode='quack' : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* 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.<br />
* 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.<br />
<br />
<br />
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}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat() # This removes any existing table locks generated by flagdata<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',xaxis='',yaxis='',averagedata=False,transform=False,extendflag=False,<br />
plotfile='',selectdata=True,field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* xaxis=' ', yaxis=' ' : One can choose the axes of the plot, i.e., the way of visualizing the data, by using the GUI display once the task is executed.<br />
* averagedata=F : It is possible to average the data in time, frequency, etc. <br />
* transform=F : It is possible to change the velocity reference frame of the data.<br />
* 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.<br />
* plotfile=' ' : It is possible to produce a hard copy (e.g., for a paper, report, or Web site) by specifying a file.<br />
* selectdata=T : One can choose to plot only subsets of the data.<br />
* field='0': The entire dataset is rather large, and different sources have very different amplitudes, so it is advisable to start by loading a subset of the data. One can later loop through the different fields (i.e. sources) and spectral windows using the GUI interface.<br />
<br />
In this case, many other 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.<br />
<br />
{{plotms}} should produce a GUI, with the default view being to show the visibility amplitude as a function of time. The figure at right shows the result of running {{plotms}} without the field selection (''field='0' '') discussed above.<br />
[[Image:plotms-default.png|200px|right|thumb|plotms default GUI view, having loaded all fields at once]]<br />
{{plotms}} allows one to select and view the data in many ways. Across the top of the left 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.<br />
<br />
In the default view, the 'Plots' tab is visible, and there are a number of tabs running down the side of the left 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.<br />
<br />
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 (baseline length, in meters), 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., <math>\sqrt{u^2+v^2}</math>). 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.) <br />
<br />
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]. To plot baseline length in wavelengths rather than meters, one needs to select ''UVDist_L'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view of 3C 391]]<br />
<br />
<br />
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.<br />
<br />
'''Do not''' close the plotms GUI after running {{plotms}}, or you will need to exit casapy and restart if at any point you wish to run plotms again, otherwise the GUI will not come up a second time.<br />
<br />
== Calibrating the Data ==<br />
<br />
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. <br />
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.<br />
<br />
Recall that the observed visibility <math>V^{\prime}</math> between two antennas <math>(i,j)</math> is related to the "true" visibility <math>V</math> by <br />
<br />
<math><br />
V^{\prime}_{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)\,e^{i [\theta_i(t) - \theta_j(t)]} <br />
</math><br />
<br />
Here, for generality, we show the visibility as a function of frequency <math>f</math> and spatial wavenumbers <math>u</math> and <math>v</math>. The other terms are <br />
* <math>g_i</math> and <math>\theta_i</math> 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 <math>t</math> to indicate that they can change with temperature, atmospheric conditions, etc.<br />
* <math>B_i</math> is the complex bandpass, the instrumental response as a function of frequency, <math>f</math>. As shown here, the bandpass may also vary as a function of time.<br />
* <math>b(t)</math> 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. <br />
Strictly, the equation above is a simplification of a more general measurement equation formalism, but it is a useful simplification in many cases.<br />
<br />
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., a priori models for the calibrators, and those derived 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. If you have started with the 10s-averaged dataset suggested at the top of this tutorial, this step has already been done for you, so may be omitted.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',spw='')<br />
</source><br />
<br />
All parameters are set to blank so that the initialization occurs for all sources and spectral windows.<br />
<br />
<br />
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 <math>g_i</math> values.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',<br />
modimage='/home/casa/data/nrao/VLA/CalModels/3C286_C.im',standard='Perley-Taylor 99',<br />
fluxdensity=-1)<br />
</source><br />
<br />
[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]<br />
* 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.<br />
* 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.<br />
* 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.<br />
* fluxdensity=-1 : It is possible to specify (i.e., force) the flux density of the source to be a particular value. Setting ''fluxdensity = -1'' (as done here) asks {{setjy}} to calculate the value based on a set of standard models if the source is one of the standard flux calibrators (i.e. 3C 286, 3C 48, or 3C 147).<br />
* spw='0' : The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw, but it will not hurt to do so. Had the spectral window 0 not been split off, as has been done here, we might wish to specify the spectral window because, in this observation, the spectral windows were sufficiently separated that two different model images for 3C 286 would be appropriate; 3C286_C.im at 4.6 GHz and 3C286_X.im at 7.5 GHz. This would require two separate runs of {{setjy}}, one for each spectral window. If the spectral windows were much closer together, it might be possible to calibrate both using the same model.<br />
<br />
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.<br />
<br />
The output from {{setjy}} should look similar to the following.<br />
<pre style="background-color: #ffe4b5;"><br />
INFO taskmanager::::casa ##### async task launch: setjy ########################<br />
INFO setjy::imager::setjy() J1331+3030 spwid= 0 [I=7.747, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
INFO setjy::imager::setjy() Using model image /home/casa/data/nrao/VLA/CalModels/3C286_C.im<br />
INFO setjy::imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
INFO setjy::imager::setjy() Scaling model image to I=7.74664 Jy for visibility prediction.<br />
INFO setjy::imager::data selection Selecting data<br />
</pre><br />
As set, the flux density scale is being set only for spectral window 0 (''spw='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. <br />
<br />
<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass.png|200px|thumb|right|bandpass illustration]]<br />
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 right. 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 as well. The variations with frequency are a reflection of the (slightly) different antenna bandpasses. (<em>Exercise for the reader, reproduce this plot using {{plotms}}.</em>)<br />
<br />
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. While amplitude variations will have little effect on the bandpass solutions, it is important to solve for any phase variations with time to prevent decorrelation when vector averaging the data in computing the bandpass solutions.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal0',field='J1331+3030',<br />
refant='ea21',spw='0:27~36',calmode='p',solint='int',minsnr=5,solnorm=T)<br />
</source><br />
<br />
[[Image:3C391_gaincal0.png|200px|thumb|right|gaincal inputs for first gain solutions]]<br />
* caltable='3c391_ctm_mosaic.gcal0' : The gain solutions will be stored in an external table.<br />
* 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.<br />
* 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.<br />
* spw='0: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. Also note that, even though these data have only a single spectral window, the syntax requires specifying the spectral window in order to specify the spectral channels.<br />
* calmode='p' : Solve for only the phase portion of the gain.<br />
* 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)<br />
* 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.<br />
* solnorm=T : Strictly, for a phase-only solution, the amplitudes should be normalized by zero. This setting enforces that.<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-R.png')<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='L',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-L.png')<br />
</source><br />
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.<br />
[[Image:plotcal-3C286-G0-phase-R.png|200px|thumb|left|gain phases for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-phase-L.png|200px|thumb|center|gain phases for 3C 286, L polarization]]<br />
<br />
<br />
Alternatively, one can choose to inspect solutions for a single antenna at a time, stepping through each antenna in sequence:<br />
<source lang="python"><br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',iteration='antenna',plotrange=[-1,-1,-180,180],timerange='08:02:00~08:17:00')<br />
</source><br />
Antennas which have been flagged will show a blank plot, since there are no solutions for these antennas. Note the phase jump on antenna ea05. You may wish to flag this antenna:<br />
<source lang="python"><br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea05',field='J1331+3030',timerange='08:02:00~08:17:00')<br />
</source><br />
<br />
Now form the bandpass itself, using the phase solutions just derived.<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='3c391_ctm_mosaic_10s_spw0.ms',gaintable='3c391_ctm_mosaic.gcal0',caltable='3c391_ctm_mosaic.bcal0',<br />
field='J1331+3030',spw='',refant='ea21',solnorm=True,combine='scan',solint='inf',bandtype='B')<br />
</source><br />
<br />
[[Image:3C391_bandpass.png|200px|thumb|right|bandpass inputs]]<br />
* gaintable='3c391_ctm_mosaic.gcal0' : This gaintable contains the<br />
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.<br />
* caltable='3c391_ctm_mosaic.bcal0' : Specify where to store the bandpass corrections.<br />
* solnorm=T : Make sure that the amplitudes of the bandpass corrections are normalized to unity.<br />
* 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.<br />
* 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.<br />
<br />
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. We use ''iteration='antenna' '' to step through separate plots for each antenna.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='R',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-R.png')<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='L',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-L.png')<br />
</source><br />
[[Image:plotcal-3C286-G0-bandpass-R.png|200px|thumb|left|bandpass for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-bandpass-L.png|200px|thumb|center|bandpass for 3C 286, L polarization]]<br />
<br />
=== Gain Calibration ===<br />
<br />
The next step is to derive corrections for the complex antenna gains, <math>g_i</math> and <math>\theta_i</math>. As discussed in the lectures and above, the absolute magnitude of the gain amplitudes <math>g_i</math> are determined by reference to a standard flux density calibrator. In order to determine the appropriate complex gains for the target source, one wants to observe a so-called phase calibrator that is much closer to the target, in order to minimize differences through the atmosphere (neutral and/or ionized) between the lines of sight to the phase calibrator and the target source. If we determine the relative gain amplitudes and phases for different antennas using the phase calibrator, we can later determine the absolute flux density scale by comparing the gain amplitudes <math>g_i</math> derived for 3C 286 with those derived for the phase calibrator. This will eventually be done using the task {{fluxscale}}. Since there is no such thing as absolute phase, we determine a zero phase by selecting a reference antenna for which the gain phase is defined to be zero.<br />
<br />
In principle, one could determine the complex antenna gains for all sources with a single invocation of {{gaincal}}; for clarity here, two separate invocations will be used.<br />
<br />
In the first step, we derive the appropriate complex gains <math>g_i</math> and <math>\theta_i</math> for the flux density calibrator 3C 286.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1331+3030',spw='0:5~58',<br />
refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',solint='inf')<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' : Produce a new calibration table containing these gain solutions. In order to make the bookkeeping easier, a '1' is appended to the file name to distinguish it from the earlier set of gain solutions, which are effectively being "thrown away."<br />
* spw='0:5~58' : From the inspection of the bandpass, one can determine the range of edge channels that are affected by the bandpass filter rolloff. Because the amplitude is dropping rapidly in these channels, one does not want to include them in the solution.<br />
* gaintype='G' and calmode='ap' : Solve for the complex antenna gains for 3C 286.<br />
* solint='inf' : Produce a solution for each scan.<br />
* gaintable='3c391_ctm_mosaic.bcal0' : Use the bandpass solutions determined earlier to correct for the bandpass shape before solving for the gain amplitudes.<br />
After reviewing the inputs to {{gaincal}} and running it, one could use {{plotcal}} to plot the solutions. While a useful sanity check, the plots themselves will be rather sparse as only a single gain amplitude is being determined for each antenna for each scan.<br />
<br />
<br />
In the second step, the appropriate complex gains for a direction on the sky close to the target source will be determined from the phase calibrator J1822-0938. We also determine the complex gains for the polarization calibrator source J0319+4130.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1822-0938,J0319+4130',<br />
spw='0:5~58',refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',<br />
solint='inf',append=True)<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' and append=True : In all previous invocations of {{gaincal}}, append has been set to False. Here, the gain solutions from the phase calibrators are going to be appended to the existing set from 3C 286. In following steps, all of these gain solutions will then be used together to derive a set of complex gains that are applied to the science data for the target source.<br />
If one checks the gain phase solutions using {{plotcal}}, one should see several solutions for each antenna as a function of time. In order to track the phases, the phase calibrator is typically observed much more frequently during the course of an observation than is the flux density calibrator. In the examples shown below, note that one of the panels is blank, which corresponds to antenna 13, the one flagged earlier in the process.<br />
<br />
[[Image:plotcal-J1822-0398-phase-R.png|200px|thumb|left|gain phase solutions for J1822-0398, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0398, L polarization]]<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Applying_the_calibration Applying the Calibration]].]</strong><br />
<br />
Having set the complex gains, we now 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).<br />
<br />
Our initial run of {{setjy}} only set the total intensity of our flux calibrator source, 3C 286. This source is known to have a fairly stable fractional polarization of 11.2% at C-band, and a polarization position angle of 66 degrees. NRAO conducted regular monitoring of a number of polarization calibrators (including 3C 286) from 1999 through 2009. If you go to the [http://www.vla.nrao.edu/astro/calib/polar/ polarization calibration webpage] and follow the link for a particular year, then search for '1331+305 C band' (1331+305 is better known as 3C 286), you will see in the table the measured values for the percentage polarization and polarization position angle.<br />
<br />
In order to calibrate the position angle, we need to set the appropriate values for Stokes Q and U. Examining our casapy.log file to find the output of {{setjy}}, we find that the total intensity was set to 7.74664 Jy in spw0. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U.<br />
<br />
<source lang="python"><br />
# In CASA<br />
i0=7.74664 # Stokes I value for spw 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0<br />
</source><br />
<br />
We now set the values of Stokes Q and U for 3C 286, using {{setjy}} as we did before.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',modimage='',spw='0',fluxdensity=[i0,q0,u0,0])<br />
</source><br />
* modimage=' ' : A model image is not used here.<br />
<br />
Note that the Stokes V flux value is set to zero, corresponding to no circular polarization.<br />
<br />
==== Solving for the Leakage Terms ====<br />
<br />
The task we will use to do all the polarization calibration is {{polcal}}. In this data set, we observed the unpolarized calibrator J0319+4130 (a.k.a. 3C 84) in order to solve for the instrumental polarization. {{polcal}} uses the Stokes IQU values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The final function call is:<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.pcal0',field='J0319+4130',<br />
spw='',refant=refant,poltype='Df',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'],<br />
gainfield=['J0319+4130', 'J1331+3030'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* caltable='3c391_ctm_mosaic.pcal0' : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the ''caltable'' argument.<br />
* field='J0319+4130' : We use the unpolarized source J0319+4130 (a.k.a. 3C 84) to solve for the leakages.<br />
* poltype='Df' : We will solve for the leakages (''D'') on a per-channel basis (''f''). Had we have 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' '').<br />
* gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'] : We apply our existing gain and bandpass tables on-the-fly by specifying them in a Python list.<br />
* gainfield=['J0319+4130','J1331+3030'] : Use only the specified sources from 3c391_ctm_mosaic.gcal1 and 3c391_ctm_mosaic.bcal0, respectively, when applying these previous gain and bandpass corrections.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.pcal0',xaxis='chan',yaxis='amp',spw='',field='',iteration='antenna')<br />
</source><br />
<br />
<br />
[[Image:3c391_ctm_plotcal_Df_solutions.jpg|thumb|{{plotcal}} GUI showing the Df solutions from {{polcal}} ]]<br />
This will produce plots similar to that shown at right.<br />
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.<br />
<br />
==== Solving for the R-L polarization angle ====<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.xcal0',poltype='Xf',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0', '3c391_ctm_mosaic.pcal0'],<br />
field='J1331+3030',refant='ea21')<br />
</source><br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.xcal0',xaxis='chan',yaxis='phase',iteration='antenna')<br />
</source><br />
<br />
[[Image:3c391_ctm_plotcal_Xf_solutions.jpg|thumb|{{plotcal}} GUI showing Xf solutions from {{polcal}} ]]<br />
<br />
At this point, your dataset contains all the necessary polarization calibration, which will shortly be applied to the data.<br />
<br />
== Applying the Calibration ==<br />
<br />
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 ''u''-''v'' 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.<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',fluxtable='3c391_ctm_mosaic.fluxscale1',<br />
reference='J1331+3030',transfer='J1822-0938,J0319+4130',append=True)<br />
</source><br />
<br />
[[Image:3C391_fluxscale.png|200px|thumb|right|fluxscale inputs]]<br />
* caltable='3c391_ctm_mosaic.gcal1' : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier<br />
* fluxtable='3c391_ctm_mosaic.fluxscale1' : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains. <br />
* reference='J1331+3030' : We specify the source with the known flux density.<br />
* transfer='J1822-0938,J0319+4130' : We specify the sources whose amplitude gains are to be rescaled.<br />
<br />
{{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. If one's data set has more than 1 spectral window, depending upon where they are spaced and the spectrum of the source, it is quite possible to find (quite) different flux densities at the different frequencies for the secondary calibrators. Example output for this data set would be<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO fluxscale::::casa ##########################################<br />
INFO fluxscale::::casa ##### Begin Task: fluxscale #####<br />
INFO fluxscale::::casa<br />
INFO fluxscale::calibrater::open Opening MS: 3c391_mosaic_10s.ms for calibration.<br />
INFO fluxscale::Calibrater:: Initializing nominal selection to the whole MS.<br />
INFO fluxscale::calibrater::fluxscale Beginning fluxscale--(MSSelection version)-------<br />
INFO fluxscale:::: Found reference field(s): J1331+3030<br />
INFO fluxscale:::: Found transfer field(s): J1822-0938 J0319+4130<br />
INFO fluxscale:::: Flux density for J1822-0938 in SpW=0 is: 2.32824 +/- 0.00706023 (SNR = 329.768, nAnt= 25)<br />
INFO fluxscale:::: Flux density for J0319+4130 in SpW=0 is: 13.7643 +/- 0.0348429 (SNR = 395.04, nAnt= 25)<br />
INFO fluxscale::Calibrater::fluxscale Appending result to 3c391_mosaic.fluxscale1<br />
INFO fluxscale:::: Appending solutions to table: 3c391_mosaic.fluxscale1<br />
INFO fluxscale::::casa<br />
INFO fluxscale::::casa ##### End Task: fluxscale #####<br />
</pre><br />
<br />
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 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.<br />
<br />
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.<br />
<br />
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). The relevant function calls are given below, although as explained presently, the calls to {{applycal}} will differ slightly if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1331+3030',gainfield=['J1331+3030','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J0319+4130',gainfield=['J0319+4130','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1822-0938',gainfield=['J1822-0938','','',''],interp=['nearest','','',''])<br />
</source><br />
<br />
* gaintable : We provide a Python list of the calibration tables to be applied. 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.<br />
* gainfield, interp : 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''.<br />
* parang : Since we have performed polarization calibration, we '''must''' set ''parang=True'', or we will discard all that hard work we did earlier. However, if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization_Calibration]] section, the tables 3c391_ctm_mosaic.pcal0 and 3c391_ctm_mosaic.xcal0 will not exist. In this case, you should leave out the final two tables in the ''gaintable'' list, and the final two sets of empty elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. 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.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
gainfield=['J1822-0938','','',''],<br />
interp=['linear','','',''],<br />
parang=True)<br />
</source><br />
<br />
[[Image:3C391_applycal.png|200px|thumb|right|applycal inputs]]<br />
* field : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* gainfield : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* interp : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
[[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]]<br />
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, for one of the parallel-hand correlations (RR or LL; the signal in the cross-hands, RL and LR is much smaller, and will be noiselike for an unpolarized calibrator). This should then 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.<br />
<br />
Inspecting the data at this stage may well show up previously-unnoticed bad data. Plotting up the '''corrected''' amplitude against UV distance, or against time is a good way to find such issues. If you find bad data, you can remove them via interactive flagging in {{plotms}}, or via manual flagging in {{flagdata}} once you have identified the offending antennas/baselines/channels/times. When you are happy that all data (particularly on your target source) look good, you may proceed.<br />
<br />
Now that the calibration has been applied to the target data, we can split off the science targets, creating a new, calibrated measurement set containing all the target fields.<br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='3c391_ctm_mosaic_10s_spw0.ms',outputvis='3c391_ctm_mosaic_spw0.ms',<br />
datacolumn='corrected',field='2~8')<br />
</source><br />
<br />
* outputvis : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* datacolumn : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* field : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Imaging ==<br />
<br />
Now that we have split off the target data into a separate measurement set with all the calibration applied, it's time to make an image. Recall from the lectures that the visibility data and the sky brightness distribution (a.k.a. image) are Fourier transform pairs<br />
<br />
<math><br />
I(l,m) = \int V(u,v) e^{[2\pi i(ul + vm)]} dudv<br />
</math><br />
<br />
The <math>u</math> and <math>v</math> coordinates are the baselines, measured in units of the observing wavelength while the <math>l</math> and <math>m</math> coordinates are the direction cosines on the sky. For generality, the sky coordinates are written in terms of direction cosines, but for most EVLA (and ALMA) observations they can be related simply to the right ascension (<math>l</math>) and declination (<math>m</math>). Also recall from the lectures that this equation is valid only if the <math>w</math> coordinate of the baselines can be neglected. This assumption is almost always true at high frequencies and smaller EVLA configurations (such as the 4.6 GHz, D-configuration observations here); the <math>w</math> coordinate cannot be neglected at lower frequencies and larger configurations (e.g., 0.33 GHz, A-configuration observations). This expression also neglects other factors, such as the shape of the primary beam. For more information on imaging, see [[http://casa.nrao.edu/docs/userman/UserManch5.html#x236-2330005 Synthesis Imaging]] within the CASA Reference Manual.<br />
<br />
<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image.<br />
Assuming you did the polarization calibration earlier, a command line call to image and deconvolve the dataset would be:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54], smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
If you previously skipped the polarization calibration, you should instead set ''stokes='I' '' and ''psfmode='clark' ''.<br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* mode='mfs' : Use multi-frequency synthesis imaging. The fractional bandwidth of these data is non-zero (128 MHz at a central frequency of 4.6 GHz). Recall that the u and v coordinates are defined as the baseline coordinates, measured in wavelengths. Thus, slight changes in the frequency from channel to channel result in slight changes in u and v. There is a concomitant improvement in u-v coverage if the visibility data from the multiple spectral channels are gridded separately onto the u-v plane, as opposed to treating all spectral channels as having the same frequency.<br />
* niter=5000,gain=0.1,threshold='1.0mJy' : Recall that the CLEAN gain is the amount by which a CLEAN component is subtracted during the CLEANing process. niter and threshold are (coupled) means of determining when to stop the CLEANing process, with niter specifying to find and subtract that many CLEAN components while threshold specifies a minimum flux density threshold a CLEAN component can have before CLEAN stops. See also interactive below. Imaging is an iterative process, and to set the threshold and number of iterations, it is usually wise to CLEAN interactively in the first instance, stopping when spurious emission from sidelobes (arising from gain errors) dominates the residual emission in the field. Here, we have used our experience in interactive mode to set a threshold level based on the rms noise in the resulting image. The number of iterations should then be set high enough to reach this threshold.<br />
* interactive=T : Very often, particularly when one is exploring how a source appears for the first time, it can be valuable to interact with the CLEANing process. If True, interactive causes a {{viewer}} window to appear. One can then set CLEAN regions, restricting where CLEAN searches for CLEAN components, as well as monitor the CLEANing process. A standard procedure is to set a large value for niter, and stop the CLEANing when it visually appears to be approaching the noise level. This procedure also allows one to change the CLEANing region, in cases when low-level intensity becomes visible as the CLEANing process proceeds. For more details, see [[http://casa.nrao.edu/docs/userman/UserMansu254.html#x292-2870005.3.14 Interactive Cleaning]], and also the discussion below.<br />
* imsize=[576,576], cell=['2.5arcsec','2.5arcsec'] : See the discussion below regarding the setting of the image size and cell size.<br />
* stokes='IQUV' and psfmode='clarkstokes' : Separate images will be made in all four polarizations (total intensity I, linear polarizations Q and U, and circular polarization V), and, with psfmode='clarkstokes', the Clark CLEAN algorithm will deconvolve each Stokes plane separately thereby making the polarization image more independent of the total intensity.<br />
* weighting='briggs',robust=0.0 : 3C 391 has diffuse, extended emission that is (at least partially) 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, Briggs weighting is used (intermediate between natural and uniform weighting), with a default robust factor of 0.<br />
* imagermode='mosaic', ftmachine='mosaic' : The data consist of a 7-pointing mosaic, since the supernova remnant fills almost the full primary beam at 4.6 GHz. A mosaic combines the data from all of the fields, with imaging and deconvolution being done jointly on all 7 fields. A mosaic both helps compensate for the shape of the primary beam and reduces the amount of large (angular) scale structure that is resolved out by the interferometer.<br />
* multiscale=[0, 6, 18, 54], smallscalebias=0.9 : A multi-scale CLEANing algorithm is used because the supernova remnant contains both diffuse, extended structure on large spatial scales and finer filamentary structure on smaller scales. The settings for multiscale are in units of pixels, with 0 pixels equivalent to the traditional delta-function CLEAN. The scales here are chosen to provide delta functions and then three logarithmically scaled sizes to fit to the data. The first scale (6 pixels) is chosen to be comparable to the size of the beam. The smallscalebias attempts to balance the weight given to larger scales, which often have more flux density, and the smaller scales, which often are brighter. Considerable experimentation is likely to be necessary; one of the authors of this document found that it was useful to CLEAN several rounds with this setting, change multiscale to be multiscale=[] and remove much of the smaller scale structure, then return to this setting.<br />
<br />
<br />
<br />
We need to select the appropriate pixel size to use. Using plotms to look at the newly-calibrated, target-only data set:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_spw0.ms',xaxis='uvdist_l',yaxis='amp')<br />
</source><br />
we select the axes tab on the left hand side, and select UVDist_L as the x-axis. <br />
[[Image:3c391 ctm spw0 uvplt.jpg|thumb|{{plotms}} GUI showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
This gives the plot shown at right.<br />
<br />
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.5 arcseconds in both co-ordinates by setting ''cell=['2.5arcsec','2.5arcsec']''. The supernova remnant is known to have a diameter of order 9 arcmin, which corresponds to about 216 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\times216</math>. We therefore set ''imsize=[576,576]''.<br />
<br />
[[Image:3C391 interactive clean.png|thumb|Example of interactive cleaning]]<br />
As mentioned above, we can guide the clean process by allowing it to find clean components only within a user-specified region. The easiest way to do this is via interactive clean. When {{clean}} runs in interactive mode, a viewer window will pop up as shown right. To get a more detailed view of the central regions containing the emission, zoom in by tracing out a rectangle with your left mouse button and double-clicking inside the zoom box you just made. Play with the color scale to bring out the emission better, by holding down the middle mouse button and moving it around. To create a clean box (a region within which components may be found), you can either hold down the right mouse button and trace out a rectangle around the source, then double click inside that rectangle to set it as a box. Alternatively, you can trace out a more generic shape to better enclose the irregular outline of the supernova remnant. To do that, right-click on the icon highlighted in green in the figure shown at right. Then trace out a shape by right-clicking where you want the corners of that shape. Once you have come full circle, the shape will be traced out in green, with small squares at the corners. Double-click inside this region and the green outline will turn white. You have now set your clean region. To toggle back to the rectangle tracer again, right-click on the icon circled in green in the figure at right. If you have made a mistake with your clean box, click on the "Erase" button, trace out a rectangle around your erroneous region, and double click inside that rectangle. You can also set multiple clean regions. By default, all clean regions will apply only to the plane shown. To change this to select all regions, click the "All Channels" button at the top. <br />
<br />
When you are happy with your clean regions, press the green circular arrow button on the far right to continue deconvolution. After completing a cycle, a revised image will come up. As the brightest points are removed from the image ("cleaned" off), fainter emission may show up. You can adjust the clean boxes each cycle, to enclose all real emission. After many cycles, once only noise is left, you can hit the red and white cross icon to stop cleaning.<br />
<br />
<br />
[[Image:3c391_ctm_i_image.jpg|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391 at 4600 MHz]]<br />
{{clean}} will make several output files, all named with the prefix given as ''imagename''. These include:<br />
* .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<br />
* .flux - the effective response of the telescope (the primary beam)<br />
* .flux.pbcoverage - the effective response of the full mosaic image<br />
* .mask - the areas where you have permitted imager to find clean components<br />
* .model - the sum of all the clean components, which has been stored as the model_data column in the measurement set<br />
* .psf - the dirty beam, which is being deconvolved from the true sky brightness during the clean process<br />
* .residual - what is left at the end of the deconvolution process; this is useful to diagnose whether or not to clean more deeply<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
<br />
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).<br />
<br />
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.<br />
<br />
The example above illustrates multi-scale CLEAN. Not all sources or fields will require multi-scale CLEAN; for reference, here is the same data set, but without multi-scale CLEANing.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_no_multiscale_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
== Next Steps ==<br />
<br />
There are a variety of additional analyses that could be done, including extracting the statistics of the images just produced, continuing with the polarization imaging, and self-calibration of the data. Examples of these topics are included in <br />
[[EVLA Advanced Topics 3C391]].<br />
<br />
If one is reading this as part of the Day 1 Summer School Tutorial, and there is time, one could consider beginning one of these advanced topics.</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=3675EVLA Continuum Tutorial 3C3912010-06-03T19:20:38Z<p>Jgallimo: </p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
<br />
== Overview ==<br />
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]]. As an alternative to the function calls as provided by the script extractor, all tasks may be run interactively by typing ''default taskname'' to load the task, ''inp'' to examine the inputs, and ''go'' once those inputs have been set to your satisfaction. Allowed inputs are shown in blue, and bad inputs are colored red. If you prefer this more interactive CASA experience, screenshots of the inputs to the different tasks used in the data reduction are provided, to illustrate which parameters need to be set. The attentive reader will see that all non-default inputs to the tasks correspond exactly to the parameters set in the function calls derived from the script extractor.<br />
<br />
Should you use the script generated by the [[Extracting_scripts_from_these_tutorials | script extractor]], be aware that it will require some small amount of interaction, occasionally suggesting that you close the graphics window and hitting return in the terminal to proceed. It is in fact unnecessary to close the graphics windows (it is suggested that you do so purely to keep your desktop uncluttered), and in one case (that of {{plotms}}), you '''must''' leave the graphics window open, as the GUI cannot be reopened without first exiting from CASA.<br />
<br />
== Obtaining the Data ==<br />
<br />
For the purposes of this tutorial, we have created a "starting" data set, upon which several initial processing steps have already been conducted. This data set may already be present on the machine that you are using; if not, obtain it from the<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz CASA data archive].<br />
<br />
We are providing this "starting" data set, rather than the "true" initial data set for (at least) two reasons. First, many of these initial processing steps can be rather time consuming (> 1 hr), and the time for the data reduction tutorial is limited. Second, while necessary, many of these steps are not fundamental to the calibration and imaging process, upon which we want to focus today. For completeness, however, here are the steps that were taken from the initial data set to produce the "starting" data set:<br />
* The data loaded into CASA, converting the initial Science Data Model (SDM) file into a measurement set.<br />
* Basic data flagging was applied, to account for "shadowing" of the antennas. These data are from the D configuration, in which antennas are particularly susceptible to being blocked or "shadowed" by other antennas in the array, depending upon the elevation of the source.<br />
* The data were averaged to 10-second samples, from the initial 1-second correlator sample time. In the D configuration, the fringe rate is relatively slow and time-average smearing is less of a concern.<br />
* The data were acquired with two spectral windows (around 4.6 and 7.5 GHz). Because of disk space concerns on some machines, the focus will be on only one of the two spectral windows.<br />
<br />
We emphasize that, were this a real science observation, all of these steps would need to be run. Detailed instructions on obtaining the data from the archive and creating this "starting" data set may be found in the [[Obtaining EVLA Data: 3C 391 Example]] tutorial.<br />
<br />
== Examining the Data ==<br />
<br />
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. From this, we find the following:<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Information from observing log:<br />
There is no C-band receivers on ea13<br />
Antenna ea06 is out of the array<br />
Antenna ea15 has some corrupted data<br />
Antennas ea10, ea12, ea22 do not have good baseline positions<br />
Gusty winds, mixed clouds, API rms up to 11.5.<br />
</pre><br />
<br />
Before beginning our data reduction, we must start CASA. If you have not used CASA before, some helpful tips are available on the [[Getting Started in CASA]] page.<br />
<br />
Once you have CASA up and running in the directory containing the data, then start your data reduction by getting some basic information about the data. The task {{listobs}} can be used to get a listing of the individual scans comprising the observation, the frequency setup, source list, and antenna locations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='3c391_ctm_mosaic_10s_spw0.ms',verbose=T)<br />
</source><br />
<br />
{{listobs}} should now produce output similar to the following in the casa logger. (Note that the listing shown is for both spectral windows.)<br />
<br />
<pre style="background-color: #ffe4b5;"><br />
INFO listobs::::casa ##########################################<br />
INFO listobs::::casa ##### Begin Task: listobs #####<br />
INFO listobs::::casa <br />
INFO listobs::ms::summary ================================================================================<br />
INFO listobs::ms::summary+ MeasurementSet Name: /export/home/hamal/jmiller/TDEM0001_sb1218006/3c391_mosaic_fullres.ms MS Version 2<br />
INFO listobs::ms::summary+ ================================================================================<br />
INFO listobs::ms::summary+ Observer: Dr. James Miller-Jones Project: T.B.D. <br />
INFO listobs::ms::summary+ Observation: EVLA<br />
INFO listobs::ms::summary Data records: 18666050 Total integration time = 28716 seconds<br />
INFO listobs::ms::summary+ Observed from 24-Apr-2010/08:01:34.5 to 24-Apr-2010/16:00:10.5 (UTC)<br />
INFO listobs::ms::summary <br />
INFO listobs::ms::summary+ ObservationID = 0 ArrayID = 0<br />
INFO listobs::ms::summary+ Date Timerange (UTC) Scan FldId FieldName nVis Int(s) SpwIds<br />
INFO listobs::ms::summary+ 24-Apr-2010/08:01:34.5 - 08:02:28.5 1 0 J1331+3030 35750 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:02:29.5 - 08:09:27.5 2 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:09:28.5 - 08:16:26.5 3 0 J1331+3030 272350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:16:27.5 - 08:24:25.5 4 1 J1822-0938 311350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:24:26.5 - 08:29:44.5 5 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:29:45.5 - 08:34:43.5 6 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:34:44.5 - 08:39:42.5 7 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:39:43.5 - 08:44:41.5 8 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:44:42.5 - 08:49:40.5 9 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:49:41.5 - 08:54:40.5 10 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:54:41.5 - 08:59:39.5 11 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 08:59:40.5 - 09:01:29.5 12 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:01:30.5 - 09:06:48.5 13 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:06:49.5 - 09:11:47.5 14 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:11:48.5 - 09:16:46.5 15 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:16:47.5 - 09:21:45.5 16 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:21:46.5 - 09:26:44.5 17 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:26:45.5 - 09:31:44.5 18 7 3C391 C6 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:31:45.5 - 09:36:43.5 19 8 3C391 C7 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:36:44.5 - 09:38:32.5 20 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:38:33.5 - 09:43:52.5 21 2 3C391 C1 208000 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:43:53.5 - 09:48:51.5 22 3 3C391 C2 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:48:52.5 - 09:53:50.5 23 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:53:51.5 - 09:58:49.5 24 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 09:58:50.5 - 10:03:48.5 25 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:03:49.5 - 10:08:47.5 26 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:08:48.5 - 10:13:47.5 27 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:13:48.5 - 10:15:36.5 28 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:15:37.5 - 10:20:55.5 29 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:20:56.5 - 10:25:55.5 30 3 3C391 C2 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:25:56.5 - 10:30:54.5 31 4 3C391 C3 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:30:55.5 - 10:35:53.5 32 5 3C391 C4 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:35:54.5 - 10:40:52.5 33 6 3C391 C5 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:40:53.5 - 10:45:51.5 34 7 3C391 C6 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:45:52.5 - 10:50:51.5 35 8 3C391 C7 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:50:52.5 - 10:52:40.5 36 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:52:41.5 - 10:57:39.5 37 0 J1331+3030 194350 1 [0, 1]<br />
INFO listobs::ms::summary+ 10:57:40.5 - 11:02:39.5 38 1 J1822-0938 195000 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:02:40.5 - 11:07:58.5 39 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:07:59.5 - 11:12:47.5 40 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:12:48.5 - 11:17:36.5 41 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:17:37.5 - 11:22:25.5 42 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:22:26.5 - 11:27:15.5 43 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:27:16.5 - 11:32:04.5 44 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:32:05.5 - 11:36:53.5 45 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:36:54.5 - 11:38:43.5 46 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:38:44.5 - 11:44:02.5 47 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:44:03.5 - 11:48:51.5 48 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:48:52.5 - 11:53:40.5 49 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:53:41.5 - 11:58:29.5 50 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 11:58:30.5 - 12:03:19.5 51 6 3C391 C5 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:03:20.5 - 12:08:08.5 52 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:08:09.5 - 12:12:57.5 53 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:12:58.5 - 12:14:47.5 54 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:14:48.5 - 12:20:06.5 55 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:20:07.5 - 12:24:55.5 56 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:24:56.5 - 12:29:44.5 57 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:29:45.5 - 12:34:34.5 58 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:34:35.5 - 12:39:23.5 59 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:39:24.5 - 12:44:12.5 60 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:44:13.5 - 12:49:01.5 61 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:49:02.5 - 12:50:51.5 62 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:50:52.5 - 12:56:10.5 63 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 12:56:11.5 - 13:00:59.5 64 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:01:00.5 - 13:05:48.5 65 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:05:49.5 - 13:10:38.5 66 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:10:39.5 - 13:15:27.5 67 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:15:28.5 - 13:20:16.5 68 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:20:17.5 - 13:25:05.5 69 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:25:06.5 - 13:26:55.5 70 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:26:56.5 - 13:32:14.5 71 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:32:15.5 - 13:37:03.5 72 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:37:04.5 - 13:41:52.5 73 4 3C391 C3 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:41:53.5 - 13:46:42.5 74 5 3C391 C4 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:46:43.5 - 13:51:31.5 75 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:51:32.5 - 13:56:20.5 76 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 13:56:21.5 - 14:01:09.5 77 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:01:10.5 - 14:02:59.5 78 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:03:00.5 - 14:08:18.5 79 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:08:19.5 - 14:13:07.5 80 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:13:08.5 - 14:17:57.5 81 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:17:58.5 - 14:22:46.5 82 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:22:47.5 - 14:27:35.5 83 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:27:36.5 - 14:32:24.5 84 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:32:25.5 - 14:37:13.5 85 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:37:14.5 - 14:39:03.5 86 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:39:04.5 - 14:44:22.5 87 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:44:23.5 - 14:49:11.5 88 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:49:12.5 - 14:54:01.5 89 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:54:02.5 - 14:58:50.5 90 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 14:58:51.5 - 15:03:39.5 91 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:03:40.5 - 15:08:28.5 92 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:08:29.5 - 15:13:17.5 93 8 3C391 C7 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:13:18.5 - 15:15:07.5 94 1 J1822-0938 71500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:15:08.5 - 15:20:26.5 95 2 3C391 C1 207350 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:20:27.5 - 15:25:15.5 96 3 3C391 C2 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:25:16.5 - 15:30:05.5 97 4 3C391 C3 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:30:06.5 - 15:34:54.5 98 5 3C391 C4 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:34:55.5 - 15:39:43.5 99 6 3C391 C5 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:39:44.5 - 15:44:32.5 100 7 3C391 C6 187850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:44:33.5 - 15:49:22.5 101 8 3C391 C7 188500 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:49:23.5 - 15:51:11.5 102 1 J1822-0938 70850 1 [0, 1]<br />
INFO listobs::ms::summary+ 15:51:12.5 - 16:00:10.5 103 9 J0319+4130 350350 1 [0, 1]<br />
INFO listobs::ms::summary (nVis = Total number of time/baseline visibilities per scan) <br />
INFO listobs::ms::summary Fields: 10<br />
INFO listobs::ms::summary+ ID Code Name RA Decl Epoch SrcId nVis <br />
INFO listobs::ms::summary+ 0 N J1331+3030 13:31:08.2880 +30.30.32.9589 J2000 0 774800 <br />
INFO listobs::ms::summary+ 1 J J1822-0938 18:22:28.7042 -09.38.56.8350 J2000 1 1361750<br />
INFO listobs::ms::summary+ 2 NONE 3C391 C1 18:49:24.2440 -00.55.40.5800 J2000 2 2488850<br />
INFO listobs::ms::summary+ 3 NONE 3C391 C2 18:49:29.1490 -00.57.48.0000 J2000 3 2280850<br />
INFO listobs::ms::summary+ 4 NONE 3C391 C3 18:49:19.3390 -00.57.48.0000 J2000 4 2282150<br />
INFO listobs::ms::summary+ 5 NONE 3C391 C4 18:49:14.4340 -00.55.40.5800 J2000 5 2282150<br />
INFO listobs::ms::summary+ 6 NONE 3C391 C5 18:49:19.3390 -00.53.33.1600 J2000 6 2281500<br />
INFO listobs::ms::summary+ 7 NONE 3C391 C6 18:49:29.1490 -00.53.33.1600 J2000 7 2281500<br />
INFO listobs::ms::summary+ 8 NONE 3C391 C7 18:49:34.0540 -00.55.40.5800 J2000 8 2282150<br />
INFO listobs::ms::summary+ 9 Z J0319+4130 03:19:48.1601 +41.30.42.1030 J2000 9 350350 <br />
INFO listobs::ms::summary+ (nVis = Total number of time/baseline visibilities per field) <br />
INFO listobs::ms::summary Spectral Windows: (2 unique spectral windows and 1 unique polarization setups)<br />
INFO listobs::ms::summary+ SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
INFO listobs::ms::summary+ 0 64 TOPO 4536 2000 128000 4536 RR RL LR LL <br />
INFO listobs::ms::summary+ 1 64 TOPO 7436 2000 128000 7436 RR RL LR LL <br />
INFO listobs::ms::summary Sources: 20<br />
INFO listobs::ms::summary+ ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
INFO listobs::ms::summary+ 0 J1331+3030 0 - - <br />
INFO listobs::ms::summary+ 0 J1331+3030 1 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 0 - - <br />
INFO listobs::ms::summary+ 1 J1822-0938 1 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 0 - - <br />
INFO listobs::ms::summary+ 2 3C391 C1 1 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 0 - - <br />
INFO listobs::ms::summary+ 3 3C391 C2 1 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 0 - - <br />
INFO listobs::ms::summary+ 4 3C391 C3 1 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 0 - - <br />
INFO listobs::ms::summary+ 5 3C391 C4 1 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 0 - - <br />
INFO listobs::ms::summary+ 6 3C391 C5 1 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 0 - - <br />
INFO listobs::ms::summary+ 7 3C391 C6 1 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 0 - - <br />
INFO listobs::ms::summary+ 8 3C391 C7 1 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 0 - - <br />
INFO listobs::ms::summary+ 9 J0319+4130 1 - - <br />
INFO listobs::ms::summary Antennas: 26:<br />
INFO listobs::ms::summary+ ID Name Station Diam. Long. Lat. <br />
INFO listobs::ms::summary+ 0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
INFO listobs::ms::summary+ 1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
INFO listobs::ms::summary+ 2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
INFO listobs::ms::summary+ 3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
INFO listobs::ms::summary+ 4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
INFO listobs::ms::summary+ 5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
INFO listobs::ms::summary+ 6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
INFO listobs::ms::summary+ 7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
INFO listobs::ms::summary+ 8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
INFO listobs::ms::summary+ 9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
INFO listobs::ms::summary+ 10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
INFO listobs::ms::summary+ 11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
INFO listobs::ms::summary+ 12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
INFO listobs::ms::summary+ 13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
INFO listobs::ms::summary+ 14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
INFO listobs::ms::summary+ 15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
INFO listobs::ms::summary+ 16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
INFO listobs::ms::summary+ 17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
INFO listobs::ms::summary+ 18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
INFO listobs::ms::summary+ 19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
INFO listobs::ms::summary+ 20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
INFO listobs::ms::summary+ 21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
INFO listobs::ms::summary+ 22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
INFO listobs::ms::summary+ 23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
INFO listobs::ms::summary+ 24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
INFO listobs::ms::summary+ 25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
INFO listobs::::casa <br />
INFO listobs::::casa ##### End Task: listobs #####<br />
INFO listobs::::casa ##########################################<br />
</pre><br />
<br />
Note that the antenna IDs (which are numbered sequentially up to the total number of antennas in the array; 0 through 25 in this instance) do not correspond to the actual antenna names (ea01 through ea28; these numbers correspond to those painted on the side of the dishes). During our data reduction, we can refer to the antennas using either convention; ''antenna='22' '' would correspond to ea25, whereas ''antenna='ea22' '' would correspond to ea22. Note that the antenna numbers in the observer log correspond to the actual antenna names, i.e. the 'ea??' numbers given in listobs.<br />
<br />
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!). <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotants(vis='3c391_ctm_mosaic_10s_spw0.ms',figfile='3c391_ctm_mosaic_antenna_layout.png')<br />
clearstat() # This removes the table lock generated by plotants in script mode<br />
</source><br />
<br />
[[Image:3c391_ctm_plotants_parameters.jpg|200px|thumb|left|plotants parameters]]<br />
[[Image:3C391_mosaic-plotants.png|200px|thumb|center|plotants figure]]<br />
<br />
== Examining and Editing the Data ==<br />
<br />
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.<br />
<br />
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 less than 1 minute long.) This first scan can safely be deleted.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,scan='1')<br />
</source><br />
<br />
[[Image:3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
* <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.)<br />
* <strong>mode='manualflag'</strong> : Specific data are going to be selected to be edited. <br />
* <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 ''help 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.)<br />
<br />
If satisfied with the inputs, run this task. The initial display in the logger will include <br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: flagdata #####<br />
flagdata::::casa<br />
attached MS [...]<br />
Saving current flags to manualflag_1 before applying new flags<br />
Creating new backup flag file called manualflag_1<br />
</pre><br />
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_1. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used.<br />
<br />
<br />
<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea13,ea15')<br />
</source><br />
* antenna='ea13' : Once again, this parameter requires a string input. Remember that antenna='ea13' and 'antenna='13' are <em>not</em> the same antenna. (See the discussion after our call to {{listobs}} above.)<br />
<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',mode='quack',quackinterval=10.0,quackmode='beg')<br />
</source><br />
* mode='quack' : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* 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.<br />
* 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.<br />
<br />
<br />
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}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat() # This removes any existing table locks generated by flagdata<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',xaxis='',yaxis='',averagedata=False,transform=False,extendflag=False,<br />
plotfile='',selectdata=True,field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* xaxis=' ', yaxis=' ' : One can choose the axes of the plot, i.e., the way of visualizing the data, by using the GUI display once the task is executed.<br />
* averagedata=F : It is possible to average the data in time, frequency, etc. <br />
* transform=F : It is possible to change the velocity reference frame of the data.<br />
* 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.<br />
* plotfile=' ' : It is possible to produce a hard copy (e.g., for a paper, report, or Web site) by specifying a file.<br />
* selectdata=T : One can choose to plot only subsets of the data.<br />
* field='0': The entire dataset is rather large, and different sources have very different amplitudes, so it is advisable to start by loading a subset of the data. One can later loop through the different fields (i.e. sources) and spectral windows using the GUI interface.<br />
<br />
In this case, many other 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.<br />
<br />
{{plotms}} should produce a GUI, with the default view being to show the visibility amplitude as a function of time. The figure at right shows the result of running {{plotms}} without the field selection (''field='0' '') discussed above.<br />
[[Image:plotms-default.png|200px|right|thumb|plotms default GUI view, having loaded all fields at once]]<br />
{{plotms}} allows one to select and view the data in many ways. Across the top of the left 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.<br />
<br />
In the default view, the 'Plots' tab is visible, and there are a number of tabs running down the side of the left 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.<br />
<br />
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 (baseline length, in meters), 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., <math>\sqrt{u^2+v^2}</math>). 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.) <br />
<br />
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]. To plot baseline length in wavelengths rather than meters, one needs to select ''UVDist_L'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view of 3C 391]]<br />
<br />
<br />
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.<br />
<br />
'''Do not''' close the plotms GUI after running {{plotms}}, or you will need to exit casapy and restart if at any point you wish to run plotms again, otherwise the GUI will not come up a second time.<br />
<br />
== Calibrating the Data ==<br />
<br />
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. <br />
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.<br />
<br />
Recall that the observed visibility <math>V^{\prime}</math> between two antennas <math>(i,j)</math> is related to the "true" visibility <math>V</math> by <br />
<br />
<math><br />
V^{\prime}_{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)\,e^{i [\theta_i(t) - \theta_j(t)]} <br />
</math><br />
<br />
Here, for generality, we show the visibility as a function of frequency <math>f</math> and spatial wavenumbers <math>u</math> and <math>v</math>. The other terms are <br />
* <math>g_i</math> and <math>\theta_i</math> 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 <math>t</math> to indicate that they can change with temperature, atmospheric conditions, etc.<br />
* <math>B_i</math> is the complex bandpass, the instrumental response as a function of frequency, <math>f</math>. As shown here, the bandpass may also vary as a function of time.<br />
* <math>b(t)</math> 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. <br />
Strictly, the equation above is a simplification of a more general measurement equation formalism, but it is a useful simplification in many cases.<br />
<br />
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., a priori models for the calibrators, and those derived 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. If you have started with the 10s-averaged dataset suggested at the top of this tutorial, this step has already been done for you, so may be omitted.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',spw='')<br />
</source><br />
<br />
All parameters are set to blank so that the initialization occurs for all sources and spectral windows.<br />
<br />
<br />
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 <math>g_i</math> values.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',<br />
modimage='/home/casa/data/nrao/VLA/CalModels/3C286_C.im',standard='Perley-Taylor 99',<br />
fluxdensity=-1)<br />
</source><br />
<br />
[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]<br />
* 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.<br />
* 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.<br />
* 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.<br />
* fluxdensity=-1 : It is possible to specify (i.e., force) the flux density of the source to be a particular value. Setting ''fluxdensity = -1'' (as done here) asks {{setjy}} to calculate the value based on a set of standard models if the source is one of the standard flux calibrators (i.e. 3C 286, 3C 48, or 3C 147).<br />
* spw='0' : The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw, but it will not hurt to do so. Had the spectral window 0 not been split off, as has been done here, we might wish to specify the spectral window because, in this observation, the spectral windows were sufficiently separated that two different model images for 3C 286 would be appropriate; 3C286_C.im at 4.6 GHz and 3C286_X.im at 7.5 GHz. This would require two separate runs of {{setjy}}, one for each spectral window. If the spectral windows were much closer together, it might be possible to calibrate both using the same model.<br />
<br />
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.<br />
<br />
The output from {{setjy}} should look similar to the following.<br />
<pre style="background-color: #ffe4b5;"><br />
INFO taskmanager::::casa ##### async task launch: setjy ########################<br />
INFO setjy::imager::setjy() J1331+3030 spwid= 0 [I=7.747, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
INFO setjy::imager::setjy() Using model image /home/casa/data/nrao/VLA/CalModels/3C286_C.im<br />
INFO setjy::imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
INFO setjy::imager::setjy() Scaling model image to I=7.74664 Jy for visibility prediction.<br />
INFO setjy::imager::data selection Selecting data<br />
</pre><br />
As set, the flux density scale is being set only for spectral window 0 (''spw='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. <br />
<br />
<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass.png|200px|thumb|right|bandpass illustration]]<br />
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 right. 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 as well. The variations with frequency are a reflection of the (slightly) different antenna bandpasses. (<em>Exercise for the reader, reproduce this plot using {{plotms}}.</em>)<br />
<br />
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. While amplitude variations will have little effect on the bandpass solutions, it is important to solve for any phase variations with time to prevent decorrelation when vector averaging the data in computing the bandpass solutions.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal0',field='J1331+3030',<br />
refant='ea21',spw='0:27~36',calmode='p',solint='int',minsnr=5,solnorm=T)<br />
</source><br />
<br />
[[Image:3C391_gaincal0.png|200px|thumb|right|gaincal inputs for first gain solutions]]<br />
* caltable='3c391_ctm_mosaic.gcal0' : The gain solutions will be stored in an external table.<br />
* 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.<br />
* 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.<br />
* spw='0: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. Also note that, even though these data have only a single spectral window, the syntax requires specifying the spectral window in order to specify the spectral channels.<br />
* calmode='p' : Solve for only the phase portion of the gain.<br />
* 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)<br />
* 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.<br />
* solnorm=T : Strictly, for a phase-only solution, the amplitudes should be normalized by zero. This setting enforces that.<br />
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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-R.png')<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='L',field='J1331+3030',spw='',<br />
figfile='plotcal-3C286-G0-phase-L.png')<br />
</source><br />
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.<br />
[[Image:plotcal-3C286-G0-phase-R.png|200px|thumb|left|gain phases for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-phase-L.png|200px|thumb|center|gain phases for 3C 286, L polarization]]<br />
<br />
<br />
Alternatively, one can choose to inspect solutions for a single antenna at a time, stepping through each antenna in sequence:<br />
<source lang="python"><br />
plotcal(caltable='3c391_ctm_mosaic.gcal0',xaxis='time',yaxis='phase',poln='R',field='J1331+3030',iteration='antenna',plotrange=[-1,-1,-180,180],timerange='08:02:00~08:17:00')<br />
</source><br />
Antennas which have been flagged will show a blank plot, since there are no solutions for these antennas. Note the phase jump on antenna ea05. You may wish to flag this antenna:<br />
<source lang="python"><br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',flagbackup=T,mode='manualflag',selectdata=T,antenna='ea05',field='J1331+3030',timerange='08:02:00~08:17:00')<br />
</source><br />
<br />
Now form the bandpass itself, using the phase solutions just derived.<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='3c391_ctm_mosaic_10s_spw0.ms',gaintable='3c391_ctm_mosaic.gcal0',caltable='3c391_ctm_mosaic.bcal0',<br />
field='J1331+3030',spw='',refant='ea21',solnorm=True,combine='scan',solint='inf',bandtype='B')<br />
</source><br />
<br />
[[Image:3C391_bandpass.png|200px|thumb|right|bandpass inputs]]<br />
* gaintable='3c391_ctm_mosaic.gcal0' : This gaintable contains the<br />
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.<br />
* caltable='3c391_ctm_mosaic.bcal0' : Specify where to store the bandpass corrections.<br />
* solnorm=T : Make sure that the amplitudes of the bandpass corrections are normalized to unity.<br />
* 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.<br />
* 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.<br />
<br />
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. We use ''iteration='antenna' '' to step through separate plots for each antenna.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='R',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-R.png')<br />
plotcal(caltable= '3c391_ctm_mosaic.bcal0',poln='L',xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221,<br />
iteration='antenna',figfile='plotcal-3C286-B0-L.png')<br />
</source><br />
[[Image:plotcal-3C286-G0-bandpass-R.png|200px|thumb|left|bandpass for 3C 286, R polarization]]<br />
[[Image:plotcal-3C286-G0-bandpass-L.png|200px|thumb|center|bandpass for 3C 286, L polarization]]<br />
<br />
=== Gain Calibration ===<br />
<br />
The next step is to derive corrections for the complex antenna gains, <math>g_i</math> and <math>\theta_i</math>. As discussed in the lectures and above, the absolute magnitude of the gain amplitudes <math>g_i</math> are determined by reference to a standard flux density calibrator. In order to determine the appropriate complex gains for the target source, one wants to observe a so-called phase calibrator that is much closer to the target, in order to minimize differences through the atmosphere (neutral and/or ionized) between the lines of sight to the phase calibrator and the target source. If we determine the relative gain amplitudes and phases for different antennas using the phase calibrator, we can later determine the absolute flux density scale by comparing the gain amplitudes <math>g_i</math> derived for 3C 286 with those derived for the phase calibrator. This will eventually be done using the task {{fluxscale}}. Since there is no such thing as absolute phase, we determine a zero phase by selecting a reference antenna for which the gain phase is defined to be zero.<br />
<br />
In principle, one could determine the complex antenna gains for all sources with a single invocation of {{gaincal}}; for clarity here, two separate invocations will be used.<br />
<br />
In the first step, we derive the appropriate complex gains <math>g_i</math> and <math>\theta_i</math> for the flux density calibrator 3C 286.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1331+3030',spw='0:5~58',<br />
refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',solint='inf')<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' : Produce a new calibration table containing these gain solutions. In order to make the bookkeeping easier, a '1' is appended to the file name to distinguish it from the earlier set of gain solutions, which are effectively being "thrown away."<br />
* spw='0:5~58' : From the inspection of the bandpass, one can determine the range of edge channels that are affected by the bandpass filter rolloff. Because the amplitude is dropping rapidly in these channels, one does not want to include them in the solution.<br />
* gaintype='G' and calmode='ap' : Solve for the complex antenna gains for 3C 286.<br />
* solint='inf' : Produce a solution for each scan.<br />
* gaintable='3c391_ctm_mosaic.bcal0' : Use the bandpass solutions determined earlier to correct for the bandpass shape before solving for the gain amplitudes.<br />
After reviewing the inputs to {{gaincal}} and running it, one could use {{plotcal}} to plot the solutions. While a useful sanity check, the plots themselves will be rather sparse as only a single gain amplitude is being determined for each antenna for each scan.<br />
<br />
<br />
In the second step, the appropriate complex gains for a direction on the sky close to the target source will be determined from the phase calibrator J1822-0938. We also determine the complex gains for the polarization calibrator source J0319+4130.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',field='J1822-0938,J0319+4130',<br />
spw='0:5~58',refant='ea21',gaintype='G',gaintable='3c391_ctm_mosaic.bcal0',calmode='ap',<br />
solint='inf',append=True)<br />
</source><br />
* caltable='3c391_ctm_mosaic.gcal1' and append=True : In all previous invocations of {{gaincal}}, append has been set to False. Here, the gain solutions from the phase calibrators are going to be appended to the existing set from 3C 286. In following steps, all of these gain solutions will then be used together to derive a set of complex gains that are applied to the science data for the target source.<br />
If one checks the gain phase solutions using {{plotcal}}, one should see several solutions for each antenna as a function of time. In order to track the phases, the phase calibrator is typically observed much more frequently during the course of an observation than is the flux density calibrator. In the examples shown below, note that one of the panels is blank, which corresponds to antenna 13, the one flagged earlier in the process.<br />
<br />
[[Image:plotcal-J1822-0398-phase-R.png|200px|thumb|left|gain phase solutions for J1822-0398, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0398, L polarization]]<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Applying_the_calibration Applying the Calibration]].]</strong><br />
<br />
Having set the complex gains, we now 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).<br />
<br />
Our initial run of {{setjy}} only set the total intensity of our flux calibrator source, 3C 286. This source is known to have a fairly stable fractional polarization of 11.2% at C-band, and a polarization position angle of 66 degrees. NRAO conducted regular monitoring of a number of polarization calibrators (including 3C 286) from 1999 through 2009. If you go to the [http://www.vla.nrao.edu/astro/calib/polar/ polarization calibration webpage] and follow the link for a particular year, then search for '1331+305 C band' (1331+305 is better known as 3C 286), you will see in the table the measured values for the percentage polarization and polarization position angle.<br />
<br />
In order to calibrate the position angle, we need to set the appropriate values for Stokes Q and U. Examining our casapy.log file to find the output of {{setjy}}, we find that the total intensity was set to 7.74664 Jy in spw0. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U.<br />
<br />
<source lang="python"><br />
# In CASA<br />
i0=7.74664 # Stokes I value for spw 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0<br />
</source><br />
<br />
We now set the values of Stokes Q and U for 3C 286, using {{setjy}} as we did before.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',modimage='',spw='0',fluxdensity=[i0,q0,u0,0])<br />
</source><br />
* modimage=' ' : A model image is not used here.<br />
<br />
Note that the Stokes V flux value is set to zero, corresponding to no circular polarization.<br />
<br />
==== Solving for the Leakage Terms ====<br />
<br />
The task we will use to do all the polarization calibration is {{polcal}}. In this data set, we observed the unpolarized calibrator J0319+4130 (a.k.a. 3C 84) in order to solve for the instrumental polarization. {{polcal}} uses the Stokes IQU values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The final function call is:<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.pcal0',field='J0319+4130',<br />
spw='',refant=refant,poltype='Df',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'],<br />
gainfield=['J0319+4130', 'J1331+3030'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* caltable='3c391_ctm_mosaic.pcal0' : [[polcal]] will create a new calibration table containing the leakage solutions, which we specify with the ''caltable'' argument.<br />
* field='J0319+4130' : We use the unpolarized source J0319+4130 (a.k.a. 3C 84) to solve for the leakages.<br />
* poltype='Df' : We will solve for the leakages (''D'') on a per-channel basis (''f''). Had we have 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' '').<br />
* gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0'] : We apply our existing gain and bandpass tables on-the-fly by specifying them in a Python list.<br />
* gainfield=['J0319+4130','J1331+3030'] : Use only the specified sources from 3c391_ctm_mosaic.gcal1 and 3c391_ctm_mosaic.bcal0, respectively, when applying these previous gain and bandpass corrections.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.pcal0',xaxis='chan',yaxis='amp',spw='',field='',iteration='antenna')<br />
</source><br />
<br />
<br />
[[Image:3c391_ctm_plotcal_Df_solutions.jpg|thumb|[[plotcal]] GUI showing the Df solutions from [[polcal]] ]]<br />
This will produce plots similar to that shown at right.<br />
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.<br />
<br />
==== Solving for the R-L polarization angle ====<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.xcal0',poltype='Xf',<br />
gaintable=['3c391_ctm_mosaic.gcal1', '3c391_ctm_mosaic.bcal0', '3c391_ctm_mosaic.pcal0'],<br />
field='J1331+3030',refant='ea21')<br />
</source><br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic.xcal0',xaxis='chan',yaxis='phase',iteration='antenna')<br />
</source><br />
<br />
[[Image:3c391_ctm_plotcal_Xf_solutions.jpg|thumb|{{plotcal}} GUI showing Xf solutions from {{polcal}} ]]<br />
<br />
At this point, your dataset contains all the necessary polarization calibration, which will shortly be applied to the data.<br />
<br />
== Applying the Calibration ==<br />
<br />
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 ''u''-''v'' 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.<br />
<br />
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.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic.gcal1',fluxtable='3c391_ctm_mosaic.fluxscale1',<br />
reference='J1331+3030',transfer='J1822-0938,J0319+4130',append=True)<br />
</source><br />
<br />
[[Image:3C391_fluxscale.png|200px|thumb|right|fluxscale inputs]]<br />
* caltable='3c391_ctm_mosaic.gcal1' : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier<br />
* fluxtable='3c391_ctm_mosaic.fluxscale1' : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains. <br />
* reference='J1331+3030' : We specify the source with the known flux density.<br />
* transfer='J1822-0938,J0319+4130' : We specify the sources whose amplitude gains are to be rescaled.<br />
<br />
{{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. If one's data set has more than 1 spectral window, depending upon where they are spaced and the spectrum of the source, it is quite possible to find (quite) different flux densities at the different frequencies for the secondary calibrators. Example output for this data set would be<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO fluxscale::::casa ##########################################<br />
INFO fluxscale::::casa ##### Begin Task: fluxscale #####<br />
INFO fluxscale::::casa<br />
INFO fluxscale::calibrater::open Opening MS: 3c391_mosaic_10s.ms for calibration.<br />
INFO fluxscale::Calibrater:: Initializing nominal selection to the whole MS.<br />
INFO fluxscale::calibrater::fluxscale Beginning fluxscale--(MSSelection version)-------<br />
INFO fluxscale:::: Found reference field(s): J1331+3030<br />
INFO fluxscale:::: Found transfer field(s): J1822-0938 J0319+4130<br />
INFO fluxscale:::: Flux density for J1822-0938 in SpW=0 is: 2.32824 +/- 0.00706023 (SNR = 329.768, nAnt= 25)<br />
INFO fluxscale:::: Flux density for J0319+4130 in SpW=0 is: 13.7643 +/- 0.0348429 (SNR = 395.04, nAnt= 25)<br />
INFO fluxscale::Calibrater::fluxscale Appending result to 3c391_mosaic.fluxscale1<br />
INFO fluxscale:::: Appending solutions to table: 3c391_mosaic.fluxscale1<br />
INFO fluxscale::::casa<br />
INFO fluxscale::::casa ##### End Task: fluxscale #####<br />
</pre><br />
<br />
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 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.<br />
<br />
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.<br />
<br />
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). The relevant function calls are given below, although as explained presently, the calls to {{applycal}} will differ slightly if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1331+3030',gainfield=['J1331+3030','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J0319+4130',gainfield=['J0319+4130','','',''],interp=['nearest','','',''])<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
parang=True,field='J1822-0938',gainfield=['J1822-0938','','',''],interp=['nearest','','',''])<br />
</source><br />
<br />
* gaintable : We provide a Python list of the calibration tables to be applied. 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.<br />
* gainfield, interp : 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''.<br />
* parang : Since we have performed polarization calibration, we '''must''' set ''parang=True'', or we will discard all that hard work we did earlier. However, if you skipped the [[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Polarization_Calibration Polarization_Calibration]] section, the tables 3c391_ctm_mosaic.pcal0 and 3c391_ctm_mosaic.xcal0 will not exist. In this case, you should leave out the final two tables in the ''gaintable'' list, and the final two sets of empty elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. 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.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic.fluxscale1','3c391_ctm_mosaic.bcal0','3c391_ctm_mosaic.pcal0','3c391_ctm_mosaic.xcal0'],<br />
gainfield=['J1822-0938','','',''],<br />
interp=['linear','','',''],<br />
parang=True)<br />
</source><br />
<br />
[[Image:3C391_applycal.png|200px|thumb|right|applycal inputs]]<br />
* field : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* gainfield : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* interp : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
[[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]]<br />
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, for one of the parallel-hand correlations (RR or LL; the signal in the cross-hands, RL and LR is much smaller, and will be noiselike for an unpolarized calibrator). This should then 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.<br />
<br />
Inspecting the data at this stage may well show up previously-unnoticed bad data. Plotting up the '''corrected''' amplitude against UV distance, or against time is a good way to find such issues. If you find bad data, you can remove them via interactive flagging in {{plotms}}, or via manual flagging in {{flagdata}} once you have identified the offending antennas/baselines/channels/times. When you are happy that all data (particularly on your target source) look good, you may proceed.<br />
<br />
Now that the calibration has been applied to the target data, we can split off the science targets, creating a new, calibrated measurement set containing all the target fields.<br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='3c391_ctm_mosaic_10s_spw0.ms',outputvis='3c391_ctm_mosaic_spw0.ms',<br />
datacolumn='corrected',field='2~8')<br />
</source><br />
<br />
* outputvis : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* datacolumn : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* field : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Imaging ==<br />
<br />
Now that we have split off the target data into a separate measurement set with all the calibration applied, it's time to make an image. Recall from the lectures that the visibility data and the sky brightness distribution (a.k.a. image) are Fourier transform pairs<br />
<br />
<math><br />
I(l,m) = \int V(u,v) e^{[2\pi i(ul + vm)]} dudv<br />
</math><br />
<br />
The <math>u</math> and <math>v</math> coordinates are the baselines, measured in units of the observing wavelength while the <math>l</math> and <math>m</math> coordinates are the direction cosines on the sky. For generality, the sky coordinates are written in terms of direction cosines, but for most EVLA (and ALMA) observations they can be related simply to the right ascension (<math>l</math>) and declination (<math>m</math>). Also recall from the lectures that this equation is valid only if the <math>w</math> coordinate of the baselines can be neglected. This assumption is almost always true at high frequencies and smaller EVLA configurations (such as the 4.6 GHz, D-configuration observations here); the <math>w</math> coordinate cannot be neglected at lower frequencies and larger configurations (e.g., 0.33 GHz, A-configuration observations). This expression also neglects other factors, such as the shape of the primary beam. For more information on imaging, see [[http://casa.nrao.edu/docs/userman/UserManch5.html#x236-2330005 Synthesis Imaging]] within the CASA Reference Manual.<br />
<br />
<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image.<br />
Assuming you did the polarization calibration earlier, a command line call to image and deconvolve the dataset would be:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54], smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
If you previously skipped the polarization calibration, you should instead set ''stokes='I' '' and ''psfmode='clark' ''.<br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* mode='mfs' : Use multi-frequency synthesis imaging. The fractional bandwidth of these data is non-zero (128 MHz at a central frequency of 4.6 GHz). Recall that the u and v coordinates are defined as the baseline coordinates, measured in wavelengths. Thus, slight changes in the frequency from channel to channel result in slight changes in u and v. There is a concomitant improvement in u-v coverage if the visibility data from the multiple spectral channels are gridded separately onto the u-v plane, as opposed to treating all spectral channels as having the same frequency.<br />
* niter=5000,gain=0.1,threshold='1.0mJy' : Recall that the CLEAN gain is the amount by which a CLEAN component is subtracted during the CLEANing process. niter and threshold are (coupled) means of determining when to stop the CLEANing process, with niter specifying to find and subtract that many CLEAN components while threshold specifies a minimum flux density threshold a CLEAN component can have before CLEAN stops. See also interactive below. Imaging is an iterative process, and to set the threshold and number of iterations, it is usually wise to CLEAN interactively in the first instance, stopping when spurious emission from sidelobes (arising from gain errors) dominates the residual emission in the field. Here, we have used our experience in interactive mode to set a threshold level based on the rms noise in the resulting image. The number of iterations should then be set high enough to reach this threshold.<br />
* interactive=T : Very often, particularly when one is exploring how a source appears for the first time, it can be valuable to interact with the CLEANing process. If True, interactive causes a {{viewer}} window to appear. One can then set CLEAN regions, restricting where CLEAN searches for CLEAN components, as well as monitor the CLEANing process. A standard procedure is to set a large value for niter, and stop the CLEANing when it visually appears to be approaching the noise level. This procedure also allows one to change the CLEANing region, in cases when low-level intensity becomes visible as the CLEANing process proceeds. For more details, see [[http://casa.nrao.edu/docs/userman/UserMansu254.html#x292-2870005.3.14 Interactive Cleaning]], and also the discussion below.<br />
* imsize=[576,576], cell=['2.5arcsec','2.5arcsec'] : See the discussion below regarding the setting of the image size and cell size.<br />
* stokes='IQUV' and psfmode='clarkstokes' : Separate images will be made in all four polarizations (total intensity I, linear polarizations Q and U, and circular polarization V), and, with psfmode='clarkstokes', the Clark CLEAN algorithm will deconvolve each Stokes plane separately thereby making the polarization image more independent of the total intensity.<br />
* weighting='briggs',robust=0.0 : 3C 391 has diffuse, extended emission that is (at least partially) 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, Briggs weighting is used (intermediate between natural and uniform weighting), with a default robust factor of 0.<br />
* imagermode='mosaic', ftmachine='mosaic' : The data consist of a 7-pointing mosaic, since the supernova remnant fills almost the full primary beam at 4.6 GHz. A mosaic combines the data from all of the fields, with imaging and deconvolution being done jointly on all 7 fields. A mosaic both helps compensate for the shape of the primary beam and reduces the amount of large (angular) scale structure that is resolved out by the interferometer.<br />
* multiscale=[0, 6, 18, 54], smallscalebias=0.9 : A multi-scale CLEANing algorithm is used because the supernova remnant contains both diffuse, extended structure on large spatial scales and finer filamentary structure on smaller scales. The settings for multiscale are in units of pixels, with 0 pixels equivalent to the traditional delta-function CLEAN. The scales here are chosen to provide delta functions and then three logarithmically scaled sizes to fit to the data. The first scale (6 pixels) is chosen to be comparable to the size of the beam. The smallscalebias attempts to balance the weight given to larger scales, which often have more flux density, and the smaller scales, which often are brighter. Considerable experimentation is likely to be necessary; one of the authors of this document found that it was useful to CLEAN several rounds with this setting, change multiscale to be multiscale=[] and remove much of the smaller scale structure, then return to this setting.<br />
<br />
<br />
<br />
We need to select the appropriate pixel size to use. Using plotms to look at the newly-calibrated, target-only data set:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_spw0.ms',xaxis='uvdist_l',yaxis='amp')<br />
</source><br />
we select the axes tab on the left hand side, and select UVDist_L as the x-axis. <br />
[[Image:3c391 ctm spw0 uvplt.jpg|thumb|{{plotms}} GUI showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
This gives the plot shown at right.<br />
<br />
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.5 arcseconds in both co-ordinates by setting ''cell=['2.5arcsec','2.5arcsec']''. The supernova remnant is known to have a diameter of order 9 arcmin, which corresponds to about 216 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\times216</math>. We therefore set ''imsize=[576,576]''.<br />
<br />
[[Image:3C391 interactive clean.png|thumb|Example of interactive cleaning]]<br />
As mentioned above, we can guide the clean process by allowing it to find clean components only within a user-specified region. The easiest way to do this is via interactive clean. When {{clean}} runs in interactive mode, a viewer window will pop up as shown right. To get a more detailed view of the central regions containing the emission, zoom in by tracing out a rectangle with your left mouse button and double-clicking inside the zoom box you just made. Play with the color scale to bring out the emission better, by holding down the middle mouse button and moving it around. To create a clean box (a region within which components may be found), you can either hold down the right mouse button and trace out a rectangle around the source, then double click inside that rectangle to set it as a box. Alternatively, you can trace out a more generic shape to better enclose the irregular outline of the supernova remnant. To do that, right-click on the icon highlighted in green in the figure shown at right. Then trace out a shape by right-clicking where you want the corners of that shape. Once you have come full circle, the shape will be traced out in green, with small squares at the corners. Double-click inside this region and the green outline will turn white. You have now set your clean region. To toggle back to the rectangle tracer again, right-click on the icon circled in green in the figure at right. If you have made a mistake with your clean box, click on the "Erase" button, trace out a rectangle around your erroneous region, and double click inside that rectangle. You can also set multiple clean regions. By default, all clean regions will apply only to the plane shown. To change this to select all regions, click the "All Channels" button at the top. <br />
<br />
When you are happy with your clean regions, press the green circular arrow button on the far right to continue deconvolution. After completing a cycle, a revised image will come up. As the brightest points are removed from the image ("cleaned" off), fainter emission may show up. You can adjust the clean boxes each cycle, to enclose all real emission. After many cycles, once only noise is left, you can hit the red and white cross icon to stop cleaning.<br />
<br />
<br />
[[Image:3c391_ctm_i_image.jpg|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391 at 4600 MHz]]<br />
{{clean}} will make several output files, all named with the prefix given as ''imagename''. These include:<br />
* .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<br />
* .flux - the effective response of the telescope (the primary beam)<br />
* .flux.pbcoverage - the effective response of the full mosaic image<br />
* .mask - the areas where you have permitted imager to find clean components<br />
* .model - the sum of all the clean components, which has been stored as the model_data column in the measurement set<br />
* .psf - the dirty beam, which is being deconvolved from the true sky brightness during the clean process<br />
* .residual - what is left at the end of the deconvolution process; this is useful to diagnose whether or not to clean more deeply<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
<br />
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).<br />
<br />
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.<br />
<br />
The example above illustrates multi-scale CLEAN. Not all sources or fields will require multi-scale CLEAN; for reference, here is the same data set, but without multi-scale CLEANing.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_no_multiscale_IQUV',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
interactive=True,<br />
imsize=[576,576], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.0,<br />
calready=True)<br />
</source><br />
<br />
== Next Steps ==<br />
<br />
There are a variety of additional analyses that could be done, including extracting the statistics of the images just produced, continuing with the polarization imaging, and self-calibration of the data. Examples of these topics are included in <br />
[[EVLA Advanced Topics 3C391]].<br />
<br />
If one is reading this as part of the Day 1 Summer School Tutorial, and there is time, one could consider beginning one of these advanced topics.</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Spectral_Line_Imaging_Analysis_IRC%2B10216&diff=3673EVLA Spectral Line Imaging Analysis IRC+102162010-06-03T19:12:56Z<p>Jgallimo: </p>
<hr />
<div><pre style="background-color: #FFFF00;"><br />
This tutorial is under construction. There are several things still to be added <br />
<br />
For the time being (until release candidate is built) you want to run this on casapy-test<br />
<br />
</pre><br />
<br />
This tutorial picks up where [[EVLA Spectral Line Calibration IRC+10216]] leaves off. <br />
<br />
== UV Continuum Subtraction and Setting Up for Self-Calibration==<br />
<br />
[[Image:irc10216_uvspec.png|thumb|UV-plot of the spectral line signal in both spw for IRC+10216.]]<br />
Now we can make a vector averaged uv-plot of the calibrated target spectral line data. It is important to note that you will only see signal in such a plot if (1) the data are well calibrated, and (2) there is significant signal near the phase center of the observations, or if the line emission (or absorption) is weak but extended. If this isn't true for your data, you won't be able to see the line signal in such a plot and will need to make an initial (dirty or lightly cleaned) line+continuum cube to determine the line-free channels. Generally, this is the recommended course for finding the line-free channels more precisely than is being done here due to time constraints, as weak line signal would not be obvious in this plot. <br />
<br />
<source lang="python"><br />
plotms(vis='IRC10216',field='',ydatacolumn='corrected',<br />
xaxis='channel',yaxis='amp',correlation='RR',<br />
avgtime='1e8',avgscan=T,spw='0~1:4~60',antenna='')<br />
</source><br />
<br />
in the Display tab, choose colorize by spw and change the Unflagged points symbol to custom and Style of 3. <br />
<br />
You should see the "horned profile" typical of a rotation shell. From this plot, you can guess that strong <br />
line emission is restricted to channels 18 to 47 (zoom in if necessary to see exactly what the channel numbers are). <br />
<br />
In the Data tab you can also click on "all baselines" to average all baselines, but this is a little harder to see.<br />
<br />
Now we want to use the line free channels to create a model of the continuum emission that can be subtracted to form a line-only dataset. We want to refrain from going to close to the edges of the band -- these channels are typically noisy, and we don't want to get too close to the line channels because we could only see strong line emission in the vector averaged uv-plot.<br />
<br />
<source lang="python"><br />
uvcontsub2(vis='IRC10216',fitspw='0~1:4~13;52~60',<br />
want_cont=T)<br />
</source><br />
<br />
The "want_cont=T" will produce two new datasets, IRC10216.contsub is the continuum subtracted line data, and IRC10216.cont is the continuum estimate (note however, that it is still a multi-channel dataset).<br />
<br />
'''If you want to try self-cal:''' Unfortunately, at the moment, uvcontsub2 doesn't leave the continuum subtracted line dataset in the state you need *if* you think you might want to self-calibrate the data later. This is because {{clean}} always looks at the "corrected" datacolumn, while {{gaincal}} (also used for self-calibration) always looks at the "data" column. You also need to know that unless the imagename supplied to clean already exists, clean always overwrites the model column with the clean model (this will be the model supplied to the self-calibration process).<br />
<pre style="background-color: #E0FFFF;"><br />
The files produced by uvcontsub2 will have the following in their data columns:<br />
Data Model Corrected<br />
IRC10216.contsub Line+Cont Cont Line<br />
IRC10216.cont Cont Cont Cont<br />
</pre><br />
<br />
Now the imaging task {{clean}} will clean both of these files fine, and correctly overwrite the model data column with the correct clean model. However, if you try to self-cal (i.e. run gaincal) on the continuum subtracted line data (.contsub), it will use the Line+Cont as its input along with the line only clean model. If the line and continuum have significantly different morphology (almost always) the self-cal process will fail. In contrast the continuum dataset (.cont) will work fine because the Data and Corrected columns agree. <br />
<br />
To fix things up, we must {{split}} the "corrected" column (which places "Corrected" in the "Data" column of the new dataset. Then you can either run clearcal to reinitialize the "model" and "corrected" columns or let clean do it for you. We put this step here explicitly for clarity about the process.<br />
<br />
<source lang="python"><br />
split(vis='IRC10216.contsub',outputvis='IRC10216.contsub.data')<br />
</source><br />
<source lang="python"><br />
clearcal(vis='IRC10216.contsub.data')<br />
</source><br />
<br />
Now IRC10216.contsub.data will have the Line in the "data" column, 1 in the "model" column, and the Line in the "corrected" column as desired. <br />
<br />
We expect that these extra shenanigans will be unnecessary in the future.<br />
<br />
==Image the Spectral Line Data==<br />
<br />
Here we make images from the continuum-subtracted, calibrated spectral line data. Because the spectral line emission from IRC+10216 has significant extended emission, it is very important to run clean interactively, and make a clean mask. To make the cube a bit smaller and stay away from noisy edge channels we restrict the <br />
channel range using the spw parameter.<br />
[[Image:viewer_interactive.png|thumb|Channel 28 shown for the HC3N cube shown in the interactive viewer with the white contour showing the mask contour drawn with the polygon tool.]]<br />
<br />
<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_HC3N.cube_r0.5',<br />
imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='0:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.39232GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
interactive=T,<br />
threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
It will take a little while to grid the data, but the {{viewer}} will open when it's ready to start an interactive clean. Use the "tape deck" at the bottom of the Viewer display GUI to step through to the channel with the most extended (in angular size) emission, select "all channels" for the clean mask, select the polygon tool (second in from the right) and make a single mask that applies to all channels (see example in thumbnail). Once you make the polygon region, you need to double click inside it to save the mask region -- if you see the polygon turn white you will know you succeeded. Note, that if you had the time and patience you could make a clean mask for each channel, and this would create a slightly better result. <br />
<br />
After making the mask you should check that the emission in all the other channels fits within the mask you made using the "tape deck" to move back and forth. If you need to include more area in the mask, you can chose the "erase" toggle at the top, and then encircle your existing mask with a polygon and double click inside. Then go back to "add" toggle at top and make a new mask. Alternatively, you can erase a part of the mask, or you can add to the existing mask by drawing new polygons. Feel free to experiment with this a bit.<br />
<br />
'''note''': If you start an interactive clean, and then do not make a mask, clean will stop when you tell it to go on because it has nothing to clean. There is no default mask. <br />
<br />
To continue with {{clean}} use the "Next action" buttons in the green area on the Viewer Display GUI: The red X will stop {{clean}} where you are, the blue arrow will stop the interactive part of {{clean}}, but continue to clean non-interactively until reaching the stopping niter or threshold (whichever comes first), and the green arrow will clean until it reaches the "iterations" parameter on the left side of the green area. When <br />
the interactive viewer comes back use the tape deck to recheck that you mask encompasses what you think is real emission. The middle mouse button by default controls the image stretch.<br />
<br />
Note that for this example, threshold has been set to threshold='3mJy' to protect you from cleaning too deeply. With a careful clean mask you can clean to close to the thermal noise limit (note here I mean the actual observed rms noise limit and not the theoretical one you calculated for the proposal, as flagging, weather etc can affect what you actually get). It is ALWAYS best to clean each channel in a cube to a specific threshold than to stop using the niter parameter, which can leave each channel cleaned to different levels. There are many ways to determine a suitable threshold. One way is to make a dirty image (niter=0), open the cube using the viewer, go to a line free channel, select the box region tool, make a box near the field center about the size of your source, double click inside. The rms noise of that channel will appear in a pop-up window (rms noise for whole cube will go to terminal). Try a few different boxes, average the results and this is a good estimate of the rms per channel assuming your data are not dynamic range limited (i.e. noise can be higher in channels with strong signal). This is the absolute minimum for threshold. With no mask you probably shouldn't clean deeper than 3x this rms. <br />
<br />
[[Image:SiS_interactive.png|thumb|Channel 16 shown for the SiS cube in the interactive viewer with the white contour showing the mask contour drawn with the polygon tool.]]<br />
<br />
Keep cleaning, by using the green Next Action arrow until the residual displayed in the viewer looks "noise like". To speed things up, you might change the iteration parameter in the viewer to something like 300. This parameter can also be set in the task command. You will notice that in this particular case, there are residuals that cannot be cleaned -- these are due to the extended resolved out structure on size scales larger than the array is sensitive to (the "Largest Angular Scale" or LAS that the array is sensitive to can be calculated from the shortest baseline length), and potential residual phase and amplitude calibration errors. We will explore this in a few sections with self-calibration. <br />
<br />
Repeat the process for the SiS line using the call below, note that the emission for this line is less extended than the HC3N -- this has to do with the different excitation requirements of the two different lines. The SiS is excited closer to the central star than the HC3N.<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_SiS.cube_r0.5',<br />
imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='1:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.30963GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
interactive=T,<br />
threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
==Image the Continuum data==<br />
<br />
Below the use of mode='mfs' will make a single multi-frequency synthesis image out of the specified spw. Again you should make an interactive clean mask. Since no threshold is set, you will need to stop cleaning when the residual looks noise like using the red x "Next Action" button (it will be done when the viewer comes back the second time).<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.cont',imagename='IRC10216.36GHzcont',<br />
mode='mfs',imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='0~1:5~59',<br />
weighting='briggs',robust=0.5,<br />
interactive=T)<br />
</source><br />
<br />
Now look at the result in the viewer if you like<br />
<br />
<source lang="python"><br />
# In CASA<br />
Viewer<br />
</source><br />
<br />
==Image Analysis and Viewing==<br />
<br />
Next make integrated intensity maps (moment 0) and integrated velocity maps (moment 1). To do this, we'll want to know what channels the line emission starts and ends on, and also the rms noise in a single channel. So first lets open the viewer:<br />
<br />
<source lang="python"><br />
# In CASA <br />
viewer<br />
</source><br />
<br />
Then use the Viewer tape deck to see which channels have significant line emission. For HC3N, the line channel range in the cube is 11 to 40, and it is the same for SiS. <br />
<br />
Then use the tape deck to go to a line free channel, select the box region tool and make a box. When you double click in the box, the image statistics for the whole cube will print to the terminal and for the channel you are on, it will print to a pop up window. Move the box around a bit to see what the variation in rms noise is. You should get something like 2 mJy. Note that the rms is much worse in channels with strong emission because of the low dynamic range of these data. If you want the box tool to go away (i.e. if you want to make a new one), hit the escape key. <br />
<br />
Now lets make the moment 0 and moment 1 maps. For moment zero, its best to limit the calculation to image channels with significant signal in them, but not to apply a flux cutoff, as this will bias the derived integrated intensities upward.<br />
<br />
[[Image:irc10216.jpg|thumb|HC3N moment 0 map with white continuum contours superposed.]]<br />
[[Image:irc10216_sismom0.jpg|thumb|SiS moment 0 map with white continuum contours superposed.]]<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_HC3N.cube_r0.5.image',moments=[0],<br />
axis='spectral',<br />
chans='11~40',<br />
outfile='IRC10216_HC3N.cube_r0.5.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_SiS.cube_r0.5.image',moments=[0],<br />
axis='spectral',<br />
chans='11~40',<br />
outfile='IRC10216_SiS.cube_r0.5.image.mom0')<br />
</source><br />
<br />
For moment 1, it is essential to apply a conservative flux cutoff to limit the calculation to high signal-to-noise areas. Here we use about 5sigma.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_HC3N.cube_r0.5.image',moments=[1],<br />
axis='spectral',<br />
chans='11~40',excludepix=[-100,0.01],<br />
outfile='IRC10216_HC3N.cube_r0.5.image.mom1')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments(imagename='IRC10216_SiS.cube_r0.5.image',moments=[1],<br />
axis='spectral',<br />
chans='11~40',excludepix=[-100,0.01],<br />
outfile='IRC10216_SiS.cube_r0.5.image.mom1')<br />
</source><br />
<br />
Now user the viewer to further explore the images you've made.<br />
<br />
== Self-Calibration ==<br />
<br />
The many different aspects of self-calibration could fill several casaguides. Here we describe a simple process for this particular relatively low S/N data (low S/N per channel at least).<br />
<br />
While running {{clean}} above, the model column for each channel will have been filled with the clean model (if you made a Fourier transform of this model, you would see an image of the clean components). <br />
<br />
We chose to do the self cal on the spw=1 SiS line data because it has the strongest emission in a single channel and is a bit more compact than the HC3N data. We will run {{gaincal}} specifying the channel in the uv-data that has the brightest peak in the image (use the viewer to figure out which channel this is for spw=1). Since we started the image with a channel range we need to account for the fact that the image channel numbers do not map exactly to the uv-data channel numbers (they are off by 5 so that channel 13 in the image is roughly channel 19 in the uv-data). <br />
<br />
Lets explore two options (1) one solution per scan (solint='inf'); and (2) one solution for the whole time range (solint='inf',combine='scan'). Both will be phase-only, as described before, if there are significant phase variations with time you don't want to solve for amplitude before they are tuned up or you risk decorrelation.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='IRC10216.contsub.data',caltable='pcal_ch19one_scan',<br />
spw='1:19~19',calmode='p',solint='inf',combine='',<br />
refant='ea02',minsnr=2.0)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='IRC10216.contsub.data',caltable='pcal_ch19one_all',<br />
spw='1:19~19',calmode='p',solint='inf',combine='scan',<br />
refant='ea02',minsnr=2.0)<br />
</source><br />
<br />
Now lets look at the solutions:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='pcal_ch19one_scan',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-50,50])<br />
</source><br />
<br />
For some antennas you can see clear global trends away from zero: ea08, ea21,ea24 are examples, but most antennas are just noisy and its difficult to see trends with time. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='pcal_ch19one_all',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-50,50])<br />
</source><br />
<br />
Here we can see more clearly that several antennas have clear non-zero average phase solutions. This gives us two clues: (1) self-cal is definitely needed on a few antennas to fix up residual baseline, and delay errors; and (2) we don't quite have enough signal to track the phase variations with time with these low S/N data.<br />
<br />
For now lets explore whether the single global solution actually improves matters. To do this we need to run {{applycal}} to apply the solutions to the line dataset, both spw. We need to use spwmap to tell it that the solutions derived for spw=1 should be applied to both spw=0 and spw=1. Again its important to set calwt=F here.<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='IRC10216.contsub.data',field='',spw='0,1',<br />
gaintable=['pcal_ch19one_all'],spwmap=[[1,1]],calwt=F)<br />
</source><br />
<br />
Now to save time we can use the clean mask we made before and run in a non-interactive mode. You can use a mask over again as long as the number channels in the {{clean}} call haven't changed. You can change cell or imsize and it will still do the right thing.<br />
<br />
<source lang="python"><br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_HC3N.cube_r0.5.selfcal',<br />
imagermode='csclean',<br />
imsize=300,cell=['0.4arcsec'],spw='0:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.39232GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
mask='IRC10216_HC3N.cube_r0.5.mask',<br />
interactive=F,threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='IRC10216.contsub.data',imagename='IRC10216_SiS.cube_r0.5.selfcal',<br />
imagermode='csclean',calready=T,<br />
imsize=300,cell=['0.4arcsec'],spw='1:5~58',<br />
mode='velocity',interpolation='linear',<br />
restfreq='36.30963GHz',outframe='LSRK',<br />
weighting='briggs',robust=0.5,<br />
mask='IRC10216_SiS.cube_r0.5.mask', <br />
interactive=F,threshold='3.0mJy',niter=100000)<br />
</source><br />
<br />
Now investigate the original and self-cal'ed images in the viewer. You will find that even this single self-cal step that averaged over the whole timerange significantly improves the images. <br />
<br />
[[Main Page | &#8629; '''CASAguides''']]<br />
<br />
--[[User:Cbrogan|Crystal Brogan]]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=EVLA_Spectral_Line_Calibration_IRC%2B10216&diff=3672EVLA Spectral Line Calibration IRC+102162010-06-03T19:09:04Z<p>Jgallimo: </p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]][[Category:Spectral Line]]<br />
<br />
<br />
<pre style="background-color: #FFFF00;"><br />
This tutorial is under construction. There are several things still to be added <br />
<br />
For the time being (until release candidate is built) you want to run this on casapy-test<br />
<br />
</pre><br />
<br />
== Overview ==<br />
This tutorial describes the data reduction for two spectral lines observed toward the AGB star IRC+10216. This carbon star, which is a few times more massive than our sun, is nearing the end of its life and is thought to be in the process of forming a planetary nebula. <br />
<br />
In this EVLA OSRO1 mode observation one subband was observed in each of two basebands, the subbands were centered on the HC3N and SiS lines near 36 GHz. The raw data were loaded into CASA with {{importevla}}, where zero and shadowed data were flagged. Then the data were "{{split}}", so we could average from the native 1 second integrations to 10 seconds, select only antennas with Ka-band receivers, and select only spectral windows (called spw in CASA) with Ka-band data. This produces a significantly smaller dataset for processing.<br />
<br />
The post-split averaged data can be downloaded from http://casa.nrao.edu/Data/EVLA/IRC10216/day2_TDEM0003_10s_norx.tar<br />
<br />
Once the download is complete, unpack the file:<br />
<br />
<source lang='bash'><br />
# in a terminal, outside of CASA:<br />
tar -xvf day2_TDEM0003_10s_norx.tar<br />
</source><br />
<br />
== The Observing Log, Antenna Position Corrections, and other Calibration "Priors"==<br />
<br />
For all EVLA observations, the operators keep an observing log. You can look at<br />
the observing logs at the observing log [[http://www.vla.nrao.edu/cgi-bin/oplogs.cgi website]]. Pertinent information from this observation are repeated below. <br />
<pre style="background-color: #E0FFFF;"><br />
INFORMATION FROM OBSERVING LOG:<br />
Date of the observation: 26-April-2010<br />
There are no Ka-band receivers on ea11, ea13, ea14, ea16, ea17, ea18, ea26 <br />
Antennas ea10, ea06 are out of the array<br />
Antenna ea12 is newly back<br />
The pointing is often bad on ea15<br />
Antennas ea10, ea12, ea22 do not have good baseline positions<br />
</pre><br />
<br />
As mentioned in the log, antennas ea10, ea12, and ea22 do not have good baseline positions.<br />
Antenna ea10 was not in the array, but for the other two antennas we need to check for<br />
any improved baseline positions that were derived after the observations were taken.<br />
<br />
In CASA, we need to insert these corrections by hand using '''{{gencal}}'''. The resulting table will need to be supplied as a "prior" calibration to all subsequent calibration steps. The corrections can be ascertained from the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections page]. Be sure to carefully read to the bottom of that <br />
webpage to see how to calculate the additive corrections. The current case is simple as there is only a single correction for each antenna. In the future we will implement an automated lookup of the corrections. <br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='day2_TDEM0003_10s_norx',caltable='antpos.cal',<br />
caltype='antpos',<br />
antenna='ea12,ea22',<br />
parameter=[-0.0072,0.0045,-0.0017, -0.0220,0.0040,-0.0190])<br />
</source><br />
<br />
'''Please note: '''if you are reducing VLA data taken before March 1, 2010, you need to set caltype='antposvla'.<br />
<br />
<br />
<br />
There are two other types of "priors" that we will need to apply at each calibration stage described below:<br />
<br />
(1) Opacity correction -- in the near future the opacity will be calculated from the weather<br />
data and an atmospheric model, or alternatively from a tipping scan, or a combination of<br />
both. For now we use a cannonical value for the zenith opacity based on the weather on that day, which at this<br />
frequency (36 GHz) is about 0.03 on the best days. We will use a zenith opacity of <math>tau_z</math>=0.04. The zenith opacity is then corrected for <br />
the elevation of the data automatically using <math> e^{[-cosec(el)tau_z]}</math>.<br />
<br />
(2) Gaincurve -- the gaincurve describes how each antenna behaves as a function of elevation, for each receiver band. Currently only gaincurves for the VLA/EVLA are available. This option should not be used <br />
with any other telescopes.<br />
<br />
==Initial Inspection and Flagging==<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='day2_TDEM0003_10s_norx')<br />
</source><br />
<br />
Below we have cut and pasted the most relevant output from the logger.<br />
<br />
<pre style="background-color: #fffacd;"><br />
Fields: 4<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
2 D J0954+1743 09:54:56.8236 +17.43.31.2224 J2000 2 65326 <br />
3 NONE IRC+10216 09:47:57.3820 +13.16.40.6600 J2000 3 208242 <br />
5 F J1229+0203 12:29:06.6997 +02.03.08.5982 J2000 5 10836 <br />
7 E J1331+3030 13:31:08.2880 +30.30.32.9589 J2000 7 5814 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (2 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
0 64 TOPO 36387.2295 125 8000 36387.2295 RR RL LR LL <br />
1 64 TOPO 36304.542 125 8000 36304.542 RR RL LR LL <br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1008+0730 0 0.03639232 -0.026 <br />
0 J1008+0730 1 0.03639232 -0.026 <br />
2 J0954+1743 0 0.03639232 -0.026 <br />
2 J0954+1743 1 0.03639232 -0.026 <br />
3 IRC+10216 0 0.03639232 -0.026 <br />
3 IRC+10216 1 0.03639232 -0.026 <br />
5 J1229+0203 0 0.03639232 -0.026 <br />
5 J1229+0203 1 0.03639232 -0.026 <br />
7 J1331+3030 0 0.03639232 -0.026 <br />
7 J1331+3030 1 0.03639232 -0.026 <br />
Antennas: 19:<br />
ID Name Station Diam. Long. Lat. <br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
8 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
9 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
10 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
11 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
12 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
13 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
14 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
15 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
16 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
17 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
18 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
</pre><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Summary of Observing Strategy<br />
Gain Calibrator: J0954+1743 field id=2<br />
Bandpass Calibrator: J1229+0203 field id=5<br />
Flux Calibrator: J1331+3030 (3C286) field id=7<br />
Target: IRC+10216 field id=3<br />
Ka-band spws = 0,1<br />
</pre> <br />
<br />
[[Image:Ant_locations.png|thumb|Antenna locations from running plotants ]]<br />
Look at a graphical plot of the antenna locations and save hardcopy<br />
in case you want it later. This will be useful for picking a reference antenna --<br />
typically a good choice is an antenna close to the center of the array. Unless it <br />
shows problems after inspection of the data, we provisionally chose ea02.<br />
<br />
[[Image:elevationvstime.png|thumb|Elevation as a function of time (after selecting colorize by field).]]<br />
<source lang="python"><br />
# In CASA<br />
plotants(vis='day2_TDEM0003_10s_norx',figfile='ant_locations.png')<br />
</source><br />
<br />
Next, let's look at the elevation as a function of time for all sources. It's not the case for these data, but if the elevation is very low (usually at start or end of track) you may want to flag. Also, how near in elevation your flux calibrator is to your target will impact your ultimate absolute flux calibration accuracy. Unfortunately, the target and flux calibrator are not particularly well-matched for this observation, as y ou can show by plotting the elevation for each source:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',<br />
xaxis='time',yaxis='elevation',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60')<br />
</source><br />
<br />
Thus we are strongly dependent on the opacity and gaincurve corrections to get the flux scale right for these data. (This is something to keep in mind when planning observations!)<br />
<br />
[[Image:plotallfields.png|thumb|Result of plotms after selecting colorize by field]]<br />
[[Image:Zoom1_mark.png|thumb|Zooming in and marking region (hatched box)]]<br />
<br />
Next,let's look at all the source amplitudes as a function of time.<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60')<br />
</source><br />
<br />
Select the "Display" tab and colorize by field, and click Plot button. <br />
<br />
<br />
Now zoom in on the region very near zero amplitude for sources J0954+1743 and IRC+10216. To zoom, select the <br />
Zoom tool in lower left corner of the {{plotms}} GUI, then you can left click to draw a box. <br />
Look for the low values (you may want to zoom a few times to really see the suspect points clearly). Now use the Mark Region and Locate buttons (located along the bottom of the GUI) to see which antenna is causing problems. Since all the "located" baselines include ea12, this is the responsible antenna.<br />
<br />
<pre style="background-color: #98FB98;"><br />
IMPORTANT NOTES ON PLOTMS:<br />
<br />
* When using the locate button it is important to have only selected a modest number <br />
of points with the mark region tool (see example of marked region in the thumnail), <br />
otherwise the response will be very slow and possibly hang the tool <br />
(all of the information will be output to your terminal window, not the logger). <br />
<br />
* Throughout the tutorial, when you are done marking/locate use the Clear Regions <br />
tool to get rid of the marked box before plotting other things. <br />
<br />
* After flagdata command flagging, you have to force a complete reload of the cache <br />
to look at the same plot again with the new flags applied. To do this change anything <br />
in the plotms GUI (the colorize parameter, antenna, spw, anything) and hit the <br />
plot button.<br />
<br />
* If the plotms tool does get hung during a plot try clicking the cancel button on the <br />
load progress GUI, and/or if you see a "table locked" message try typing <br />
clearstat on the CASA command line.<br />
<br />
* Occasionally plotms will get into a strange state that you cannot clear from inside. <br />
We are working on these issues, but for now, when all else fails, exit from casapy and <br />
restart. <br />
<br />
</pre> <br />
<br />
Now click the unmark region button, and then go back to the zoom button to zoom in further to note exactly what the time range is: 03:41:00~04:10:00.<br />
<br />
Check the other sideband by changing spw to 1:4~60. You will have to<br />
rezoom. If you have trouble, click on the Mark icon and then back to<br />
zoom. In spw=1, ea07 is bad from the beginning until after next<br />
pointing run: 03:21:40~04:10:00. To see this, compare the amplitudes when antenna is set to 'ea07' and when it is set to one of the other antennas, such as 'ea08'.<br />
<br />
If you set antenna to 'ea12' and zoom in on this intial timerange, you can also see that ea12 is bad during the same time range as for spw 0. You can also see this by entering '!ea07' for antenna, which removes ea07 from the plot (in CASA selection, ! deselects). <br />
<br />
We can set up a flagging command to get both bad antennas for the<br />
appropriate time and spw:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='day2_TDEM0003_10s_norx',<br />
field=['2,3','2,3'],<br />
spw=['','1'],<br />
antenna=['ea12','ea07'],<br />
timerange=['03:41:00~04:10:00','03:21:40~04:10:00'])<br />
</source><br />
<br />
Note that because the chosen timerange is limited to fields 2 and 3,the field parameter is not really<br />
needed; however, flagdata will run fastest if you put as many constraints as possible.<br />
<br />
Now remove the !ea07 from antenna and replot both spw, zooming in to<br />
be sure that all obviously low points are gone. Also zoom in and<br />
check 3C286 (J1229+0203 is already obvious because it is so bright!). <br />
<br />
[[Image:IRC10216_uvdist1.png|thumb|Amplitude vs. uv-distance for IRC+10216, both spw (after colorize by spw)]]<br />
<br />
Lets look more closely at IRC+10216:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0~1:4~60')<br />
</source><br />
<br />
Go to the "display" tab and choose colorize by spw. You can see a<br />
that there are some noisy high points. But now try<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0~1:4~60')<br />
</source><br />
<br />
Most of the high points on IRC+10216 are due to large scale emission on short baselines, but there is still some noisy stuff -- for a target like this with extended emission its best to wait until later to decide what to do about it. We will not be able to get adequate calibration for antennas that are truly bad (even if they don't stand out here) so these will be obvious later.<br />
<br />
==Setup the Model for the Flux Calibrator==<br />
<br />
Next, we set the model for the flux calibrator. Depending on your observing frequency and angular resolution you can do this several ways. In the past, one typically used a point source (constant flux) model for <br />
the flux calibrator, possibly with a uvrange cutoff if necessary. More recently for the VLA/EVLA, model images for the most common flux calibrators have been made available for use in cases where the sources are somewhat resolved. This is most likely to be true at higher frequencies and at higher resolutions (more extended arrays). Thus below we use the K-band model image for these Ka-band observations. Because one model image is typically available per receiver band (in this case the model for Ka-band is the same as that of K-band), the frequency of the model image probably does not match exactly the frequency of your observations, as is certainly the case here. In that case, the task scales the total flux in the model image to that appropriate for your observing frequency according to the calibrators flux as a function of frequency model, and reports this number in the logger -- it is a good idea to save this information for your records.<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='day2_TDEM0003_10s_norx',field='7',spw='0~1',<br />
modimage='/usr/lib64/casapy/data/nrao/VLA/CalModels/3C286_K.im')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
The logger output for each spw is:<br />
setjy J1331+3030 spwid= 0 [I=1.692, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
setjy J1331+3030 spwid= 1 [I=1.695, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)<br />
</pre><br />
<br />
The modimage location used in the command is appropriate for running CASA at the AOC. If you are running elsewhere (laptop or Mac), in a terminal type<br />
<br />
<source lang='bash'><br />
# in a terminal, outside of CASA:<br />
locate 3C286_K.im <br />
</source><br />
<br />
to find where the models live (the models are always shipped with CASA).<br />
<br />
==Bandpass==<br />
<br />
Before determining the bandpass solution, we need to inspect phase and amplitude<br />
variations with time and frequency on the bandpass calibrator to<br />
decide how best to proceed. We limit the number of antennas to make<br />
the plot easier to see. We chose ea02 as it seems like a good<br />
candidate for the reference antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='phase',correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02&ea23')<br />
</source><br />
[[Image:Nobandpass_phase.png|thumb|Phase as a function of channel for ea02 (after colorize by Antenna2, and Custom and upping "Style" to 3.)]]<br />
The phase variation is modest ~10 degrees. Now expand to all antennas with ea02 and <br />
select colorize by Antenna2, then hit the "Plot" button.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='phase',correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02')<br />
</source><br />
[[Image:Nobandpass_phasetime.png|thumb|Phase as a function of time for all baselines with antenna ea02 (after colorize by Antenna2, and Custom and upping "Style" to 3.)]]<br />
Go to the "display" tab and chose colorize by antenna2. From this<br />
you can see that the phase variation across the bandpass is<br />
modest. Next check LL, and spw=1, both correlations. Also check<br />
other antennas if you like.<br />
<br />
Now look at the phase as a function of time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='time',yaxis='phase',correlation='RR',<br />
avgchannel='64',spw='0:4~60',antenna='ea02&ea23')<br />
</source><br />
<br />
<br />
Expand to all antennas with ea02<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='time',yaxis='phase',correlation='RR',<br />
avgchannel='64',spw='0:4~60',antenna='ea02')<br />
</source><br />
<br />
Go to the "display" tab and chose colorize by antenna2, you may also want to select "Custom" under "unflagged points symbol" and then change Style from "2" to "3".<br />
<br />
You can see that the phase variations are smooth, but do vary<br />
significantly over the 5 minutes of observation -- in most cases by<br />
a few 10s of degrees. Zoom in to see this better if you want.<br />
<br />
The conclusion from this investigation is that you need to correct<br />
the phase variations with time before solving for the bandpass to<br />
prevent decorrelation of the vector averaged bandpass<br />
solution. Since the phase variation as a function of channel is<br />
modest, you can average over several channels to increase the signal<br />
to noise of the phase vs. time solution. If the phase variation as a<br />
function of channel is larger you may need to use only a few<br />
channels to prevent introducing delay-based closure errors as can happen from averaging over<br />
non-bandpass corrected channels with large phase variations.<br />
<br />
<br />
Since the bandpass calibrator is quite strong we do the phase-only<br />
solution on the integration time of 10 seconds (solint='int').<br />
<br />
[[Image:Prebp_phasecal2.png|thumb|Phase only calibration before bandpass. The 4 lines are both polarizations in both spw, unfortunately two of them get the same color green at the moment.]]<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='bpphase.gcal',<br />
field='5',spw='0~1:20~40',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
gaintable=['antpos.cal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
Plot the solutions<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='bpphase.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
These solutions will appear in the CASA plotter gui. If you closed it after plotting the antennas above, it should reopen. If it is still open from before, the new plots should just appear. After you are done looking at the first set of plots, push the "Next" button on the GUI to see the next set of antennas.<br />
<br />
Next we can apply this phase solution on the fly while determining<br />
the bandpass solutions on the timescale of the bandpass calibrator scan (solint='inf'). <br />
<br />
[[Image:Bandpass_amp.png|thumb|Amplitude Bandpass solutions]]<br />
[[Image:Bandpass_phase1.png|thumb|Phase Bandpass solutions]]<br />
<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='day2_TDEM0003_10s_norx',caltable='bandpass.bcal',field='5',<br />
refant='ea02',solint='inf',solnorm=T,<br />
gaintable=['antpos.cal','bpphase.gcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
'''A few words about solint and combine:'''<br />
<br />
The use of solint='inf' in {{bandpass}} will derive one bandpass<br />
solution for the whole J1229+0203 scan. Note that if there had been two observations of the bandpass calibrator (for example), this command would have combined the data from both scans to form one bandpass solution, because the default of the combine parameter '''for {{bandpass}}''' is combine='scan'. To solve for one bandpass for each bandpass calibrator scan you would also need to include combine='''' '''' in the bandpass call. In all calibration tasks, regardless of solint, scan boundaries are only crossed when combine='scan'. Likewise, field (spw) boundaries are only crossed if combine='field' (combine='spw'), the latter two are not generally good ideas for bandpass solutions. <br />
<br />
Plot the solutions, amplitude and phase:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='bandpass.bcal',xaxis='chan',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='bandpass.bcal',xaxis='chan',yaxis='phase',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
Note that phases on ea12 look noiser than on other antennas. This<br />
jitter could indicate bad pointing; note that ea12 had just come back in<br />
the array.<br />
<br />
This step isn't necessary from a calibration perspective, but if you<br />
want to go ahead and check the bandpass calibration on the bandpass<br />
calibrator you can run applycal here. In future we hope to plot<br />
corrected data on-the-fly without this applycal step. Later applycals<br />
will overwrite this one, so no need to worry.<br />
<br />
[[Image:Applybandpass_phase.png|thumb|Phase as a function of channel, plotting the corrected data (after colorize by Antenna2, and Custom and upping "Style" to 3.)]]<br />
<br />
<source lang="python"><br />
applycal(vis='day2_TDEM0003_10s_norx',field='5',<br />
gaintable=['antpos.cal','bandpass.bcal'],<br />
spwmap=[[]],gainfield=['','5'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02')<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
correlation='RR',<br />
avgtime='1e8',spw='0:4~60',antenna='ea02')<br />
</source><br />
<br />
Note that the phase and amplitude as a function of channel are very flat now.<br />
<br />
==Gain Calibration==<br />
<br />
Now that we have a bandpass solution to apply we can solve for the antenna-based phase and amplitude gain calibration. Since the phase changes on a much shorter timescale than the amplitude, we will solve for them separately. In particular, if the phase changes significantly over a scan time, the amplitude would be decorrelated, if the un-corrected phase were averaged over this timescale. Note that we re-solve for the gain solutions of the bandpass calibrator, so we can derive new solutions that are corrected for the bandpass shape. Since the bandpass calibrator will not be used again, this is not strictly necessary, but is useful to check its calibrated flux density for example.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='intphase.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
[[Image:allcal_phaseint2.png|thumb|Plot of phase solutions on an integration time.]]<br />
<br />
Here solint='int' coupled with calmode='p' will derive a single phase solution for each 10 second integration. Note that the bandpass table is applied on-the-fly before solving for the phase solutions, however the bandpass is NOT applied to the data permanently until applycal is run later on.<br />
<br />
Note that quite a few solutions are rejected due to SNR<2 (printed to terminal). For the most part it <br />
is only one or two solutions out of >30 so this isn't too worrying. Take note if you see large numbers of rejected solutions per integration. This is likely an indication that solint is too short for the S/N of the data.<br />
<br />
Now look at the phase solution, and note the obvious scatter within a scan time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='intphase.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
Although solint='int' (i.e. the integration time of 10 seconds) is the best choice to apply before for solving for the amplitude solutions, it is not a good idea to use this to apply to the target. This is because the phase-scatter within a scan can dominate the interpolation between calibrator scans. Instead, we also solve for the phase on the scan time, solint='inf' (but combine='''' '''', since we want one solution per scan) for application to the target later on. '''Unlike the bandpass task,''' for gaincal, the default of the combine parameter is combine='''' ''''.<br />
[[Image:allcal_phaseinf2.png|thumb|Plot of phase solutions on a scan time.]]<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='scanphase.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='scanphase.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331,plotrange=[0,0,-180,180])<br />
</source><br />
<br />
Note that there are no failed solutions here because of the added S/N afforded by the longer solint.<br />
Alternatively, instead of making a separate phase solution for application to the target, one can also run {{smoothcal}} to smooth the solutions derived on the integration time.<br />
<br />
Next we apply the bandpass and solint='int' phase-only calibration solutions on-the-fly to derive amplitude solutions. <br />
Here the use of solint='inf', but combine='''' '''' will result in one solution per scan interval.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='amp.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='ap',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal'],spwmap=[[],[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
[[Image:allcal_ampphase.png|thumb|Plot of residual phase solutions on a scan time]]<br />
<br />
Now let's look at the resulting phase solutions. Since we have taken out the phase as best we can by applying the solint='int' phase-only solution, this plot will give a good idea of the residual phase error. If you see scatter of more than a few degrees here, you should consider going back and looking for more data to flag, particularly bad timeranges etc.<br />
<br />
<source lang="python"><br />
# In CASA <br />
plotcal(caltable='amp.gcal',xaxis='time',yaxis='phase',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
Indeed, both antenna ea12 (all times) and ea23 (first 1/3 of observation) show particularly large residual phase noise.<br />
[[Image:allcal_amp.png|thumb|Plot of amplitude solutions on a scan time]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='amp.gcal',xaxis='time',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
Note that the amplitude solutions for ea12 are very low; this is another indication that this antenna is dubious.<br />
<br />
Next we use the flux calibrator (whose flux density was set in {{setjy}} above) to derive the flux of the other calibrators. Note that the flux table REPLACES the amp.gcal in terms of future application of the calibration to the data, i.e. the flux table contains both the amp.gcal and flux scaling. Unlike the gain calibration steps, this is not an incremental table. <br />
<br />
<source lang="python"><br />
# In CASA<br />
fluxscale(vis='day2_TDEM0003_10s_norx',caltable='amp.gcal',<br />
fluxtable='flux.cal',reference='7')<br />
</source><br />
<br />
[[Image:allcal_flux.png|thumb|Plot of flux corrected amplitude solutions.]]<br />
It is a good idea to note down for your records the derived flux densities:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Flux density for J0954+1743 in SpW=0 is: 0.225863 +/- 0.000817704 <br />
(SNR = 276.217, nAnt= 19)<br />
Flux density for J0954+1743 in SpW=1 is: 0.235866 +/- 0.000604897 <br />
(SNR = 389.928, nAnt= 19)<br />
Flux density for J1229+0203 in SpW=0 is: 25.248 +/- 0 <br />
(SNR = inf, nAnt= 19)<br />
Flux density for J1229+0203 in SpW=1 is: 25.008 +/- 0 <br />
(SNR = inf, nAnt= 19)<br />
<br />
</pre><br />
<br />
Obviously, the signal-to-noise for J1229+0203 can't be infinity! This is just an indication that their is only one scan for this source, and we derived a scan based amplitude solution, so there is no variation to calculate. <br />
<br />
Next, check that the flux.cal table looks as expected.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='flux.cal',xaxis='time',yaxis='amp',<br />
iteration='antenna',subplot=331)<br />
</source><br />
<br />
==Applycal and Inspect==<br />
<br />
Now we apply the calibration to each source, according to which tables are appropriate, and which source should be used to do that particular calibration. For the calibrators, all bandpass solutions come from the bandpass calibrator (id=5), and the phase and amplitude calibration comes from their own solutions. <br />
<br />
'''Note:''' In applycal we set calwt=F. It is very important to turn off this parameter which determines if the weights are calibrated along with the data. Data from antennas with better receiver performance and/or longer integration times should have higher weights, and it can be advantageous to factor this information into the calibration. During the VLA era, meaningful weights were available for each visibility. However, EVLA is not yet recording the information necessary to calculate meaningful weights. Since these data weights are used at the imaging stage you can get strange results from having calwt=T when the input weights are themselves not meaningful, especially for self-calibration on resolved sources (your flux calibrator and target for example). In a few months EVLA data will again have meaningful weights and the default calwt=T will likely again be the best option.<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='2',<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='5',<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','5','5'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='7',<br />
gaintable=['antpos.cal','bandpass.bcal','intphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','7','7'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
For the target we apply the bandpass from id=5, and the calibration from the gain calibrator (id=2):<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='3',<br />
gaintable=['antpos.cal','bandpass.bcal','scanphase.gcal','flux.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
Now inspect the corrected data:<br />
[[Image:applycal_inspect.png|thumb|Plot of calibrated amplitudes over time.]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='5',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='')<br />
</source><br />
<br />
This plot shows some data deviating from the average amplitudes. Use methods described above to <br />
mark a region for a small number of deviant data points, and click "Locate". You will find that ea12 is responsible.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='')<br />
</source><br />
<br />
Here we see some problems, with high points. Mark some regions<br />
and locate in {{plotms}} to find out which antennas and in which spws. Pay special<br />
attention to antennas that have been called out already as showing some dubious behavior.<br />
<br />
What you find is that ea07 which we flagged spw=1 above, is also bad for the same timerange in spw=0. This was not obvious in the raw data, because spw=0 was adjusted in the on-line system by a gain attenuator, while spw=1 wasn't. So a lack of power on this antenna can look like very low (and obvious) amplitudes in spw=1 but not for spw=0. Looking carefully you'll see that ea07 is actually pretty noisy throughout.<br />
[[Image:ea12.png|thumb|Plot of antenna ea12 by itself]]<br />
[[Image:ea23.png|thumb|Plot of antenna ea23 by itself]]<br />
<br />
From the locate we also find that ea12 and ea23 show some high points; to see this, replot baselines using each of them alone:<br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='ea12')<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='ea23')<br />
</source><br />
<br />
ea12 needs to be flagged completely its just a bit noisy all around and ea23 is pretty noisy during the first scans between initial and second pointing. Recall that these are antennas we became suspicious of while inspecting the calibration solutions.<br />
<br />
[[Image:target_uvdist.png|thumb|IRC+12216 as a function of uv-distance (after colorize by Antenna2).]]<br />
Now lets see how the target looks. Because the target has resolved structure, its best to look at it as<br />
a function of uvdistance. We'll go ahead and exclude the three antennas we already know have problems.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='!ea07;!ea12;!ea23')<br />
</source><br />
<br />
in "display" tab choose colorize by antenna2; then you can see that the spikes<br />
are caused by a single antenna. Use, zoom, mark, and locate to see which one.<br />
Also look at spw=1.<br />
<br />
Turns out to be ea28; to confirm, replot with antenna=!ea28, and<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='!ea07;!ea12;!ea23;!ea28')<br />
</source><br />
<br />
To see if it's restricted to a certain time<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='ea28')<br />
</source><br />
<br />
<br />
Baselines with ea28 clearly show issues until about two-thirds of the way through the observation. <br />
Plot another distant antenna to compare. We will go ahead and flag it all, since its hanging far out on the north<br />
arm by itself.<br />
<br />
The additional data we've identified as bad need to be flagged, and then all the calibration steps will need to be run<br />
again.<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='day2_TDEM0003_10s_norx',<br />
field=['',''],<br />
spw=['',''],<br />
antenna=['ea07,ea12,ea28','ea07,ea23'],<br />
timerange=['','03:21:40~04:10:00'])<br />
</source><br />
<br />
==Redo Calibration after more Flagging==<br />
<br />
After flagging, you'll need to repeat the calibration steps above. Here, we append _redo to the table names to distinguish them from the first round, in case we want to compare with previous versions. <br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='bpphase_redo.gcal',<br />
field='5',spw='0~1:20~40',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='day2_TDEM0003_10s_norx',caltable='bandpass_redo.bcal',<br />
field='5',<br />
refant='ea02',solint='inf',solnorm=T,<br />
gaintable=['bpphase_redo.gcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='intphase_redo.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='int',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass_redo.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='scanphase_redo.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='p',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass_redo.bcal'],spwmap=[[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='day2_TDEM0003_10s_norx',caltable='amp_redo.gcal',<br />
field='2,5,7',spw='0~1:4~60',<br />
refant='ea02',calmode='ap',solint='inf',minsnr=2.0,<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal'],<br />
spwmap=[[],[]],<br />
opacity=0.04,gaincurve=T)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA <br />
fluxscale(vis='day2_TDEM0003_10s_norx',caltable='amp_redo.gcal',<br />
fluxtable='flux_redo.cal',reference='7')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
Flux density for J0954+1743 in SpW=0 is: 0.235345 +/- 0.000879422 <br />
(SNR = 267.613, nAnt= 16)<br />
Flux density for J0954+1743 in SpW=1 is: 0.241996 +/- 0.000930228 <br />
(SNR = 260.147, nAnt= 16)<br />
Flux density for J1229+0203 in SpW=0 is: 25.2479 +/- 0 <br />
(SNR = inf, nAnt= 16)<br />
Flux density for J1229+0203 in SpW=1 is: 24.9907 +/- 0 <br />
(SNR = inf, nAnt= 16)<br />
</pre><br />
<br />
Feel free to pause here and remake the calibration solution plots from above, just be sure to put in the revised table names.<br />
<br />
==Redo Applycal and Inspect==<br />
<br />
Now, apply all the new calibrations, which will overwrite the old ones. These commands are identical to those above, with the exception of the _redo part of each calibration filename.<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='2',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='5',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','5','5'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
[[Image:gaincal_corrflag.png|thumb|Gain calibrator after further flagging and recalibration]]<br />
[[Image:target_corrflag.png|thumb|IRC+10216 after further flagging and recalibration (after selecting colorize by spw).]]<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='7',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','intphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','7','7'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='day2_TDEM0003_10s_norx',field='3',<br />
gaintable=['antpos.cal','bandpass_redo.bcal','scanphase_redo.gcal','flux_redo.cal'],<br />
spwmap=[[]],gainfield=['','5','2','2'],<br />
opacity=0.04,gaincurve=T,calwt=F)<br />
</source><br />
<br />
Now you can inspect the calibrated data again. Except for random scatter things look pretty good.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='2',ydatacolumn='corrected',<br />
xaxis='time',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0:4~60',antenna='')<br />
</source><br />
<br />
Lets check the target again, looking at both spws, and selecting "Display" colorize by spw. You can use the Mark and Locate buttons to assess that the remaining scatter seems random, i.e. no particular antenna or time range appears to be responsible.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='day2_TDEM0003_10s_norx',field='3',ydatacolumn='corrected',<br />
xaxis='uvdist',yaxis='amp',correlation='RR,LL',<br />
avgchannel='64',spw='0~1:4~60',antenna='')<br />
</source><br />
<br />
==Split==<br />
<br />
Now we split the data into individual files. This is not strictly necessary, as you can select the appropriate fields in later clean stages, but it is safer in case for example you get confused with later processing and want to fall back to this point (this is especially a good idea if you plan to do continuum subtraction or self calibration later on). It also makes smaller individual files in case you want to copy to another machine or colleague.<br />
<br />
Here, we split off the data for the phase calibrator and the target:<br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='day2_TDEM0003_10s_norx',outputvis='J0954',<br />
field='2')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
split(vis='day2_TDEM0003_10s_norx',outputvis='IRC10216',<br />
field='3')<br />
</source><br />
<br />
To reinitialize the scratch columns for use by later tasks, we need to run clearcal for both new datasets<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='J0954')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
clearcal(vis='IRC10216')<br />
</source><br />
<br />
This concludes the calibration phase of the data reductions. The tutorial continues with continuum subtraction, imaging, and image analysis in <br />
[[EVLA Spectral Line Imaging Analysis IRC+10216]].<br />
<br />
[[Main Page | &#8629; '''CASAguides''']]<br />
<br />
--[[User:Cbrogan|Crystal Brogan]]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Widefield&diff=3671Template:Widefield2010-06-03T19:02:04Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/widefield-task.html widefield]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/widefield-task.html widefield]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Visstat&diff=3670Template:Visstat2010-06-03T19:00:20Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/visstat-task.html visstat]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/visstat-task.html visstat]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Vishead&diff=3669Template:Vishead2010-06-03T18:59:57Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/vishead-task.html vishead]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/vishead-task.html vishead]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Viewer&diff=3668Template:Viewer2010-06-03T18:59:35Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/viewer-task.html viewer]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/viewer-task.html viewer]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Viewerconnection&diff=3667Template:Viewerconnection2010-06-03T18:59:19Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/viewerconnection-task.html viewerconnection]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/viewerconnection-task.html viewerconnection]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Uvsub&diff=3666Template:Uvsub2010-06-03T18:58:42Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/uvsub-task.html uvsub]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/uvsub-task.html uvsub]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Uvmodelfit&diff=3665Template:Uvmodelfit2010-06-03T18:58:23Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/uvmodelfit-task.html uvmodelfit]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/uvmodelfit-task.html uvmodelfit]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Uvcontsub&diff=3664Template:Uvcontsub2010-06-03T18:58:04Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/uvcontsub-task.html uvcontsub]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/uvcontsub-task.html uvcontsub]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Uvcontsub2&diff=3663Template:Uvcontsub22010-06-03T18:57:45Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/uvcontsub2-task.html uvcontsub2]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/uvcontsub2-task.html uvcontsub2]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Specfit&diff=3662Template:Specfit2010-06-03T18:57:00Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/specfit-task.html specfit]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/specfit-task.html specfit]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Smoothcal&diff=3661Template:Smoothcal2010-06-03T18:56:41Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/smoothcal-task.html smoothcal]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/smoothcal-task.html smoothcal]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Simdata&diff=3660Template:Simdata2010-06-03T18:56:21Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/simdata-task.html simdata]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/simdata-task.html simdata]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Setjy&diff=3659Template:Setjy2010-06-03T18:55:51Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/setjy-task.html setjy]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/setjy-task.html setjy]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Sdtpimaging&diff=3658Template:Sdtpimaging2010-06-03T18:55:24Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/sdtpimaging-task.html sdtpimaging]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/sdtpimaging-task.html sdtpimaging]</div>Jgallimohttps://casaguides.nrao.edu/index.php?title=Template:Sdstat&diff=3657Template:Sdstat2010-06-03T18:54:53Z<p>Jgallimo: Created page with '[http://casa.nrao.edu/docs/taskref/sdstat-task.html sdstat]'</p>
<hr />
<div>[http://casa.nrao.edu/docs/taskref/sdstat-task.html sdstat]</div>Jgallimo