https://casaguides.nrao.edu/api.php?action=feedcontributions&user=Jlazio&feedformat=atomCASA Guides - User contributions [en]2024-03-28T19:50:29ZUser contributionsMediaWiki 1.38.6https://casaguides.nrao.edu/index.php?title=Create_a_Simulated_Image&diff=4542Create a Simulated Image2011-02-12T06:26:23Z<p>Jlazio: </p>
<hr />
<div>This topic is closely related to [[Create a Component List for Selfcal]], but it is given a separate category in hopes that it will also help people find this more general topic.<br />
<br />
There are at least two reasons that one would want to create a simulated image.<br />
1. One wants to start with a particular sky model for self-calibration. In this case, the topic [[Create a Component List for Selfcal]] may suffice.<br />
2. One wants to perform statistical tests on an image. In the particular case that motivated this document, I was attempting to assess whether I could believe weak sources within an image. In my case, CLEAN bias was not an issue, but there are instances in which it may be.<br />
<br />
Assume that there is an image <code>mysrc.image</code> and the corresponding sky model <code>mysrc.model</code>, that has been imaged from the corresponding Measurement Set <code>mysrc.ms</code>. First, presumably one does not want to work on the actual sky model, but one wants to conduct the test on a derivative file. Outside of CASA, <code>cp -r mysrc.model mysrc.test</code> creates a new sky model that is initially identical to the true sky model. In this example, only a single "fake" source will be added, but the extension to multiple sources is straightforward.<br />
<br />
For the purposes that motivated this test, I wanted to add weak sources to the visibility data to determine if I could detect them reliably. Thus, I used <code>immath</code> to maintain the image header, but zero out all of the values in the image.<br />
<br />
<source lang="python"><br />
mysrc = 'NGC4536'<br />
<br />
imgname = mysrc + '.image'<br />
newimgname = mysrc + '.add'<br />
<br />
# create a new blank image<br />
immath(imagename=imgname,outfile=newimgname,<br />
mode='evalexpr',expr='IM0*0.0')<br />
</source><br />
<br />
After this step, the image NGC4536.add is identically zero, but has the same header (coordinate system, pointing direction, etc.) as the original file.<br />
<br />
Now, a component list is created and associated with that file. The component list is created using the <code>addcomponent</code> part of the toolkit; eventually, it may be possible to use the <code>asciitocomponentlist</code> part of the toolkit to do this for multiple sources simultaneously.<br />
<br />
<br />
<source lang="python"><br />
cl.open()<br />
cl.addcomponent(flux=1.25, fluxunit='mJy', polarization='Stokes',<br />
dir='J2000 19h30m00 15d00m00', shape='gaussian', majoraxis='10arcsec',<br />
minoraxis='6arcsec', positionangle='0deg', freq='1.25GHz',<br />
spectrumtype='spectral index', index=-0.8)<br />
### you can add more components if you wish by calling addcomponent<br />
### repeatedly with different params<br />
</source><br />
See [[http://casa.nrao.edu/docs/casaref/componentlist.addcomponent.html#x246-2450001.1.5]] for the full list of options to <code>addcomponent</code>.<br />
<br />
If desired, one can save the component list to disk, which would allow it to be viewed or used later.<br />
<source lang="python"><br />
##save it to disk<br />
cl.rename('my_1_component.cl')<br />
</source><br />
<br />
Now the components are added to the image, and everything is closed up.<br />
<br />
<source lang="python"><br />
ia.open(newimgname)<br />
ia.modify(cl.torecord())<br />
<br />
cl.close()<br />
cl.done()<br />
ia.close()<br />
</source><br />
<br />
The next step is to add these weak sources into the MODEL column of the Measurement Set. There are two ways to do this using <code>ft</code>, one using the image, the other the component list:<br />
<source lang="python"><br />
ft(vis='myms', complist='my_1_component.cl')<br />
</source><br />
or<br />
<source lang="python"><br />
ft(vis='myms', model=newimgname)<br />
</source><br />
<br />
The final step is the addition of these weak sources to the visibility data, by <code>uvsub<code>:<br />
<source lang="python"><br />
uvsub(vis='myms',reverse=True)<br />
</source><br />
<br />
At this point, the visibility data has a weak source(s) added to it. One can now test whether it can be recovered reliably.<br />
<br />
<br />
<br />
YMMV.<BR><br />
TJWL</div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Create_a_Simulated_Image&diff=4541Create a Simulated Image2011-02-12T06:25:46Z<p>Jlazio: Create a simulated image for the purposes of testing image statistics, self-calibration, etc.</p>
<hr />
<div>This topic is closely related to [[Create a Component List for Selfcal]], but it is given a separate category in hopes that it will also help people find this more general topic.<br />
<br />
There are at least two reasons that one would want to create a simulated image.<br />
1. One wants to start with a particular sky model for self-calibration. In this case, the topic [[Create a Component List for Selfcal]] may suffice.<br />
2. One wants to perform statistical tests on an image. In the particular case that motivated this document, I was attempting to assess whether I could believe weak sources within an image. In my case, CLEAN bias was not an issue, but there are instances in which it may be.<br />
<br />
Assume that there is an image <code>mysrc.image</code> and the corresponding sky model <code>mysrc.model</code>, that has been imaged from the corresponding Measurement Set <code>mysrc.ms</code>. First, presumably one does not want to work on the actual sky model, but one wants to conduct the test on a derivative file. Outside of CASA, <code>cp -r mysrc.model mysrc.test</code> creates a new sky model that is initially identical to the true sky model. In this example, only a single "fake" source will be added, but the extension to multiple sources is straightforward.<br />
<br />
For the purposes that motivated this test, I wanted to add weak sources to the visibility data to determine if I could detect them reliably. Thus, I used <code>immath</code> to maintain the image header, but zero out all of the values in the image.<br />
<br />
<source lang="python"><br />
mysrc = 'NGC4536'<br />
<br />
imgname = mysrc + '.image'<br />
newimgname = mysrc + '.add'<br />
<br />
# create a new blank image<br />
immath(imagename=imgname,outfile=newimgname,<br />
mode='evalexpr',expr='IM0*0.0')<br />
</source><br />
<br />
After this step, the image NGC4536.add is identically zero, but has the same header (coordinate system, pointing direction, etc.) as the original file.<br />
<br />
Now, a component list is created and associated with that file. The component list is created using the <code>addcomponent</code> part of the toolkit; eventually, it may be possible to use the <code>asciitocomponentlist</code> part of the toolkit to do this for multiple sources simultaneously.<br />
<br />
<br />
<source lang="python"><br />
cl.open()<br />
cl.addcomponent(flux=1.25, fluxunit='mJy', polarization='Stokes',<br />
dir='J2000 19h30m00 15d00m00', shape='gaussian', majoraxis='10arcsec',<br />
minoraxis='6arcsec', positionangle='0deg', freq='1.25GHz',<br />
spectrumtype='spectral index', index=-0.8)<br />
### you can add more components if you wish by calling addcomponent<br />
### repeatedly with different params<br />
</source><br />
See [[http://casa.nrao.edu/docs/casaref/componentlist.addcomponent.html#x246-2450001.1.5]] for the full list of options to <code>addcomponent</code>.<br />
<br />
If desired, one can save the component list to disk, which would allow it to be viewed or used later.<br />
<source lang="python"><br />
##save it to disk<br />
cl.rename('my_1_component.cl')<br />
</source><br />
<br />
Now the components are added to the image, and everything is closed up.<br />
<br />
<source lang="python"><br />
ia.open(newimgname)<br />
ia.modify(cl.torecord())<br />
<br />
cl.close()<br />
cl.done()<br />
ia.close()<br />
</source><br />
<br />
The next step is to add these weak sources into the MODEL column of the Measurement Set. There are two ways to do this using <code>ft</code>, one using the image, the other the component list:<br />
<source lang="python"><br />
ft(vis='myms', complist='my_1_component.cl')<br />
</source><br />
or<br />
<source lang="python"><br />
ft(vis='myms', model=newimgname)<br />
</source><br />
<br />
The final step is the addition of these weak sources to the visibility data, by <code>uvsub<code>:<br />
<source lang="python"><br />
uvsub(vis='myms',reverse=True)<br />
</source><br />
<br />
At this point, the visibility data has a weak source(s) added to it. One can now test whether it can be recovered reliably.<br />
<br />
<br />
<br />
YMMV.<br />
TJWL<br />
<br />
<br />
<br />
Then proceed with the gaincal as in normal selfcal routines.</div>Jlaziohttps://casaguides.nrao.edu/index.php?title=CASA_Hints,_Tips,_and_Tricks&diff=4540CASA Hints, Tips, and Tricks2011-02-12T05:46:16Z<p>Jlazio: /* More Advanced Topics */</p>
<hr />
<div>{{Using CASA}}<br />
[[Category: CASA Basics]]<br />
== For Newcomers ==<br />
* [[Importing Data into CASA]]<br />
* [[Loading and Running Tasks]]<br />
* [[Selecting Spectral Windows and Channels]]<br />
* [http://www.aoc.nrao.edu/~sbhatnag/misc/msselection/msselection.html General description of the data selection syntax]<br />
* [[Interpreting CASA output]]<br />
* [[New Startup Screen]]<br />
* [[Starting CASA Without the Logger]]<br />
* [[Capturing Return Values]]<br />
* [[Accessing the Newest Version of CASA at NRAO]]<br />
<br />
== More Advanced Topics ==<br />
<br />
* [[Setting Up the Available Memory]]<br />
* [[Fixing out of date TAI_UTC tables (missing information on leap seconds)]]<br />
* [[Renaming a Field]]<br />
* [[Renaming Antennas]]<br />
* [[Creating lists of files for task input: using glob]]<br />
* [[Waiting for read-lock on file]]<br />
* [[Diverging deconvolution results in 'csclean' and 'mosaic' modes]]<br />
* [[Combining Bandpasses]]<br />
* [[Create a Component List for Selfcal]]<br />
* [[Create a Simulated Image]]<br />
* [[How to rotate and slice a cube for pV diagrams]]<br />
* [http://aips2.nrao.edu/docs/notes/223/223.html Lattice Expression Language (LEL) as used, e.g. in ''immath'']<br />
* [http://casa.nrao.edu/Memos/229.html Definition of a Measurement Set]<br />
* [http://casa.nrao.edu/Memos/240.html Definition of a Calibration Table]<br />
<br />
<br />
Also check out the step-by-step tutorials on this wiki! <br />
<br />
<br />
[[Main Page | &#8629; '''CASAguides''']] <br></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Karl_G._Jansky_VLA_Tutorials&diff=4180Karl G. Jansky VLA Tutorials2010-07-13T18:54:24Z<p>Jlazio: </p>
<hr />
<div>* Twelfth Synthesis Imaging Workshop Tutorials ('''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>Jlaziohttps://casaguides.nrao.edu/index.php?title=Main_Page_Old&diff=4173Main Page Old2010-06-21T19:16:39Z<p>Jlazio: /* 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>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4172Transient reduction pipeline2010-06-20T20:02:57Z<p>Jlazio: /* Pipeline */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that polarization information is not required;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the edge channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator, if one exists. The pipeline uses the calibration codes stored in the measurement set to determine which, if any, sources are suitable for calibrating the flux density scale. If it finds no source that is suitable, it sets all sources that are suitable for calibrating the gain phases and the spectral bandpass to have a flux density of 1 Jy. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass, if a spectral bandpass calibrator exists.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator if one exists, then the phase calibrator. The two steps could be combined, but it is not clear that doing so would provide much benefit.<br />
<br />
* Apply the calibration, from the phase calibrator to the science target.<br />
<br />
* Form target source measurement set.<br />
<br />
* Clip data above some a threshold. The user can select this threshold by specifying <tt>clip_sigma</tt> prior to invoking the pipeline. If no value is given, a value of 50<math>\sigma</math> is assumed.<br />
<br />
=== Imaging ===<br />
<br />
* The source is imaged and a light CLEANing is applied.<br />
<br />
== Pipeline ==<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
#!/bin/env python<br />
#<br />
# A first step toward an EVLA transient reduction pipeline.<br />
#<br />
# Warning: This script was written at the time that the<br />
# EVLA was undergoing commissioning. Details may change.<br />
# Caveat emptor!<br />
#<br />
# In particular, current version does not calibrate<br />
# weights within applycal as EVLA does not currently<br />
# report accurate weights.<br />
#<br />
#<br />
########################################################################<br />
#<br />
import os.path, math<br />
#<br />
#Version='v. 0.0 TJWL 2010-05-11'<br />
#Version='v. 0.1 TJWL 2010-06-16'<br />
#Version='v. 0.2 TJWL 2010-06-19'<br />
#Version='v. 0.3 TJWL 2010-06-20'<br />
Version='v. 0.4 TJWL 2010-06-20'<br />
# adopt L. Chiomuk's suggestion of incorporating spectral window<br />
# information<br />
# add flagging information<br />
# start moving away from user input<br />
#<br />
CalModels='/home/casa/data/nrao/VLA/CalModels'<br />
c=2.99792458E8<br />
D=24.5<br />
degrad=180/pi<br />
arcsecond_deg=3600<br />
#<br />
print " "<br />
print "EVLA Transient Reduction Pipeline"<br />
print " "<br />
print Version<br />
print " "<br />
print "Warning: This script was written at the time that the"<br />
print "EVLA was undergoing commissioning. Details may change."<br />
print "Caveat emptor!"<br />
print " "<br />
print "Assumption: Data stored as an Archive Science Data Model (ASDM)"<br />
print " file on disk."<br />
print " "<br />
print "Assumption: Sources, listed in order of appearance, are structured"<br />
print " as Option A or Option B"<br />
print " Option A: phase calibrator"<br />
print " target source"<br />
print " amplitude calibrator"<br />
print " "<br />
print " Option B: amplitude calibrator"<br />
print " phase calibrator"<br />
print " target source"<br />
print " "<br />
#<br />
print "Assumption: Calibrator model files stored in "<br />
print CalModels<br />
if not os.path.isdir(CalModels):<br />
raise IOError('Calibrator model files missing? Stopping.')<br />
#<br />
<br />
########################################################################<br />
# User specified parameters<br />
try: clip_sigma<br />
except NameError:<br />
clip_sigma=50.0<br />
<br />
try: ASDM_name<br />
except NameError:<br />
raise NameError('ASDM_name variable not specified')<br />
<br />
if not os.path.exists(ASDM_name):<br />
raise IOError('ASDM file does not exist.')<br />
else:<br />
msname=ASDM_name+'.ms'<br />
<br />
try: refant<br />
except NameError:<br />
raise NameError('Reference antenna not specified in variable refant.')<br />
<br />
########################################################################<br />
# definitions<br />
#<br />
acal_std_name = {}<br />
acal_std_name['3C286'] = frozenset(['3C286','3C 286',<br />
'1328+30','1328+307','B1328+307','B1328+30',<br />
'1331+305','J1331+305','J1331+3030'])<br />
acal_std_name['3C138'] = frozenset(['3C138','3C 138',<br />
'0518+16','0518+165','0518+1635','B0518+16','B0518+165','B0518+1635',<br />
'0521+166','0521+1638','J0521+166','J0521+1638'])<br />
acal_std_name['3C147'] = frozenset(['3C147','3C 147',<br />
'0538+49','0538+498','0538+4949','B0538+49','B0538+498','B0538+4949',<br />
'0542+498','0542+4951','J0542+498','J0542+4951'])<br />
acal_std_name['3C48'] = frozenset(['3C48','3C 48',<br />
'0134+32','0134+329','0134+3254','B0134+32','B0134+329','B0134+3254',<br />
'0137+331','0137+3309','J0137+331','J0137+3309'])<br />
#<br />
########################################################################<br />
#<br />
# Initial stuff.<br />
#<br />
# Read the data from the ASDM file converting it to a Measurement Set<br />
# with importevla.<br />
# Apply basic flagging operations (zeros, shadowing) here.<br />
#<br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
#<br />
# Flag the first (dummy) scan.<br />
# Required at the time of development, this step may be relaxed<br />
# in the future.<br />
#<br />
print "Flagging first (dummy) scan ..."<br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
<br />
#<br />
# Flag (quack) first 10 seconds of each scan.<br />
#<br />
print "Quack data ..."<br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
<br />
#<br />
# Extract various useful quantities ....<br />
#<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
source_table=msname + '/SOURCE'<br />
tb.open(source_table)<br />
calcode=tb.getcol("CODE")<br />
source_id=tb.getcol("SOURCE_ID")<br />
source_name=tb.getcol("NAME")<br />
tb.close(source_table)<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
#<br />
# How much time-average smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 2 of Bridle & Schwab (1999).<br />
# Note undocumented option that the amount of time-average<br />
# smearing loss can be specified by user.<br />
#<br />
try: time_smearing_loss<br />
except NameError:<br />
time_smearing_loss=0.01<br />
<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=min(interval)<br />
#<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
#<br />
# How much bandwidth smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 1 of Bridle & Schwab (1999).<br />
# Assume square bandpass, no taper, expand resulting<br />
# sine integral to lowest order<br />
# Note undocumented option that the amount of time-average<br />
# smearing loss can be specified by user.<br />
#<br />
try: band_smearing_loss<br />
except NameError:<br />
band_smearing_loss=0.01<br />
<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
#<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
<br />
#<br />
# Compress data for faster processing.<br />
# Throw away edge channels.<br />
#<br />
<br />
bchan=num_chan[0]*0.1<br />
echan=num_chan[0]*0.9<br />
chans='*:%d~%d'%(bchan, echan)<br />
<br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
spw=chans,<br />
timebin=tave,width=int(nchav))<br />
<br />
########################################################################<br />
#<br />
# Calibration<br />
#<br />
# The could be an issue if the frequency<br />
# setting is such that one should use a<br />
# model image at a different band than one<br />
# is observing, e.g., observing near the<br />
# top of the C band where an X band model<br />
# might be more appropriate.<br />
<br />
# New style EVLA (indicators of scan intents):<br />
# D = calibrator useful to determine Complex Gains<br />
# E = calibrator useful to determine the absolute Flux Density<br />
# Scale; typically only used for 3C48, 3C147, 3C286 (and 3C138,<br />
# 3C295)<br />
# F = calibrator useful to determine the spectral Bandpass response<br />
# G = calibrator useful to determine Polarization Angle<br />
# H = calibrator useful to determine the instrumental Polarization<br />
# Leakage<br />
# I = calibrator for Complex Gain and Bandpass<br />
# J = calibrator for Complex Gain and Polarization Leakage<br />
# K = calibrator for Flux Density Scale and Bandpass<br />
# L = calibrator for Flux Density Scale and Polarization Angle<br />
# M = calibrator for Bandpass and Polarization Angle<br />
# N = calibrator for Flux Density Scale, Bandpass and Polarization<br />
# Angle<br />
# Y = recognised as calibrator source in the VLA catalog by the<br />
# pipeline; only appears when no other calcodes are present and<br />
# NOT an indication that this calibrator is useful at this<br />
# frequency or in this array<br />
# Z = any other non-Target combination of intents<br />
# <br />
# Code Gain Flux BP Pang P%<br />
# D X<br />
# E X<br />
# F X<br />
# G X<br />
# H X<br />
# I X X<br />
# J X X<br />
# K X X<br />
# L X X<br />
# M X X<br />
# N X X X<br />
#<br />
print " Beginning calibration ..."<br />
clearstat()<br />
<br />
flux_cal=F<br />
for i in range(0, len(calcode)):<br />
if calcode[i]=='E' or calcode[i]=='K' or calcode[i]=='L' or calcode[i]=='N':<br />
flux_cal=T<br />
break<br />
<br />
if flux_cal==T:<br />
iflux_cal=i<br />
for tstname in acal_std_name.keys():<br />
if source_name[i] in acal_std_name[tstname]:<br />
modimage=CalModels + '/' + tstname + '_' + band + '.im'<br />
break<br />
#<br />
setjy(vis=outmsname,field=source_name[i],modimage=modimage)<br />
else:<br />
for i in range(0, len(calcode)):<br />
if calcode[i]=='D' or calcode=='F' or calcode[i]=='I' or calcode[i]=='J' or calcode=='M':<br />
setjy(vis=outmsname,field=source_name[i],modimage='',fluxdensity=[1.0,0.0,0.0,0.0])<br />
#<br />
# Quick-n-dirty bandpass<br />
#<br />
for i in range(0, len(calcode)):<br />
if calcode[i]=='F' or calcode[i]=='I' or calcode=='K' or calcode=='M' or calcode=='N':<br />
print " Finding bandpass ..."<br />
band_cal=T<br />
#<br />
Bcaltable=ASDM_name + '.B1'<br />
Gcaltable=ASDM_name + '.G0'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=source_name[i], <br />
solint='int',refant=refant,<br />
solnorm=T,calmode='p',minsnr=5)<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=source_name[i],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
gaintable=[Gcaltable])<br />
break<br />
#<br />
# Amplitude and phase calibration<br />
#<br />
print " Amplitude and phase calibration ..."<br />
<br />
Gcaltable=ASDM_name + '.G1'<br />
if band_cal==T:<br />
gaintable=[Bcaltable]<br />
else:<br />
gaintable=[]<br />
<br />
if flux_cal==T:<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=source_name[iflux_cal],<br />
solint='inf',combine='scan',refant=refant,<br />
minsnr=5,<br />
gaintable=gaintable)<br />
<br />
for i in range(0, len(calcode)):<br />
if calcode[i]=='D' or calcode[i]=='I' or calcode=='J':<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=source_name[i],<br />
solint='inf',refant=refant,<br />
minsnr=3,<br />
append=T,<br />
gaintable=gaintable)<br />
#<br />
# Apply calibration.<br />
#<br />
if flux_cal==T:<br />
fluxtable=ASDM_name + '.flux1'<br />
for i in range(0, len(calcode)):<br />
if calcode[i]=='D' or calcode[i]=='I' or calcode=='J':<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=source_name[iflux_cal],<br />
transfer=source_name[i])<br />
<br />
if flux_cal==T and band_cal==T:<br />
gaintable=[Bcaltable,fluxtable]<br />
gainfield=['',source_name[iflux_cal]]<br />
elif flux_cal==T and band_cal==F:<br />
gaintable=[fluxtable]<br />
gainfield=[source_name[iflux_cal]]<br />
elif flux_cal==F and band_cal==T:<br />
gaintable=[Bcaltable,Gcaltable]<br />
gainfield=[]<br />
else:<br />
gaintable=[Gcaltable]<br />
gainfield=[]<br />
<br />
for i in range(0, len(calcode)):<br />
if calcode[i]=='D' or calcode[i]=='I' or calcode=='J':<br />
applycal(vis=outmsname,<br />
field=''<br />
gaintable=gaintable,<br />
gainfield=gainfield,<br />
calwt=F)<br />
break<br />
#<br />
# Form target source measurement set.<br />
#<br />
print " Forming target source measurement set ..."<br />
<br />
for i in range(0, len(calcode)):<br />
if calcode[i]=='Z' or calcode[i]=='NONE':<br />
targetms=source_name[i] + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=source_name[i])<br />
#<br />
# Clip any egregious data.<br />
#<br />
Vstat=visstat(vis=outmsname,selectdata=F)<br />
Vclip=clip_sigma*Vstat['DATA']['rms']<br />
<br />
flagdata(vis=outmsname,<br />
mode='manualflag',<br />
clipexpr='ABS RR',clipminmax=[0.0,Vclip],<br />
selectdata=F)<br />
flagdata(vis=outmsname,<br />
mode='manualflag',<br />
clipexpr='ABS LL',clipminmax=[0.0,Vclip],<br />
selectdata=F)<br />
<br />
########################################################################<br />
#<br />
# Imaging and CLEANing.<br />
#<br />
print " Image the data ..."<br />
clearstat()<br />
<br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4171Transient reduction pipeline2010-06-20T19:44:21Z<p>Jlazio: /* Calibration */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that polarization information is not required;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the edge channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator, if one exists. The pipeline uses the calibration codes stored in the measurement set to determine which, if any, sources are suitable for calibrating the flux density scale. If it finds no source that is suitable, it sets all sources that are suitable for calibrating the gain phases and the spectral bandpass to have a flux density of 1 Jy. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass, if a spectral bandpass calibrator exists.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator if one exists, then the phase calibrator. The two steps could be combined, but it is not clear that doing so would provide much benefit.<br />
<br />
* Apply the calibration, from the phase calibrator to the science target.<br />
<br />
* Form target source measurement set.<br />
<br />
* Clip data above some a threshold. The user can select this threshold by specifying <tt>clip_sigma</tt> prior to invoking the pipeline. If no value is given, a value of 50<math>\sigma</math> is assumed.<br />
<br />
=== Imaging ===<br />
<br />
* The source is imaged and a light CLEANing is applied.<br />
<br />
== Pipeline ==<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
#!/bin/env python<br />
#<br />
# A first step toward an EVLA transient reduction pipeline.<br />
#<br />
# Warning: This script was written at the time that the<br />
# EVLA was undergoing commissioning. Details may change.<br />
# Caveat emptor!<br />
#<br />
# In particular, current version does not calibrate<br />
# weights within applycal as EVLA does not currently<br />
# report accurate weights.<br />
#<br />
#<br />
########################################################################<br />
#<br />
import os.path, math<br />
#<br />
#Version='v. 0.0 TJWL 2010-05-11'<br />
#Version='v. 0.1 TJWL 2010-06-16'<br />
#Version='v. 0.2 TJWL 2010-06-19'<br />
Version='v. 0.3 TJWL 2010-06-20'<br />
# adopt L. Chiomuk's suggestion of incorporating spectral window<br />
# information<br />
# add flagging information<br />
# start moving away from user input<br />
#<br />
CalModels='/home/casa/data/nrao/VLA/CalModels'<br />
c=2.99792458E8<br />
D=24.5<br />
degrad=180/pi<br />
arcsecond_deg=3600<br />
#<br />
print " "<br />
print "EVLA Transient Reduction Pipeline"<br />
print " "<br />
print Version<br />
print " "<br />
print "Warning: This script was written at the time that the"<br />
print "EVLA was undergoing commissioning. Details may change."<br />
print "Caveat emptor!"<br />
print " "<br />
print "Assumption: Data stored as an Archive Science Data Model (ASDM)"<br />
print " file on disk."<br />
print " "<br />
print "Assumption: Sources, listed in order of appearance, are structured"<br />
print " as Option A or Option B"<br />
print " Option A: phase calibrator"<br />
print " target source"<br />
print " amplitude calibrator"<br />
print " "<br />
print " Option B: amplitude calibrator"<br />
print " phase calibrator"<br />
print " target source"<br />
print " "<br />
#<br />
print "Assumption: Calibrator model files stored in "<br />
print CalModels<br />
if not os.path.isdir(CalModels):<br />
raise IOError('Calibrator model files missing? Stopping.')<br />
#<br />
<br />
########################################################################<br />
# User specified parameters<br />
try: clip_sigma<br />
except NameError:<br />
clip_sigma=50.0<br />
<br />
try: ASDM_name<br />
except NameError:<br />
raise NameError('ASDM_name variable not specified')<br />
<br />
if not os.path.exists(ASDM_name):<br />
raise IOError('ASDM file does not exist.')<br />
else:<br />
msname=ASDM_name+'.ms'<br />
<br />
try: refant<br />
except NameError:<br />
raise NameError('Reference antenna not specified in variable refant.')<br />
<br />
########################################################################<br />
# definitions<br />
#<br />
acal_std_name = {}<br />
acal_std_name['3C286'] = frozenset(['3C286','3C 286',<br />
'1328+30','1328+307','B1328+307','B1328+30',<br />
'1331+305','J1331+305','J1331+3030'])<br />
acal_std_name['3C138'] = frozenset(['3C138','3C 138',<br />
'0518+16','0518+165','0518+1635','B0518+16','B0518+165','B0518+1635',<br />
'0521+166','0521+1638','J0521+166','J0521+1638'])<br />
acal_std_name['3C147'] = frozenset(['3C147','3C 147',<br />
'0538+49','0538+498','0538+4949','B0538+49','B0538+498','B0538+4949',<br />
'0542+498','0542+4951','J0542+498','J0542+4951'])<br />
acal_std_name['3C48'] = frozenset(['3C48','3C 48',<br />
'0134+32','0134+329','0134+3254','B0134+32','B0134+329','B0134+3254',<br />
'0137+331','0137+3309','J0137+331','J0137+3309'])<br />
<br />
########################################################################<br />
#<br />
# 2. Determine the structure of the observations.<br />
#<br />
print " "<br />
obs_structure=raw_input('Structure of observations [A|B]: ')<br />
if obs_structure == 'A':<br />
sources = {'acal':'2', 'pcal':'0', 'target':'1'}<br />
elif obs_structure == 'B':<br />
sources = {'acal':'0', 'pcal':'1', 'target':'2'}<br />
<br />
<br />
#<br />
########################################################################<br />
#<br />
# Initial stuff.<br />
#<br />
# Read the data from the ASDM file converting it to a Measurement Set<br />
# with importevla.<br />
# Apply basic flagging operations (zeros, shadowing) here.<br />
#<br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
#<br />
# Flag the first (dummy) scan.<br />
# Required at the time of development, this step may be relaxed<br />
# in the future.<br />
#<br />
print "Flagging first (dummy) scan ..."<br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
<br />
#<br />
# Flag (quack) first 10 seconds of each scan.<br />
#<br />
print "Quack data ..."<br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
<br />
#<br />
# Extract various useful quantities ....<br />
#<br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['acal'])<br />
acal_name=hdvalue[0]<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
<br />
#<br />
# How much time-average smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 2 of Bridle & Schwab (1999).<br />
# Note undocumented option that the amount of time-average<br />
# smearing loss can be specified by user.<br />
#<br />
try: time_smearing_loss<br />
except NameError:<br />
time_smearing_loss=0.01<br />
<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=min(interval)<br />
#<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
#<br />
# How much bandwidth smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 1 of Bridle & Schwab (1999).<br />
# Assume square bandpass, no taper, expand resulting<br />
# sine integral to lowest order<br />
# Note undocumented option that the amount of time-average<br />
# smearing loss can be specified by user.<br />
#<br />
try: band_smearing_loss<br />
except NameError:<br />
band_smearing_loss=0.01<br />
<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
#<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
<br />
#<br />
# Compress data for faster processing.<br />
# Throw away edge channels.<br />
#<br />
<br />
bchan=num_chan[0]*0.1<br />
echan=num_chan[0]*0.9<br />
chans='*:%d~%d'%(bchan, echan)<br />
<br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
spw=chans,<br />
timebin=tave,width=int(nchav))<br />
<br />
########################################################################<br />
#<br />
# Calibration<br />
#<br />
# Set flux density of amplitude calibrator.<br />
# Need some heuristics here.<br />
# Also could be an issue if the frequency<br />
# setting is such that one should use a<br />
# model image at a different band than one<br />
# is observing, e.g., observing near the<br />
# top of the C band where an X band model<br />
# might be more appropriate.<br />
#<br />
#print acal_name<br />
print " Beginning calibration ..."<br />
clearstat()<br />
<br />
for tstname in acal_std_name.keys():<br />
if acal_name in acal_std_name[tstname]:<br />
modimage=tstname<br />
modimage=CalModels + '/' + modimage + '_' + band + '.im'<br />
setjy(vis=outmsname,field=sources['acal'],modimage=modimage)<br />
<br />
#<br />
# Quick-n-dirty bandpass<br />
#<br />
print " Finding bandpass ..."<br />
<br />
Bcaltable=ASDM_name + '.B1'<br />
Gcaltable=ASDM_name + '.G0'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'], <br />
solint='int',refant=refant,<br />
solnorm=T,calmode='p',minsnr=5)<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
gaintable=[Gcaltable]) <br />
<br />
#<br />
# Amplitude and phase calibration<br />
#<br />
print " Amplitude and phase calibration ..."<br />
<br />
Gcaltable=ASDM_name + '.G1'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
minsnr=5,<br />
gaintable=[Bcaltable])<br />
<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['pcal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
append=T,<br />
gaintable=[Bcaltable])<br />
<br />
#<br />
# Apply calibration.<br />
#<br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, fluxtable],<br />
gainfield=['',sources['pcal']],<br />
calwt=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, fluxtable],<br />
gainfield=['',sources['pcal']],<br />
calwt=F)<br />
<br />
#<br />
# Form target source measurement set.<br />
#<br />
print " Forming target source measurement set ..."<br />
<br />
hdvalue=vishead(vis=outmsname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
<br />
#<br />
# Clip any egregious data.<br />
#<br />
Vstat=visstat(vis=outmsname,selectdata=F)<br />
Vclip=clip_sigma*Vstat['DATA']['rms']<br />
<br />
flagdata(vis=outmsname,<br />
mode='manualflag',<br />
clipexpr='ABS RR',clipminmax=[0.0,Vclip],<br />
selectdata=F)<br />
flagdata(vis=outmsname,<br />
mode='manualflag',<br />
clipexpr='ABS LL',clipminmax=[0.0,Vclip],<br />
selectdata=F)<br />
<br />
########################################################################<br />
#<br />
# Imaging and CLEANing.<br />
#<br />
print " Image the data ..."<br />
clearstat()<br />
<br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4170Transient reduction pipeline2010-06-20T19:36:24Z<p>Jlazio: /* Calibration */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that polarization information is not required;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the edge channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator, if one exists. The pipeline uses the calibration codes stored in the measurement set to determine which, if any, sources are suitable for calibrating the flux density scale. If it finds no source that is suitable, it sets all sources that are suitable for calibrating the gain phases and the spectral bandpass to have a flux density of 1 Jy. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass, if a spectral bandpass calibrator exists.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator, then the phase calibrator, but the two steps could be combined.<br />
<br />
* Apply the calibration, from the phase calibrator to the science target.<br />
<br />
* Form target source measurement set.<br />
<br />
* Clip data above some a threshold. The user can select this threshold by specifying <tt>clip_sigma</tt> prior to invoking the pipeline. If no value is given, a value of 50<math>\sigma</math> is assumed.<br />
<br />
=== Imaging ===<br />
<br />
* The source is imaged and a light CLEANing is applied.<br />
<br />
== Pipeline ==<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
#!/bin/env python<br />
#<br />
# A first step toward an EVLA transient reduction pipeline.<br />
#<br />
# Warning: This script was written at the time that the<br />
# EVLA was undergoing commissioning. Details may change.<br />
# Caveat emptor!<br />
#<br />
# In particular, current version does not calibrate<br />
# weights within applycal as EVLA does not currently<br />
# report accurate weights.<br />
#<br />
#<br />
########################################################################<br />
#<br />
import os.path, math<br />
#<br />
#Version='v. 0.0 TJWL 2010-05-11'<br />
#Version='v. 0.1 TJWL 2010-06-16'<br />
#Version='v. 0.2 TJWL 2010-06-19'<br />
Version='v. 0.3 TJWL 2010-06-20'<br />
# adopt L. Chiomuk's suggestion of incorporating spectral window<br />
# information<br />
# add flagging information<br />
# start moving away from user input<br />
#<br />
CalModels='/home/casa/data/nrao/VLA/CalModels'<br />
c=2.99792458E8<br />
D=24.5<br />
degrad=180/pi<br />
arcsecond_deg=3600<br />
#<br />
print " "<br />
print "EVLA Transient Reduction Pipeline"<br />
print " "<br />
print Version<br />
print " "<br />
print "Warning: This script was written at the time that the"<br />
print "EVLA was undergoing commissioning. Details may change."<br />
print "Caveat emptor!"<br />
print " "<br />
print "Assumption: Data stored as an Archive Science Data Model (ASDM)"<br />
print " file on disk."<br />
print " "<br />
print "Assumption: Sources, listed in order of appearance, are structured"<br />
print " as Option A or Option B"<br />
print " Option A: phase calibrator"<br />
print " target source"<br />
print " amplitude calibrator"<br />
print " "<br />
print " Option B: amplitude calibrator"<br />
print " phase calibrator"<br />
print " target source"<br />
print " "<br />
#<br />
print "Assumption: Calibrator model files stored in "<br />
print CalModels<br />
if not os.path.isdir(CalModels):<br />
raise IOError('Calibrator model files missing? Stopping.')<br />
#<br />
<br />
########################################################################<br />
# User specified parameters<br />
try: clip_sigma<br />
except NameError:<br />
clip_sigma=50.0<br />
<br />
try: ASDM_name<br />
except NameError:<br />
raise NameError('ASDM_name variable not specified')<br />
<br />
if not os.path.exists(ASDM_name):<br />
raise IOError('ASDM file does not exist.')<br />
else:<br />
msname=ASDM_name+'.ms'<br />
<br />
try: refant<br />
except NameError:<br />
raise NameError('Reference antenna not specified in variable refant.')<br />
<br />
########################################################################<br />
# definitions<br />
#<br />
acal_std_name = {}<br />
acal_std_name['3C286'] = frozenset(['3C286','3C 286',<br />
'1328+30','1328+307','B1328+307','B1328+30',<br />
'1331+305','J1331+305','J1331+3030'])<br />
acal_std_name['3C138'] = frozenset(['3C138','3C 138',<br />
'0518+16','0518+165','0518+1635','B0518+16','B0518+165','B0518+1635',<br />
'0521+166','0521+1638','J0521+166','J0521+1638'])<br />
acal_std_name['3C147'] = frozenset(['3C147','3C 147',<br />
'0538+49','0538+498','0538+4949','B0538+49','B0538+498','B0538+4949',<br />
'0542+498','0542+4951','J0542+498','J0542+4951'])<br />
acal_std_name['3C48'] = frozenset(['3C48','3C 48',<br />
'0134+32','0134+329','0134+3254','B0134+32','B0134+329','B0134+3254',<br />
'0137+331','0137+3309','J0137+331','J0137+3309'])<br />
<br />
########################################################################<br />
#<br />
# 2. Determine the structure of the observations.<br />
#<br />
print " "<br />
obs_structure=raw_input('Structure of observations [A|B]: ')<br />
if obs_structure == 'A':<br />
sources = {'acal':'2', 'pcal':'0', 'target':'1'}<br />
elif obs_structure == 'B':<br />
sources = {'acal':'0', 'pcal':'1', 'target':'2'}<br />
<br />
<br />
#<br />
########################################################################<br />
#<br />
# Initial stuff.<br />
#<br />
# Read the data from the ASDM file converting it to a Measurement Set<br />
# with importevla.<br />
# Apply basic flagging operations (zeros, shadowing) here.<br />
#<br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
#<br />
# Flag the first (dummy) scan.<br />
# Required at the time of development, this step may be relaxed<br />
# in the future.<br />
#<br />
print "Flagging first (dummy) scan ..."<br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
<br />
#<br />
# Flag (quack) first 10 seconds of each scan.<br />
#<br />
print "Quack data ..."<br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
<br />
#<br />
# Extract various useful quantities ....<br />
#<br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['acal'])<br />
acal_name=hdvalue[0]<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
<br />
#<br />
# How much time-average smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 2 of Bridle & Schwab (1999).<br />
# Note undocumented option that the amount of time-average<br />
# smearing loss can be specified by user.<br />
#<br />
try: time_smearing_loss<br />
except NameError:<br />
time_smearing_loss=0.01<br />
<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=min(interval)<br />
#<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
#<br />
# How much bandwidth smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 1 of Bridle & Schwab (1999).<br />
# Assume square bandpass, no taper, expand resulting<br />
# sine integral to lowest order<br />
# Note undocumented option that the amount of time-average<br />
# smearing loss can be specified by user.<br />
#<br />
try: band_smearing_loss<br />
except NameError:<br />
band_smearing_loss=0.01<br />
<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
#<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
<br />
#<br />
# Compress data for faster processing.<br />
# Throw away edge channels.<br />
#<br />
<br />
bchan=num_chan[0]*0.1<br />
echan=num_chan[0]*0.9<br />
chans='*:%d~%d'%(bchan, echan)<br />
<br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
spw=chans,<br />
timebin=tave,width=int(nchav))<br />
<br />
########################################################################<br />
#<br />
# Calibration<br />
#<br />
# Set flux density of amplitude calibrator.<br />
# Need some heuristics here.<br />
# Also could be an issue if the frequency<br />
# setting is such that one should use a<br />
# model image at a different band than one<br />
# is observing, e.g., observing near the<br />
# top of the C band where an X band model<br />
# might be more appropriate.<br />
#<br />
#print acal_name<br />
print " Beginning calibration ..."<br />
clearstat()<br />
<br />
for tstname in acal_std_name.keys():<br />
if acal_name in acal_std_name[tstname]:<br />
modimage=tstname<br />
modimage=CalModels + '/' + modimage + '_' + band + '.im'<br />
setjy(vis=outmsname,field=sources['acal'],modimage=modimage)<br />
<br />
#<br />
# Quick-n-dirty bandpass<br />
#<br />
print " Finding bandpass ..."<br />
<br />
Bcaltable=ASDM_name + '.B1'<br />
Gcaltable=ASDM_name + '.G0'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'], <br />
solint='int',refant=refant,<br />
solnorm=T,calmode='p',minsnr=5)<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
gaintable=[Gcaltable]) <br />
<br />
#<br />
# Amplitude and phase calibration<br />
#<br />
print " Amplitude and phase calibration ..."<br />
<br />
Gcaltable=ASDM_name + '.G1'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
minsnr=5,<br />
gaintable=[Bcaltable])<br />
<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['pcal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
append=T,<br />
gaintable=[Bcaltable])<br />
<br />
#<br />
# Apply calibration.<br />
#<br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, fluxtable],<br />
gainfield=['',sources['pcal']],<br />
calwt=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, fluxtable],<br />
gainfield=['',sources['pcal']],<br />
calwt=F)<br />
<br />
#<br />
# Form target source measurement set.<br />
#<br />
print " Forming target source measurement set ..."<br />
<br />
hdvalue=vishead(vis=outmsname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
<br />
#<br />
# Clip any egregious data.<br />
#<br />
Vstat=visstat(vis=outmsname,selectdata=F)<br />
Vclip=clip_sigma*Vstat['DATA']['rms']<br />
<br />
flagdata(vis=outmsname,<br />
mode='manualflag',<br />
clipexpr='ABS RR',clipminmax=[0.0,Vclip],<br />
selectdata=F)<br />
flagdata(vis=outmsname,<br />
mode='manualflag',<br />
clipexpr='ABS LL',clipminmax=[0.0,Vclip],<br />
selectdata=F)<br />
<br />
########################################################################<br />
#<br />
# Imaging and CLEANing.<br />
#<br />
print " Image the data ..."<br />
clearstat()<br />
<br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4169Transient reduction pipeline2010-06-20T17:54:18Z<p>Jlazio: /* Pipeline */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that polarization information is not required;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the edge channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator, then the phase calibrator, but the two steps could be combined.<br />
<br />
* Apply the calibration, from the phase calibrator to the science target.<br />
<br />
* Form target source measurement set.<br />
<br />
* Clip data above some a threshold. The user can select this threshold by specifying <tt>clip_sigma</tt> prior to invoking the pipeline. If no value is given, a value of 50<math>\sigma</math> is assumed.<br />
<br />
=== Imaging ===<br />
<br />
* The source is imaged and a light CLEANing is applied.<br />
<br />
== Pipeline ==<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
#!/bin/env python<br />
#<br />
# A first step toward an EVLA transient reduction pipeline.<br />
#<br />
# Warning: This script was written at the time that the<br />
# EVLA was undergoing commissioning. Details may change.<br />
# Caveat emptor!<br />
#<br />
# In particular, current version does not calibrate<br />
# weights within applycal as EVLA does not currently<br />
# report accurate weights.<br />
#<br />
#<br />
########################################################################<br />
#<br />
import os.path, math<br />
#<br />
#Version='v. 0.0 TJWL 2010-05-11'<br />
#Version='v. 0.1 TJWL 2010-06-16'<br />
#Version='v. 0.2 TJWL 2010-06-19'<br />
Version='v. 0.3 TJWL 2010-06-20'<br />
# adopt L. Chiomuk's suggestion of incorporating spectral window<br />
# information<br />
# add flagging information<br />
# start moving away from user input<br />
#<br />
CalModels='/home/casa/data/nrao/VLA/CalModels'<br />
c=2.99792458E8<br />
D=24.5<br />
degrad=180/pi<br />
arcsecond_deg=3600<br />
#<br />
print " "<br />
print "EVLA Transient Reduction Pipeline"<br />
print " "<br />
print Version<br />
print " "<br />
print "Warning: This script was written at the time that the"<br />
print "EVLA was undergoing commissioning. Details may change."<br />
print "Caveat emptor!"<br />
print " "<br />
print "Assumption: Data stored as an Archive Science Data Model (ASDM)"<br />
print " file on disk."<br />
print " "<br />
print "Assumption: Sources, listed in order of appearance, are structured"<br />
print " as Option A or Option B"<br />
print " Option A: phase calibrator"<br />
print " target source"<br />
print " amplitude calibrator"<br />
print " "<br />
print " Option B: amplitude calibrator"<br />
print " phase calibrator"<br />
print " target source"<br />
print " "<br />
#<br />
print "Assumption: Calibrator model files stored in "<br />
print CalModels<br />
if not os.path.isdir(CalModels):<br />
raise IOError('Calibrator model files missing? Stopping.')<br />
#<br />
<br />
########################################################################<br />
# User specified parameters<br />
try: clip_sigma<br />
except NameError:<br />
clip_sigma=50.0<br />
<br />
try: ASDM_name<br />
except NameError:<br />
raise NameError('ASDM_name variable not specified')<br />
<br />
if not os.path.exists(ASDM_name):<br />
raise IOError('ASDM file does not exist.')<br />
else:<br />
msname=ASDM_name+'.ms'<br />
<br />
try: refant<br />
except NameError:<br />
raise NameError('Reference antenna not specified in variable refant.')<br />
<br />
########################################################################<br />
# definitions<br />
#<br />
acal_std_name = {}<br />
acal_std_name['3C286'] = frozenset(['3C286','3C 286',<br />
'1328+30','1328+307','B1328+307','B1328+30',<br />
'1331+305','J1331+305','J1331+3030'])<br />
acal_std_name['3C138'] = frozenset(['3C138','3C 138',<br />
'0518+16','0518+165','0518+1635','B0518+16','B0518+165','B0518+1635',<br />
'0521+166','0521+1638','J0521+166','J0521+1638'])<br />
acal_std_name['3C147'] = frozenset(['3C147','3C 147',<br />
'0538+49','0538+498','0538+4949','B0538+49','B0538+498','B0538+4949',<br />
'0542+498','0542+4951','J0542+498','J0542+4951'])<br />
acal_std_name['3C48'] = frozenset(['3C48','3C 48',<br />
'0134+32','0134+329','0134+3254','B0134+32','B0134+329','B0134+3254',<br />
'0137+331','0137+3309','J0137+331','J0137+3309'])<br />
<br />
########################################################################<br />
#<br />
# 2. Determine the structure of the observations.<br />
#<br />
print " "<br />
obs_structure=raw_input('Structure of observations [A|B]: ')<br />
if obs_structure == 'A':<br />
sources = {'acal':'2', 'pcal':'0', 'target':'1'}<br />
elif obs_structure == 'B':<br />
sources = {'acal':'0', 'pcal':'1', 'target':'2'}<br />
<br />
<br />
#<br />
########################################################################<br />
#<br />
# Initial stuff.<br />
#<br />
# Read the data from the ASDM file converting it to a Measurement Set<br />
# with importevla.<br />
# Apply basic flagging operations (zeros, shadowing) here.<br />
#<br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
#<br />
# Flag the first (dummy) scan.<br />
# Required at the time of development, this step may be relaxed<br />
# in the future.<br />
#<br />
print "Flagging first (dummy) scan ..."<br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
<br />
#<br />
# Flag (quack) first 10 seconds of each scan.<br />
#<br />
print "Quack data ..."<br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
<br />
#<br />
# Extract various useful quantities ....<br />
#<br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['acal'])<br />
acal_name=hdvalue[0]<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
<br />
#<br />
# How much time-average smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 2 of Bridle & Schwab (1999).<br />
# Note undocumented option that the amount of time-average<br />
# smearing loss can be specified by user.<br />
#<br />
try: time_smearing_loss<br />
except NameError:<br />
time_smearing_loss=0.01<br />
<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=min(interval)<br />
#<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
#<br />
# How much bandwidth smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 1 of Bridle & Schwab (1999).<br />
# Assume square bandpass, no taper, expand resulting<br />
# sine integral to lowest order<br />
# Note undocumented option that the amount of time-average<br />
# smearing loss can be specified by user.<br />
#<br />
try: band_smearing_loss<br />
except NameError:<br />
band_smearing_loss=0.01<br />
<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
#<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
<br />
#<br />
# Compress data for faster processing.<br />
# Throw away edge channels.<br />
#<br />
<br />
bchan=num_chan[0]*0.1<br />
echan=num_chan[0]*0.9<br />
chans='*:%d~%d'%(bchan, echan)<br />
<br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
spw=chans,<br />
timebin=tave,width=int(nchav))<br />
<br />
########################################################################<br />
#<br />
# Calibration<br />
#<br />
# Set flux density of amplitude calibrator.<br />
# Need some heuristics here.<br />
# Also could be an issue if the frequency<br />
# setting is such that one should use a<br />
# model image at a different band than one<br />
# is observing, e.g., observing near the<br />
# top of the C band where an X band model<br />
# might be more appropriate.<br />
#<br />
#print acal_name<br />
print " Beginning calibration ..."<br />
clearstat()<br />
<br />
for tstname in acal_std_name.keys():<br />
if acal_name in acal_std_name[tstname]:<br />
modimage=tstname<br />
modimage=CalModels + '/' + modimage + '_' + band + '.im'<br />
setjy(vis=outmsname,field=sources['acal'],modimage=modimage)<br />
<br />
#<br />
# Quick-n-dirty bandpass<br />
#<br />
print " Finding bandpass ..."<br />
<br />
Bcaltable=ASDM_name + '.B1'<br />
Gcaltable=ASDM_name + '.G0'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'], <br />
solint='int',refant=refant,<br />
solnorm=T,calmode='p',minsnr=5)<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
gaintable=[Gcaltable]) <br />
<br />
#<br />
# Amplitude and phase calibration<br />
#<br />
print " Amplitude and phase calibration ..."<br />
<br />
Gcaltable=ASDM_name + '.G1'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
minsnr=5,<br />
gaintable=[Bcaltable])<br />
<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['pcal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
append=T,<br />
gaintable=[Bcaltable])<br />
<br />
#<br />
# Apply calibration.<br />
#<br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, fluxtable],<br />
gainfield=['',sources['pcal']],<br />
calwt=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, fluxtable],<br />
gainfield=['',sources['pcal']],<br />
calwt=F)<br />
<br />
#<br />
# Form target source measurement set.<br />
#<br />
print " Forming target source measurement set ..."<br />
<br />
hdvalue=vishead(vis=outmsname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
<br />
#<br />
# Clip any egregious data.<br />
#<br />
Vstat=visstat(vis=outmsname,selectdata=F)<br />
Vclip=clip_sigma*Vstat['DATA']['rms']<br />
<br />
flagdata(vis=outmsname,<br />
mode='manualflag',<br />
clipexpr='ABS RR',clipminmax=[0.0,Vclip],<br />
selectdata=F)<br />
flagdata(vis=outmsname,<br />
mode='manualflag',<br />
clipexpr='ABS LL',clipminmax=[0.0,Vclip],<br />
selectdata=F)<br />
<br />
########################################################################<br />
#<br />
# Imaging and CLEANing.<br />
#<br />
print " Image the data ..."<br />
clearstat()<br />
<br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4168Transient reduction pipeline2010-06-20T17:39:54Z<p>Jlazio: /* Pipeline */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that polarization information is not required;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the edge channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator, then the phase calibrator, but the two steps could be combined.<br />
<br />
* Apply the calibration, from the phase calibrator to the science target.<br />
<br />
* Form target source measurement set.<br />
<br />
* Clip data above some a threshold. The user can select this threshold by specifying <tt>clip_sigma</tt> prior to invoking the pipeline. If no value is given, a value of 50<math>\sigma</math> is assumed.<br />
<br />
=== Imaging ===<br />
<br />
* The source is imaged and a light CLEANing is applied.<br />
<br />
== Pipeline ==<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4167Transient reduction pipeline2010-06-20T17:38:54Z<p>Jlazio: /* Transient Reduction Pipeline */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that polarization information is not required;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the edge channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator, then the phase calibrator, but the two steps could be combined.<br />
<br />
* Apply the calibration, from the phase calibrator to the science target.<br />
<br />
* Form target source measurement set.<br />
<br />
* Clip data above some a threshold. The user can select this threshold by specifying <tt>clip_sigma</tt> prior to invoking the pipeline. If no value is given, a value of 50<math>\sigma</math> is assumed.<br />
<br />
=== Imaging ===<br />
<br />
* The source is imaged and a light CLEANing is applied.<br />
<br />
== Pipeline ==</div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4166Transient reduction pipeline2010-06-20T17:35:39Z<p>Jlazio: /* Transient Reduction Pipeline */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that polarization information is not required;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the edge channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator, then the phase calibrator, but the two steps could be combined.<br />
<br />
* Apply the calibration, from the phase calibrator to the science target.<br />
<br />
* Form target source measurement set.<br />
<br />
* Clip data above some a threshold. The user can select this threshold by specifying <tt>clip_sigma</tt> prior to invoking the pipeline. If no value is given, a value of 50<math>\sigma</math> is assumed.<br />
<br />
=== Imaging ===<br />
<br />
* The source is imaged and a light CLEANing is applied.</div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4165Transient reduction pipeline2010-06-20T17:35:01Z<p>Jlazio: /* Calibration */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the edge channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator, then the phase calibrator, but the two steps could be combined.<br />
<br />
* Apply the calibration, from the phase calibrator to the science target.<br />
<br />
* Form target source measurement set.<br />
<br />
* Clip data above some a threshold. The user can select this threshold by specifying <tt>clip_sigma</tt> prior to invoking the pipeline. If no value is given, a value of 50<math>\sigma</math> is assumed.<br />
<br />
=== Imaging ===<br />
<br />
* The source is imaged and a light CLEANing is applied.</div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4164Transient reduction pipeline2010-06-20T17:29:37Z<p>Jlazio: /* Calibration */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the edge channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator, then the phase calibrator, but the two steps could be combined.<br />
<br />
* Apply the calibration.<br />
<br />
* <br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4163Transient reduction pipeline2010-06-20T17:28:25Z<p>Jlazio: /* Initial Stuff */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the edge channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator, then the phase calibrator, but the two steps could be combined.<br />
<br />
<br />
9. Apply calibration.<br />
<br />
<source lang="python"><br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
</source><br />
<br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4162Transient reduction pipeline2010-06-20T17:27:51Z<p>Jlazio: /* Transient Reduction Pipeline */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
Further, to the best of the author's knowledge, the infrastructure does not yet exist within CASA to determine if there are [http://www.vla.nrao.edu/astro/archive/baselines/ antenna position corrections] that should be applied (via <tt>gencal</tt>).<br />
<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the outer channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator, then the phase calibrator, but the two steps could be combined.<br />
<br />
<br />
9. Apply calibration.<br />
<br />
<source lang="python"><br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
</source><br />
<br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4161Transient reduction pipeline2010-06-20T17:24:47Z<p>Jlazio: /* Processing Steps */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
=== Initial Stuff ===<br />
<br />
* Read the data from the ASDM file converting it to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
* Flag the first (dummy) scan. (This step is required at the time of development, but it may be relaxed in the future.)<br />
<br />
* Flag (quack) first 10 seconds of each scan.<br />
<br />
* Having constructed the initial measurement set, pause to extract various useful items from it, such as the frequency of observation, number of spectral channels, etc. Use these to then calculate various quantities such as the primary beam, synthesized beam, tolerable amount of bandwidth smearing, and tolerable amount of time-average smearing.<br />
<br />
* Reduce the data in size for faster processing downstream by averaging in time and frequency. Also, reject the outer channels.<br />
<br />
=== Calibration ===<br />
<br />
* Set the flux density of the amplitude calibrator. There is a potential issue, at the time of writing, if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate. Presumably once all of the new receivers have been installed, new calibrator models will follow at some point.<br />
<br />
* Make a quick-n-dirty bandpass.<br />
<br />
* Amplitude and phase calibration. This is done in two steps, first the amplitude calibrator, then the phase calibrator, but the two steps could be combined.<br />
<br />
<br />
9. Apply calibration.<br />
<br />
<source lang="python"><br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
</source><br />
<br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4160Transient reduction pipeline2010-06-20T17:07:11Z<p>Jlazio: /* User Input */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
These must be done before invoking the script/pipeline. For example<br />
<pre><br />
CASA <1> ASDM_name='AL007_sb123456789_1.56000.1234567890'<br />
CASA <2> refant='ea21'<br />
CASA <3> clip_sigma=50.0<br />
CASA <4> execfile('transient_pipeline.py')<br />
</pre><br />
A sensible, large value is adopted for <tt>clip_sigma</tt> if it is omitted.<br />
<br />
== Processing Steps ==<br />
<br />
1. Read the data from the ASDM file converting to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
<source lang="python"><br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
</source><br />
<br />
2. Flag first (dummy) scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
</source><br />
<br />
3. Flag first 10 seconds of each scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
</source><br />
<br />
4. Extract various useful quantities from the data.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['acal'])<br />
acal_name=hdvalue[0]<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
<br />
##############################<br />
# How much time-average smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 2 of Bridle<br />
# & Schwab (1999).<br />
#<br />
time_smearing_loss=0.01<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=min(interval)<br />
<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer<br />
# multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
##############################<br />
# How much bandwidth<br />
# smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of<br />
# primary beam.<br />
# Follow Section 1 of Bridle<br />
# & Schwab (1999).<br />
# Assume square bandpass, no<br />
# taper, expand resulting<br />
# sine integral to lowest order<br />
#<br />
band_smearing_loss=0.01<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
</source><br />
<br />
5. Compress data for faster processing.<br />
<br />
<source lang="python"><br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
timebin=tave,width=int(nchav))<br />
</source><br />
<br />
6. Set flux density of amplitude calibrator.<br />
Need some heuristics here.<br />
Also could be an issue if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate.<br />
<br />
<source lang="python"><br />
for tstname in acal_std_name.keys():<br />
if acal_name in acal_std_name[tstname]:<br />
modimage=tstname<br />
modimage=CalModels + '/' + modimage + '_' + band + '.im'<br />
setjy(vis=outmsname,field=sources['acal'],modimage=modimage)<br />
</source><br />
<br />
<br />
7. Quick-n-dirty bandpass<br />
<br />
<source lang="python"><br />
Bcaltable=ASDM_name + '.B1'<br />
Gcaltable=ASDM_name + '.G0'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='int',refant=refant,<br />
solnorm=T,calmode='p',minsnr=5)<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
gaintable=[Gcaltable])<br />
</source><br />
<br />
<br />
8. amplitude and phase calibration<br />
<br />
<source lang="python"><br />
Gcaltable=ASDM_name + '.G1'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
minsnr=5,<br />
gaintable=[Bcaltable])<br />
<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['pcal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
append=T,<br />
gaintable=[Bcaltable])<br />
</source><br />
<br />
<br />
9. Apply calibration.<br />
<br />
<source lang="python"><br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
</source><br />
<br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4159Transient reduction pipeline2010-06-20T16:49:22Z<p>Jlazio: /* User Input */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
I am attempting to migrate the script to become a "pipeline," in the sense of not requiring any user input. However, there are some pieces of information that it is useful or required to know in order to process the data.<br />
<br />
* What is the name of the initial Archive Science Data Model (ASDM) file? It would be possible to assume that the script is being run in a directory that contains only a single file, which is in ASDM format, but that also seems a bit limiting.<br />
<br />
* What antenna should be used as a reference antenna? At the time of writing, it is not clear that a robust algorithm exists within CASA for choosing a reference antenna if the user has not specified one.<br />
<br />
* How much flagging should be done? The script does some simple clipping, designed to remove any egregious RFI or horribly performing antenna or baseline. This clipping is done in terms of the rms visibility amplitude in the science target data, flagging data above some large threshold (e.g., 50<math>\sigma</math>). This threshold is under user control, but the current flagging in this script is certainly not equal to a human lovingly massaging the visibility data.<br />
<br />
== Processing Steps ==<br />
<br />
1. Read the data from the ASDM file converting to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
<source lang="python"><br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
</source><br />
<br />
2. Flag first (dummy) scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
</source><br />
<br />
3. Flag first 10 seconds of each scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
</source><br />
<br />
4. Extract various useful quantities from the data.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['acal'])<br />
acal_name=hdvalue[0]<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
<br />
##############################<br />
# How much time-average smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 2 of Bridle<br />
# & Schwab (1999).<br />
#<br />
time_smearing_loss=0.01<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=min(interval)<br />
<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer<br />
# multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
##############################<br />
# How much bandwidth<br />
# smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of<br />
# primary beam.<br />
# Follow Section 1 of Bridle<br />
# & Schwab (1999).<br />
# Assume square bandpass, no<br />
# taper, expand resulting<br />
# sine integral to lowest order<br />
#<br />
band_smearing_loss=0.01<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
</source><br />
<br />
5. Compress data for faster processing.<br />
<br />
<source lang="python"><br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
timebin=tave,width=int(nchav))<br />
</source><br />
<br />
6. Set flux density of amplitude calibrator.<br />
Need some heuristics here.<br />
Also could be an issue if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate.<br />
<br />
<source lang="python"><br />
for tstname in acal_std_name.keys():<br />
if acal_name in acal_std_name[tstname]:<br />
modimage=tstname<br />
modimage=CalModels + '/' + modimage + '_' + band + '.im'<br />
setjy(vis=outmsname,field=sources['acal'],modimage=modimage)<br />
</source><br />
<br />
<br />
7. Quick-n-dirty bandpass<br />
<br />
<source lang="python"><br />
Bcaltable=ASDM_name + '.B1'<br />
Gcaltable=ASDM_name + '.G0'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='int',refant=refant,<br />
solnorm=T,calmode='p',minsnr=5)<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
gaintable=[Gcaltable])<br />
</source><br />
<br />
<br />
8. amplitude and phase calibration<br />
<br />
<source lang="python"><br />
Gcaltable=ASDM_name + '.G1'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
minsnr=5,<br />
gaintable=[Bcaltable])<br />
<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['pcal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
append=T,<br />
gaintable=[Bcaltable])<br />
</source><br />
<br />
<br />
9. Apply calibration.<br />
<br />
<source lang="python"><br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
</source><br />
<br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4158Transient reduction pipeline2010-06-20T16:42:06Z<p>Jlazio: /* Transient Reduction Pipeline */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 20 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
I've restructured the document to describe the processing steps (conceptually) first, then list the actual script itself.<br />
<br />
== User Input ==<br />
<br />
0. Initial set up, advice and warnings, and sanity checks.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import os.path, math<br />
#<br />
Version='v. 0.1 TJWL 2010-06-16'<br />
CalModels='/home/casa/data/nrao/VLA/CalModels'<br />
c=2.99792458E8<br />
D=24.5<br />
degrad=180/pi<br />
arcsecond_deg=3600<br />
#<br />
print " "<br />
print "EVLA Transient Reduction Pipeline"<br />
print " "<br />
print Version<br />
print " "<br />
print "Warning: This script was written at the time that the"<br />
print "EVLA was undergoing commissioning. Details may change."<br />
print "Caveat emptor!"<br />
print " "<br />
print "Assumption: Data stored as an ALMA Science Data Model (ASDM)"<br />
print " file on disk."<br />
print " "<br />
print "Assumption: Sources, listed in order of appearance, are structured"<br />
print " as Option A or Option B"<br />
print " Option A: phase calibrator"<br />
print " target source"<br />
print " amplitude calibrator"<br />
print " "<br />
print " Option B: amplitude calibrator"<br />
print " phase calibrator"<br />
print " target source"<br />
print " "<br />
#<br />
print "Assumption: Calibrator model files stored in "<br />
print CalModels<br />
if not os.path.isdir(CalModels):<br />
raise IOError('Calibrator model files missing? Stopping.')<br />
#<br />
print " "<br />
acal_std_name = {}<br />
acal_std_name['3C286'] = frozenset(['3C286','3C 286',<br />
'1328+30','1328+307','B1328+307','B1328+30',<br />
'1331+305','J1331+305','J1331+3030'])<br />
acal_std_name['3C138'] = frozenset(['3C138','3C 138',<br />
'0518+16','0518+165','0518+1635','B0518+16','B0518+165','B0518+1635',<br />
'0521+166','0521+1638','J0521+166','J0521+1638'])<br />
acal_std_name['3C147'] = frozenset(['3C147','3C 147',<br />
'0538+49','0538+498','0538+4949','B0538+49','B0538+498','B0538+4949',<br />
'0542+498','0542+4951','J0542+498','J0542+4951'])<br />
acal_std_name['3C48'] = frozenset(['3C48','3C 48',<br />
'0134+32','0134+329','0134+3254','B0134+32','B0134+329','B0134+3254',<br />
'0137+331','0137+3309','J0137+331','J0137+3309'])<br />
</source><br />
<br />
1. Obtain the name of the ASDM file, use it to construct the Measurement Set name.<br />
<br />
<source lang="python"><br />
# In CASA<br />
ASDM_name=raw_input('ASDM file name:')<br />
msname=ASDM_name+'.ms'<br />
</source><br />
<br />
2. Determine the order in which sources appear in the observation.<br />
<br />
<source lang="python"><br />
# In CASA<br />
obs_structure=raw_input('Structure of observations [A|B]:')<br />
if obs_structure == 'A':<br />
sources = {'acal':'2', 'pcal':'0', 'target':'1'}<br />
elif obs_structure == 'B':<br />
sources = {'acal':'0', 'pcal':'1', 'target':'2'}<br />
</source><br />
<br />
3. Reference antenna. (Should be able to determine this from the measurement set?!)<br />
<br />
<source lang="python"><br />
# In CASA<br />
refant=raw_input('Enter desired reference antenna [e.g., ea21]: ')<br />
</source><br />
<br />
== Processing Steps ==<br />
<br />
1. Read the data from the ASDM file converting to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
<source lang="python"><br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
</source><br />
<br />
2. Flag first (dummy) scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
</source><br />
<br />
3. Flag first 10 seconds of each scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
</source><br />
<br />
4. Extract various useful quantities from the data.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['acal'])<br />
acal_name=hdvalue[0]<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
<br />
##############################<br />
# How much time-average smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 2 of Bridle<br />
# & Schwab (1999).<br />
#<br />
time_smearing_loss=0.01<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=min(interval)<br />
<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer<br />
# multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
##############################<br />
# How much bandwidth<br />
# smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of<br />
# primary beam.<br />
# Follow Section 1 of Bridle<br />
# & Schwab (1999).<br />
# Assume square bandpass, no<br />
# taper, expand resulting<br />
# sine integral to lowest order<br />
#<br />
band_smearing_loss=0.01<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
</source><br />
<br />
5. Compress data for faster processing.<br />
<br />
<source lang="python"><br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
timebin=tave,width=int(nchav))<br />
</source><br />
<br />
6. Set flux density of amplitude calibrator.<br />
Need some heuristics here.<br />
Also could be an issue if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate.<br />
<br />
<source lang="python"><br />
for tstname in acal_std_name.keys():<br />
if acal_name in acal_std_name[tstname]:<br />
modimage=tstname<br />
modimage=CalModels + '/' + modimage + '_' + band + '.im'<br />
setjy(vis=outmsname,field=sources['acal'],modimage=modimage)<br />
</source><br />
<br />
<br />
7. Quick-n-dirty bandpass<br />
<br />
<source lang="python"><br />
Bcaltable=ASDM_name + '.B1'<br />
Gcaltable=ASDM_name + '.G0'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='int',refant=refant,<br />
solnorm=T,calmode='p',minsnr=5)<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
gaintable=[Gcaltable])<br />
</source><br />
<br />
<br />
8. amplitude and phase calibration<br />
<br />
<source lang="python"><br />
Gcaltable=ASDM_name + '.G1'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
minsnr=5,<br />
gaintable=[Bcaltable])<br />
<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['pcal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
append=T,<br />
gaintable=[Bcaltable])<br />
</source><br />
<br />
<br />
9. Apply calibration.<br />
<br />
<source lang="python"><br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
</source><br />
<br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4157Transient reduction pipeline2010-06-16T23:09:00Z<p>Jlazio: c</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 16 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
<br />
<br />
== User Input ==<br />
<br />
0. Initial set up, advice and warnings, and sanity checks.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import os.path, math<br />
#<br />
Version='v. 0.1 TJWL 2010-06-16'<br />
CalModels='/home/casa/data/nrao/VLA/CalModels'<br />
c=2.99792458E8<br />
D=24.5<br />
degrad=180/pi<br />
arcsecond_deg=3600<br />
#<br />
print " "<br />
print "EVLA Transient Reduction Pipeline"<br />
print " "<br />
print Version<br />
print " "<br />
print "Warning: This script was written at the time that the"<br />
print "EVLA was undergoing commissioning. Details may change."<br />
print "Caveat emptor!"<br />
print " "<br />
print "Assumption: Data stored as an ALMA Science Data Model (ASDM)"<br />
print " file on disk."<br />
print " "<br />
print "Assumption: Sources, listed in order of appearance, are structured"<br />
print " as Option A or Option B"<br />
print " Option A: phase calibrator"<br />
print " target source"<br />
print " amplitude calibrator"<br />
print " "<br />
print " Option B: amplitude calibrator"<br />
print " phase calibrator"<br />
print " target source"<br />
print " "<br />
#<br />
print "Assumption: Calibrator model files stored in "<br />
print CalModels<br />
if not os.path.isdir(CalModels):<br />
raise IOError('Calibrator model files missing? Stopping.')<br />
#<br />
print " "<br />
acal_std_name = {}<br />
acal_std_name['3C286'] = frozenset(['3C286','3C 286',<br />
'1328+30','1328+307','B1328+307','B1328+30',<br />
'1331+305','J1331+305','J1331+3030'])<br />
acal_std_name['3C138'] = frozenset(['3C138','3C 138',<br />
'0518+16','0518+165','0518+1635','B0518+16','B0518+165','B0518+1635',<br />
'0521+166','0521+1638','J0521+166','J0521+1638'])<br />
acal_std_name['3C147'] = frozenset(['3C147','3C 147',<br />
'0538+49','0538+498','0538+4949','B0538+49','B0538+498','B0538+4949',<br />
'0542+498','0542+4951','J0542+498','J0542+4951'])<br />
acal_std_name['3C48'] = frozenset(['3C48','3C 48',<br />
'0134+32','0134+329','0134+3254','B0134+32','B0134+329','B0134+3254',<br />
'0137+331','0137+3309','J0137+331','J0137+3309'])<br />
</source><br />
<br />
1. Obtain the name of the ASDM file, use it to construct the Measurement Set name.<br />
<br />
<source lang="python"><br />
# In CASA<br />
ASDM_name=raw_input('ASDM file name:')<br />
msname=ASDM_name+'.ms'<br />
</source><br />
<br />
2. Determine the order in which sources appear in the observation.<br />
<br />
<source lang="python"><br />
# In CASA<br />
obs_structure=raw_input('Structure of observations [A|B]:')<br />
if obs_structure == 'A':<br />
sources = {'acal':'2', 'pcal':'0', 'target':'1'}<br />
elif obs_structure == 'B':<br />
sources = {'acal':'0', 'pcal':'1', 'target':'2'}<br />
</source><br />
<br />
3. Reference antenna. (Should be able to determine this from the measurement set?!)<br />
<br />
<source lang="python"><br />
# In CASA<br />
refant=raw_input('Enter desired reference antenna [e.g., ea21]: ')<br />
</source><br />
<br />
== Processing Steps ==<br />
<br />
1. Read the data from the ASDM file converting to a Measurement Set with <tt>importevla</tt>. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
<source lang="python"><br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
</source><br />
<br />
2. Flag first (dummy) scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
</source><br />
<br />
3. Flag first 10 seconds of each scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
</source><br />
<br />
4. Extract various useful quantities from the data.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['acal'])<br />
acal_name=hdvalue[0]<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
<br />
##############################<br />
# How much time-average smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of primary beam.<br />
# Follow Section 2 of Bridle<br />
# & Schwab (1999).<br />
#<br />
time_smearing_loss=0.01<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=min(interval)<br />
<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer<br />
# multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
##############################<br />
# How much bandwidth<br />
# smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of<br />
# primary beam.<br />
# Follow Section 1 of Bridle<br />
# & Schwab (1999).<br />
# Assume square bandpass, no<br />
# taper, expand resulting<br />
# sine integral to lowest order<br />
#<br />
band_smearing_loss=0.01<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
</source><br />
<br />
5. Compress data for faster processing.<br />
<br />
<source lang="python"><br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
timebin=tave,width=int(nchav))<br />
</source><br />
<br />
6. Set flux density of amplitude calibrator.<br />
Need some heuristics here.<br />
Also could be an issue if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate.<br />
<br />
<source lang="python"><br />
for tstname in acal_std_name.keys():<br />
if acal_name in acal_std_name[tstname]:<br />
modimage=tstname<br />
modimage=CalModels + '/' + modimage + '_' + band + '.im'<br />
setjy(vis=outmsname,field=sources['acal'],modimage=modimage)<br />
</source><br />
<br />
<br />
7. Quick-n-dirty bandpass<br />
<br />
<source lang="python"><br />
Bcaltable=ASDM_name + '.B1'<br />
Gcaltable=ASDM_name + '.G0'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='int',refant=refant,<br />
solnorm=T,calmode='p',minsnr=5)<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
gaintable=[Gcaltable])<br />
</source><br />
<br />
<br />
8. amplitude and phase calibration<br />
<br />
<source lang="python"><br />
Gcaltable=ASDM_name + '.G1'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
minsnr=5,<br />
gaintable=[Bcaltable])<br />
<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['pcal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
append=T,<br />
gaintable=[Bcaltable])<br />
</source><br />
<br />
<br />
9. Apply calibration.<br />
<br />
<source lang="python"><br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, Gcaltable],<br />
gainfield=[' ', sources['pcal']],<br />
calwt=F)<br />
</source><br />
<br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4156Transient reduction pipeline2010-06-16T22:59:07Z<p>Jlazio: /* User Input */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 16 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
<br />
<br />
== User Input ==<br />
<br />
0. Initial set up, advice and warnings, and sanity checks.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import os.path, math<br />
#<br />
Version='v. 0.1 TJWL 2010-06-16'<br />
CalModels='/home/casa/data/nrao/VLA/CalModels'<br />
c=2.99792458E8<br />
D=24.5<br />
degrad=180/pi<br />
arcsecond_deg=3600<br />
#<br />
print " "<br />
print "EVLA Transient Reduction Pipeline"<br />
print " "<br />
print Version<br />
print " "<br />
print "Warning: This script was written at the time that the"<br />
print "EVLA was undergoing commissioning. Details may change."<br />
print "Caveat emptor!"<br />
print " "<br />
print "Assumption: Data stored as an ALMA Science Data Model (ASDM)"<br />
print " file on disk."<br />
print " "<br />
print "Assumption: Sources, listed in order of appearance, are structured"<br />
print " as Option A or Option B"<br />
print " Option A: phase calibrator"<br />
print " target source"<br />
print " amplitude calibrator"<br />
print " "<br />
print " Option B: amplitude calibrator"<br />
print " phase calibrator"<br />
print " target source"<br />
print " "<br />
#<br />
print "Assumption: Calibrator model files stored in "<br />
print CalModels<br />
if not os.path.isdir(CalModels):<br />
raise IOError('Calibrator model files missing? Stopping.')<br />
#<br />
print " "<br />
acal_std_name = {}<br />
acal_std_name['3C286'] = frozenset(['3C286','3C 286',<br />
'1328+30','1328+307','B1328+307','B1328+30',<br />
'1331+305','J1331+305','J1331+3030'])<br />
acal_std_name['3C138'] = frozenset(['3C138','3C 138',<br />
'0518+16','0518+165','0518+1635','B0518+16','B0518+165','B0518+1635',<br />
'0521+166','0521+1638','J0521+166','J0521+1638'])<br />
acal_std_name['3C147'] = frozenset(['3C147','3C 147',<br />
'0538+49','0538+498','0538+4949','B0538+49','B0538+498','B0538+4949',<br />
'0542+498','0542+4951','J0542+498','J0542+4951'])<br />
acal_std_name['3C48'] = frozenset(['3C48','3C 48',<br />
'0134+32','0134+329','0134+3254','B0134+32','B0134+329','B0134+3254',<br />
'0137+331','0137+3309','J0137+331','J0137+3309'])<br />
</source><br />
<br />
1. Obtain the name of the ASDM file, use it to construct the Measurement Set name.<br />
<br />
<source lang="python"><br />
# In CASA<br />
ASDM_name=raw_input('ASDM file name:')<br />
msname=ASDM_name+'.ms'<br />
</source><br />
<br />
2. Determine the order in which sources appear in the observation.<br />
<br />
<source lang="python"><br />
# In CASA<br />
obs_structure=raw_input('Structure of observations [A|B]:')<br />
if obs_structure == 'A':<br />
sources = {'acal':'2', 'pcal':'0', 'target':'1'}<br />
elif obs_structure == 'B':<br />
sources = {'acal':'0', 'pcal':'1', 'target':'2'}<br />
</source><br />
<br />
3. Reference antenna. (Should be able to determine this from the measurement set?!)<br />
<br />
<source lang="python"><br />
# In CASA<br />
refant=raw_input('Enter desired reference antenna [e.g., ea21]: ')<br />
</source><br />
<br />
== Processing Steps ==<br />
<br />
1. Read the data from the ASDM file converting to a Measurement Set with ''importevla''. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
<source lang="python"><br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
</source><br />
<br />
2. Flag first (dummy) scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
</source><br />
<br />
3. Flag first 10 seconds of each scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
</source><br />
<br />
4. Extract various useful quantities from the data.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['acal'])<br />
acal_name=hdvalue[0]<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
<br />
##############################<br />
# How much time-average<br />
# smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of<br />
# primary beam.<br />
# Follow Section 2 of Bridle<br />
# & Schwab (1999).<br />
#<br />
time_smearing_loss=0.01<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=interval[0]<br />
for dtprime in interval:<br />
if dtprime < dt:<br />
dt=dtprime<br />
<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer<br />
# multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
##############################<br />
# How much bandwidth<br />
# smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of<br />
# primary beam.<br />
# Follow Section 1 of Bridle<br />
# & Schwab (1999).<br />
# Assume square bandpass, no<br />
# taper, expand resulting<br />
# sine integral to lowest order<br />
#<br />
band_smearing_loss=0.01<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
</source><br />
<br />
5. Compress data for faster processing.<br />
<br />
<source lang="python"><br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
timebin=tave,width=int(nchav))<br />
</source><br />
<br />
6. Set flux density of amplitude calibrator.<br />
Need some heuristics here.<br />
Also could be an issue if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate.<br />
<br />
<source lang="python"><br />
for tstname in acal_std_name.keys():<br />
if acal_name in acal_std_name[tstname]:<br />
modimage=tstname<br />
modimage=CalModels + '/' + modimage + '_' + band + '.im'<br />
setjy(vis=outmsname,field=sources['acal'],modimage=modimage)<br />
</source><br />
<br />
<br />
7. Quick-n-dirty bandpass<br />
<br />
<source lang="python"><br />
Bcaltable=ASDM_name + '.B1'<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
bandtype='B',<br />
append=F)<br />
</source><br />
<br />
<br />
8. amplitude and phase calibration<br />
<br />
<source lang="python"><br />
Gcaltable=ASDM_name + '.G1'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
solnorm=F,<br />
gaintype='G',calmode='ap',<br />
append=F,<br />
gaintable=Bcaltable)<br />
<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['pcal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
solnorm=F,<br />
gaintype='G',calmode='ap',<br />
append=T,<br />
gaintable=Bcaltable)<br />
</source><br />
<br />
<br />
9. Apply calibration.<br />
<br />
<source lang="python"><br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'],<br />
append=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, Gcaltable])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, Gcaltable])<br />
</source><br />
<br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4155Transient reduction pipeline2010-06-16T22:57:10Z<p>Jlazio: /* Transient Reduction Pipeline */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 16 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an Archive Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
<br />
<br />
== User Input ==<br />
<br />
0. Initial set up, advice and warnings, and sanity checks.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import os.path, math<br />
#<br />
Version='v. 0.0 TJWL 2010-05-11'<br />
CalModels='/home/casa/data/nrao/VLA/CalModels'<br />
c=2.99792458E8<br />
D=24.5<br />
degrad=180/pi<br />
arcsecond_deg=3600<br />
#<br />
print " "<br />
print "EVLA Transient Reduction Pipeline"<br />
print " "<br />
print Version<br />
print " "<br />
print "Warning: This script was written at the time that the"<br />
print "EVLA was undergoing commissioning. Details may change."<br />
print "Caveat emptor!"<br />
print " "<br />
print "Assumption: Data stored as an ALMA Science Data Model (ASDM)"<br />
print " file on disk."<br />
print " "<br />
print "Assumption: Sources, listed in order of appearance, are structured"<br />
print " as Option A or Option B"<br />
print " Option A: phase calibrator"<br />
print " target source"<br />
print " amplitude calibrator"<br />
print " "<br />
print " Option B: amplitude calibrator"<br />
print " phase calibrator"<br />
print " target source"<br />
print " "<br />
#<br />
print "Assumption: Calibrator model files stored in "<br />
print CalModels<br />
if not os.path.isdir(CalModels):<br />
raise IOError('Calibrator model files missing? Stopping.')<br />
#<br />
print " "<br />
acal_std_name = {}<br />
acal_std_name['3C286'] = frozenset(['3C286','3C 286',<br />
'1328+30','1328+307','B1328+307','B1328+30',<br />
'1331+305','J1331+305','J1331+3030'])<br />
acal_std_name['3C138'] = frozenset(['3C138','3C 138',<br />
'0518+16','0518+165','0518+1635','B0518+16','B0518+165','B0518+1635',<br />
'0521+166','0521+1638','J0521+166','J0521+1638'])<br />
acal_std_name['3C147'] = frozenset(['3C147','3C 147',<br />
'0538+49','0538+498','0538+4949','B0538+49','B0538+498','B0538+4949',<br />
'0542+498','0542+4951','J0542+498','J0542+4951'])<br />
acal_std_name['3C48'] = frozenset(['3C48','3C 48',<br />
'0134+32','0134+329','0134+3254','B0134+32','B0134+329','B0134+3254',<br />
'0137+331','0137+3309','J0137+331','J0137+3309'])<br />
</source><br />
<br />
1. Obtain the name of the ASDM file, use it to construct the Measurement Set name.<br />
<br />
<source lang="python"><br />
# In CASA<br />
ASDM_name=raw_input('ASDM file name:')<br />
msname=ASDM_name+'.ms'<br />
</source><br />
<br />
2. Determine the order in which sources appear in the observation.<br />
<br />
<source lang="python"><br />
# In CASA<br />
obs_structure=raw_input('Structure of observations [A|B]:')<br />
if obs_structure == 'A':<br />
sources = {'acal':'2', 'pcal':'0', 'target':'1'}<br />
elif obs_structure == 'B':<br />
sources = {'acal':'0', 'pcal':'1', 'target':'2'}<br />
</source><br />
<br />
3. Reference antenna. (Should be able to determine this from the measurement set!!)<br />
<br />
<source lang="python"><br />
# In CASA<br />
refant=raw_input('Enter desired reference antenna [e.g., ea21]: ')<br />
</source><br />
<br />
== Processing Steps ==<br />
<br />
1. Read the data from the ASDM file converting to a Measurement Set with ''importevla''. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
<source lang="python"><br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
</source><br />
<br />
2. Flag first (dummy) scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
</source><br />
<br />
3. Flag first 10 seconds of each scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
</source><br />
<br />
4. Extract various useful quantities from the data.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['acal'])<br />
acal_name=hdvalue[0]<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
<br />
##############################<br />
# How much time-average<br />
# smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of<br />
# primary beam.<br />
# Follow Section 2 of Bridle<br />
# & Schwab (1999).<br />
#<br />
time_smearing_loss=0.01<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=interval[0]<br />
for dtprime in interval:<br />
if dtprime < dt:<br />
dt=dtprime<br />
<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer<br />
# multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
##############################<br />
# How much bandwidth<br />
# smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of<br />
# primary beam.<br />
# Follow Section 1 of Bridle<br />
# & Schwab (1999).<br />
# Assume square bandpass, no<br />
# taper, expand resulting<br />
# sine integral to lowest order<br />
#<br />
band_smearing_loss=0.01<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
</source><br />
<br />
5. Compress data for faster processing.<br />
<br />
<source lang="python"><br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
timebin=tave,width=int(nchav))<br />
</source><br />
<br />
6. Set flux density of amplitude calibrator.<br />
Need some heuristics here.<br />
Also could be an issue if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate.<br />
<br />
<source lang="python"><br />
for tstname in acal_std_name.keys():<br />
if acal_name in acal_std_name[tstname]:<br />
modimage=tstname<br />
modimage=CalModels + '/' + modimage + '_' + band + '.im'<br />
setjy(vis=outmsname,field=sources['acal'],modimage=modimage)<br />
</source><br />
<br />
<br />
7. Quick-n-dirty bandpass<br />
<br />
<source lang="python"><br />
Bcaltable=ASDM_name + '.B1'<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
bandtype='B',<br />
append=F)<br />
</source><br />
<br />
<br />
8. amplitude and phase calibration<br />
<br />
<source lang="python"><br />
Gcaltable=ASDM_name + '.G1'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
solnorm=F,<br />
gaintype='G',calmode='ap',<br />
append=F,<br />
gaintable=Bcaltable)<br />
<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['pcal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
solnorm=F,<br />
gaintype='G',calmode='ap',<br />
append=T,<br />
gaintable=Bcaltable)<br />
</source><br />
<br />
<br />
9. Apply calibration.<br />
<br />
<source lang="python"><br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'],<br />
append=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, Gcaltable])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, Gcaltable])<br />
</source><br />
<br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Transient_reduction_pipeline&diff=4154Transient reduction pipeline2010-06-16T22:56:37Z<p>Jlazio: /* Transient Reduction Pipeline */</p>
<hr />
<div>[[Category: EVLA]]<br />
<br />
= Transient Reduction Pipeline =<br />
<br />
2010 June 16 - T. Joseph W. Lazio<br />
<br />
There are a class of observations for which only relatively simple data reduction steps are needed. One such example is that of transient observations, which are typically conducted in continuum mode and for which one is merely trying to determine a flux density of an essentially unresolved or only partially resolved source. This guide describes the steps in such a pipeline.<br />
<br />
<strong>Warning: This guide was written at the time when the EVLA was still in its commissioning phase. As the instrument matures, specific steps taken here may need to be adjusted. Caveat emptor.</strong><br />
<br />
In order to process these data in a semi-automatic fashion, certain assumptions are made<br />
* Data stored as an ALMA Science Data Model (ASDM) file on disk.<br />
* Sources, listed in order of appearance, are structured as Option A or Option B<br />
** Option A: phase calibrator, target source, amplitude calibrator<br />
** Option B: amplitude calibrator, phase calibrator, target source<br />
<br />
This guide should be set up so that a pipeline script can be [[Extracting_scripts_from_these_tutorials | extracted]] from it.<br />
<br />
<br />
Possible issues include <br />
* <tt>calwt=F</tt> because at the time of writing the EVLA is not reporting accurate weights (though I believe that this has a stronger effect on extended sources rather than compact sources);<br />
* the pipeline assumes the same number of channels per spectral window;<br />
* the pipeline assumes that the first scan is a dummy scan, as such is required at the time of writing.<br />
<br />
<br />
<br />
== User Input ==<br />
<br />
0. Initial set up, advice and warnings, and sanity checks.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import os.path, math<br />
#<br />
Version='v. 0.0 TJWL 2010-05-11'<br />
CalModels='/home/casa/data/nrao/VLA/CalModels'<br />
c=2.99792458E8<br />
D=24.5<br />
degrad=180/pi<br />
arcsecond_deg=3600<br />
#<br />
print " "<br />
print "EVLA Transient Reduction Pipeline"<br />
print " "<br />
print Version<br />
print " "<br />
print "Warning: This script was written at the time that the"<br />
print "EVLA was undergoing commissioning. Details may change."<br />
print "Caveat emptor!"<br />
print " "<br />
print "Assumption: Data stored as an ALMA Science Data Model (ASDM)"<br />
print " file on disk."<br />
print " "<br />
print "Assumption: Sources, listed in order of appearance, are structured"<br />
print " as Option A or Option B"<br />
print " Option A: phase calibrator"<br />
print " target source"<br />
print " amplitude calibrator"<br />
print " "<br />
print " Option B: amplitude calibrator"<br />
print " phase calibrator"<br />
print " target source"<br />
print " "<br />
#<br />
print "Assumption: Calibrator model files stored in "<br />
print CalModels<br />
if not os.path.isdir(CalModels):<br />
raise IOError('Calibrator model files missing? Stopping.')<br />
#<br />
print " "<br />
acal_std_name = {}<br />
acal_std_name['3C286'] = frozenset(['3C286','3C 286',<br />
'1328+30','1328+307','B1328+307','B1328+30',<br />
'1331+305','J1331+305','J1331+3030'])<br />
acal_std_name['3C138'] = frozenset(['3C138','3C 138',<br />
'0518+16','0518+165','0518+1635','B0518+16','B0518+165','B0518+1635',<br />
'0521+166','0521+1638','J0521+166','J0521+1638'])<br />
acal_std_name['3C147'] = frozenset(['3C147','3C 147',<br />
'0538+49','0538+498','0538+4949','B0538+49','B0538+498','B0538+4949',<br />
'0542+498','0542+4951','J0542+498','J0542+4951'])<br />
acal_std_name['3C48'] = frozenset(['3C48','3C 48',<br />
'0134+32','0134+329','0134+3254','B0134+32','B0134+329','B0134+3254',<br />
'0137+331','0137+3309','J0137+331','J0137+3309'])<br />
</source><br />
<br />
1. Obtain the name of the ASDM file, use it to construct the Measurement Set name.<br />
<br />
<source lang="python"><br />
# In CASA<br />
ASDM_name=raw_input('ASDM file name:')<br />
msname=ASDM_name+'.ms'<br />
</source><br />
<br />
2. Determine the order in which sources appear in the observation.<br />
<br />
<source lang="python"><br />
# In CASA<br />
obs_structure=raw_input('Structure of observations [A|B]:')<br />
if obs_structure == 'A':<br />
sources = {'acal':'2', 'pcal':'0', 'target':'1'}<br />
elif obs_structure == 'B':<br />
sources = {'acal':'0', 'pcal':'1', 'target':'2'}<br />
</source><br />
<br />
3. Reference antenna. (Should be able to determine this from the measurement set!!)<br />
<br />
<source lang="python"><br />
# In CASA<br />
refant=raw_input('Enter desired reference antenna [e.g., ea21]: ')<br />
</source><br />
<br />
== Processing Steps ==<br />
<br />
1. Read the data from the ASDM file converting to a Measurement Set with ''importevla''. Apply basic flagging operations (zeros, shadowing) here.<br />
<br />
<source lang="python"><br />
importevla(asdm=ASDM_name, vis=msname,<br />
flagzero=True, flagpol=True, shadow=True)<br />
</source><br />
<br />
2. Flag first (dummy) scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='manualflag',selectdata=T, scan='1')<br />
</source><br />
<br />
3. Flag first 10 seconds of each scan.<br />
<br />
<source lang="python"><br />
flagdata(vis=msname,<br />
mode='quack',quackinterval=10,quackmode='beg',<br />
selectdata=F)<br />
</source><br />
<br />
4. Extract various useful quantities from the data.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['acal'])<br />
acal_name=hdvalue[0]<br />
<br />
spw_table=msname + '/SPECTRAL_WINDOW'<br />
tb.open(spw_table)<br />
freq_list=tb.getcol("REF_FREQUENCY")<br />
channel_width=tb.getcol("CHAN_WIDTH")<br />
num_chan=tb.getcol("NUM_CHAN")<br />
tb.close(spw_table)<br />
freq=freq_list[0]<br />
if (1E9 < freq) and (freq < 2E9):<br />
band = 'L'<br />
elif (2E9 < freq) and (freq < 4E9):<br />
band = 'S'<br />
elif (4E9 < freq) and (freq < 8E9):<br />
band='C'<br />
elif (8E9 < freq) and (freq < 12E9):<br />
band='X'<br />
elif (12E9 < freq) and (freq < 40E9):<br />
band = 'K'<br />
elif freq > 40E9:<br />
band = 'Q'<br />
print "Observations are determined to be in the ", band, " band.\n"<br />
<br />
<br />
wavelength=c/freq<br />
primary_beam=(1.02*wavelength/D)*degrad # HPBW, from Napier (1999)<br />
<br />
tb.open(msname)<br />
uvw=tb.getcol('UVW')<br />
interval=tb.getcol('INTERVAL')<br />
tb.close(msname)<br />
<br />
b=[]<br />
for u, v, w in zip(uvw[0], uvw[1], uvw[2]):<br />
b.append(math.sqrt(u*u+v*v)/wavelength)<br />
bmax=max(b)<br />
# HPBW, synthesized beam,<br />
# from Bridle & Schwab (1999)<br />
synthesized_beam=(1.2/bmax)*degrad*arcsecond_deg<br />
<br />
<br />
##############################<br />
# How much time-average<br />
# smearing can be tolerated?<br />
# Assume no more than time_smearing_loss peak<br />
# intensity loss over half of<br />
# primary beam.<br />
# Follow Section 2 of Bridle<br />
# & Schwab (1999).<br />
#<br />
time_smearing_loss=0.01<br />
FoV=(primary_beam/math.sqrt(2))*arcsecond_deg<br />
tau=math.sqrt(time_smearing_loss*1E9)*(synthesized_beam/FoV)<br />
<br />
arbitrary_maximum=30<br />
if tau > arbitrary_maximum:<br />
tau=arbitrary_maximum<br />
<br />
dt=interval[0]<br />
for dtprime in interval:<br />
if dtprime < dt:<br />
dt=dtprime<br />
<br />
# tau is allowed value, dt is actual (minimum)<br />
# (could be an issue if baseline-dependent<br />
# correlator accumulation used)<br />
# make sure that tau is an integer<br />
# multiple of dt<br />
# <br />
tau=dt*math.floor(tau/dt)<br />
if tau < dt:<br />
tau=dt<br />
<br />
print "Data will be averaged in time."<br />
print "Original time sampling [s]: ", dt<br />
print "Averaging time [s]: ", tau<br />
print " "<br />
<br />
##############################<br />
# How much bandwidth<br />
# smearing can be tolerated?<br />
# Assume no more than band_smearing_loss peak<br />
# intensity loss over half of<br />
# primary beam.<br />
# Follow Section 1 of Bridle<br />
# & Schwab (1999).<br />
# Assume square bandpass, no<br />
# taper, expand resulting<br />
# sine integral to lowest order<br />
#<br />
band_smearing_loss=0.01<br />
eta_band=3.79<br />
delta_nu=freq*(2/eta_band)*(synthesized_beam/FoV)*math.sqrt(18*band_smearing_loss)<br />
<br />
# delta_nu is allowed value,<br />
# figure out even divisibles of the actual<br />
# value, stored in num_chan that is smaller than<br />
# delta_nu<br />
# potential bug if uneven channel widths<br />
# used in different spectral windows<br />
<br />
dnu=channel_width[0][0]<br />
nchan_log2=math.log(num_chan[0],2)<br />
for i in range(int(nchan_log2-1), 0, -1):<br />
if (dnu*math.pow(2,i)) < delta_nu:<br />
nchav=math.pow(2,i)<br />
break<br />
<br />
if nchav < 1:<br />
nchav=1<br />
<br />
print "Data will be averaged in frequency."<br />
print "Original channel width [kHz]: ", min(channel_width[0])/1E3<br />
print "Averaged channel width [kHz]: ", (nchav*min(channel_width[0]))/1E3<br />
print "Number of channels: ", nchav<br />
</source><br />
<br />
5. Compress data for faster processing.<br />
<br />
<source lang="python"><br />
outmsname=ASDM_name+'_split.ms'<br />
tave='%.fs'%tau<br />
split(vis=msname,outputvis=outmsname,<br />
datacolumn='data',<br />
timebin=tave,width=int(nchav))<br />
</source><br />
<br />
6. Set flux density of amplitude calibrator.<br />
Need some heuristics here.<br />
Also could be an issue if the frequency setting is such that one should use a model image at a different band than one is observing, e.g., observing near the top of the C band where an X band model might be more appropriate.<br />
<br />
<source lang="python"><br />
for tstname in acal_std_name.keys():<br />
if acal_name in acal_std_name[tstname]:<br />
modimage=tstname<br />
modimage=CalModels + '/' + modimage + '_' + band + '.im'<br />
setjy(vis=outmsname,field=sources['acal'],modimage=modimage)<br />
</source><br />
<br />
<br />
7. Quick-n-dirty bandpass<br />
<br />
<source lang="python"><br />
Bcaltable=ASDM_name + '.B1'<br />
bandpass(vis=outmsname,caltable=Bcaltable,<br />
field=sources['acal'],<br />
solint='inf',combine='scan',refant=refant,<br />
solnorm=T,<br />
bandtype='B',<br />
append=F)<br />
</source><br />
<br />
<br />
8. amplitude and phase calibration<br />
<br />
<source lang="python"><br />
Gcaltable=ASDM_name + '.G1'<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['acal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
solnorm=F,<br />
gaintype='G',calmode='ap',<br />
append=F,<br />
gaintable=Bcaltable)<br />
<br />
gaincal(vis=outmsname,caltable=Gcaltable,<br />
field=sources['pcal'],<br />
solint='inf',refant=refant,<br />
minsnr=5,<br />
solnorm=F,<br />
gaintype='G',calmode='ap',<br />
append=T,<br />
gaintable=Bcaltable)<br />
</source><br />
<br />
<br />
9. Apply calibration.<br />
<br />
<source lang="python"><br />
fluxtable=ASDM_name + '.flux1'<br />
fluxscale(vis=outmsname,caltable=Gcaltable,fluxtable=fluxtable,<br />
reference=sources['acal'],<br />
transfer=sources['pcal'],<br />
append=F)<br />
<br />
applycal(vis=outmsname,<br />
field=sources['pcal'],<br />
gaintable=[Bcaltable, Gcaltable])<br />
<br />
applycal(vis=outmsname,<br />
field=sources['target'],<br />
gaintable=[Bcaltable, Gcaltable])<br />
</source><br />
<br />
<br />
10. Form target source measurement set.<br />
<br />
<source lang="python"><br />
hdvalue=vishead(vis=msname, mode='get',<br />
hdkey='field', hdindex=sources['target'])<br />
target_name=hdvalue[0]<br />
<br />
targetms=target_name + '.ms'<br />
split(vis=outmsname,outputvis=targetms,<br />
datacolumn='corrected',<br />
field=sources['target'])<br />
</source><br />
<br />
11. Image and CLEAN.<br />
<source lang="python"><br />
imagename=target_name + '.im'<br />
cells='%.3farcsec'%(synthesized_beam/4)<br />
<br />
clean(vis=targetms,imagename=imagename,<br />
mode='mfs',<br />
niter=300,<br />
psfmode='clark',<br />
imagermode='csclean',<br />
imsize=[1024,1024],cell=cells,<br />
stokes='IV',<br />
weighting='briggs',robust=-1)<br />
</source></div>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=4153EVLA Advanced Topics 3C3912010-06-16T21:49:55Z<p>Jlazio: /* 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 (see below). 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 I-only image is generated (3c391_ctm_spw0_I.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). Note that in the clean before the self-cal, we only image I so that any cleaned polarization does not affect the gaincal.<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_I',<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='I',<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 />
calwt=F)<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 />
* Care is required in the setting of <tt>imagename</tt>. If one has an image that already exists, CASA will continue CLEANing it, which is almost certainly not what one wants during self-calibration. Rather one wants a unique <tt>imagename</tt> for each pass of self-calibration.<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 />
* One should consider examining the solutions from [[gaincal]], using [[plotcal]], in order to assure one's self that the corrections are sensible. Smoothly varying phases are good, jumps are usually not. (However, because the phases are often plotted +/- 180 degrees, there can be apparent "jumps," if the phases are very near +180 deg or -180 deg.)<br />
<br />
* In the case of a mosaic, such as here, one should also verify that the solutions are of equal quality for all of the fields.<br />
<br />
== On Your Own: 3C391 second frequency and G93.3+6.9 ==<br />
<br />
Now that you have run through spw 0 of 3C391, you are ready to strike off on your own with other datasets. We have provided two options here, described below. The first option is simplest as it is the same object (different spectral window). But for a more rewarding challenge try the L-band dataset on G93.3+6.9!<br />
<br />
You can find the data in the [http://casa.nrao.edu/Data/Synth2010/AdvancedEVLAcont.tgz CASA repository]. Both datasets are contained in this "tarball". Note that these MSes do not have the scratch columns pre-made (to keep the sizes small) so you can do an inintial clearcal to force the creation (or wait until you first calibration task does it for you).<br />
<br />
1. 3C391 spw 1 (at 7.5 GHz)<br />
<br />
This is the second spectral window split off from the 3C391 dataset. You can process this as you did the first, but beware of RFI in this band! You will have to avoid it (through channel ranges) and/or edit it out. Once you have processed this data and imaged it, you can combine those images in immath to make a spectral index image (see above), or combine the two calibrated MSes in clean to make a deeper MFS image (this might be tricky). You can also look for signs of Faraday Rotation by searching for a polarization angle change between the two spw. Can you derive the "rotation measure" (RM)?<br />
<br />
2. Supernova Remnant G93.3+6.9 at L-band<br />
<br />
This is data taken at L-band of an entirely different Supernova Remnant, centered near 1400 MHz. You should be able to process this data in a very similar manner to the C-band data on 3C391. Note that we are not telling you what you will see in the image ahead of time - you'll have to try it to see! Here are some data reduction hints to help you along:<br />
<br />
* There is strong RFI in this spectral window of the original 2 spw dataset. You will need to find it (e.g. using plotms) and avoid it in imaging. You can also flag those channels using flagdata, but this is not necessary. Note that there is a single baseline that shows very strong interference, see if you can find it! You can flag it using the baseline syntax in flagdata (e.g. antenna='ea0x&ea0y').<br />
<br />
* We have not edited out bad or dead antennas for you (unlike in 3C391). You will need to find these using plotms and then flagdata them. One helpful plotms trick is to set antenna='ea01' and pick a few channels (like spw='0:30~33') and a single scan (e.g. scan='2~3') and plot the amp versus Antenna2 on the x-axis. You should see the bad antennas (the low ones). As a check set antenna='ea02' and repeat. Is it the same?<br />
<br />
* In spite of RFI, the antenna-based calibration is remarkably resilient to moderate to low RFI contamination (which tends to be baseline-based). So rather than flagging channels with RFI, you might try going ahead with calibration and seeing if the solutions make sense. We were able to calibrate this data without flagging channels (only getting the bad baseline noted above).<br />
<br />
* There is no observation of a flux or polarization angle calibrator like J1331+3030. You need to use setjy to set the I flux of the gain calibrator. We use the approximate flux density of 5.8 Jy for J2038+5119.<br />
<br />
* When it comes time to calibrate the polarization leakage, we are in good shape since J2038+5119 was observed through a range of parallactic angle (use plotms to plot versus ParAngle). Use poltype='Df+QU' to solve for leakage and the unknown polarization of this source. We do not know the true polarization angle of this source, so before doing poltype='Xf' use setjy to set the Q flux to 5.8Jy * fractional pol (determined in leakage polcal run). This will at least align the polarization when you image it.<br />
<br />
* The L-band field of view is much larger than at C-band. From the [http://evlaguides.nrao.edu/index.php?title=Category:Status EVLA Observation Status Summary] the resolution should be around 45" in D-config. Use a cellsize of 15" or smaller. What is the primary beam of the VLA at 1.4MHz? How big should you make your image? <br />
<br />
* As you clean you will see faint sources all over the field. Welcome to L-band imaging! This SNR has lots of structure - try both standard and multi-scale clean.<br />
<br />
== 3C391 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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4152EVLA Continuum Tutorial 3C3912010-06-16T21:42:30Z<p>Jlazio: /* Imaging */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
<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 />
<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.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-0938, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0938, 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 [[polcal]] is used for polarization calibration. 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 I, Q, and U values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The 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 />
gainfield=['','','J0319+4130'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* <strong>caltable='3c391_ctm_mosaic_10s_spw0.D1'</strong> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <strong>field='J0319+4130'</strong> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <strong>spw='0:5~58'</strong> : In this example, the edge channels are not used in finding the solution. Because the bandpass is one of the calibration tables being applied (in <tt>gaintable</tt>), this restriction is not necessary. However, if one restricts the spectral window here, it <em>must</em> also be restricted in the remainder of the calibration steps, particularly [[applycal]], otherwise the final data set will contain frequency channels for which the leakage terms have not been calibrated.<br />
* <strong>poltype='Df'</strong> : 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 (<tt>poltype='Df+QU</tt>).<br />
* <strong>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.G1']</strong> : 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 />
* <strong>gainfield=[' ',' ','J0319+4130']</strong> : The gain caltable that is being applied on the fly, <tt>3c391_ctm_mosaic_10s_spw0.G1</tt>, contains the solutions for multiple sources. Only the solutions from J0319+4130 should be applied to itself in the process of finding the polarization leakage terms.<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 />
==== Solving for the R-L polarization angle ====<br />
<br />
Having calibrated the instrumental polarization, the total polarization is now correct, but the <br />
R-L phase still needs to calibrated in order to obtain an accurate polarization position angle. We use the same task, {{polcal}}, but this time set <tt>poltype='Xf</tt>, which specifies a frequency-dependent (''f'') position angle (''X'') calibration, using the source J1331+3030 (a.k.a. 3C 286), whose position angle is known, 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 (<tt>3c391_ctm_mosaic_10s_spw0.D1</tt>) to the gain tables that 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 />
gainfield=[' ', ' ', 'J1331+3030', ' ')<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_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 />
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 />
* <strong>mode='mfs'</strong> : 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 />
* <strong>niter=5000</strong>, <strong>gain=0.1</strong>, <strong>threshold='1.0mJy'</strong> : Recall that the CLEAN gain is the amount by which a CLEAN component is subtracted during the CLEANing process. <tt>niter</tt> and <tt>threshold</tt> are (coupled) means of determining when to stop the CLEANing process, with <tt>niter</tt> specifying to find and subtract that many CLEAN components while <tt>threshold</tt> specifies a minimum flux density threshold a CLEAN component can have before CLEAN stops. See also <tt>interactive</tt> 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 />
* <strong>interactive=T</strong> : 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, <tt>interactive</tt> 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 <tt>niter</tt>, 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 the discussion below.<br />
* <strong>imsize=[576]</strong>, <strong>cell=['2.5arcsec']</strong> : See the discussion below regarding the setting of the image size and cell size.<br />
* <strong>stokes='IQUV'</strong>, <strong>psfmode='clarkstokes'</strong> : Separate images will be made in all four polarizations (total intensity I, linear polarizations Q and U, and circular polarization V), and, with <tt>psfmode='clarkstokes'</tt>, the Clark CLEAN algorithm will deconvolve each Stokes plane separately thereby making the polarization image more independent of the total intensity.<br />
* <strong>weighting='briggs'</strong>, <strong>robust=0.0</strong> : 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 />
* <strong>imagermode='mosaic'</strong>, <strong>ftmachine='mosaic'</strong> : 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 />
* <strong>multiscale=[0, 6, 18, 54]</strong>, <strong>smallscalebias=0.9</strong> : 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 <tt>multiscale</tt> 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 <tt>smallscalebias</tt> 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 to <tt>multiscale=[]</tt> 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 the left mouse button and <em>double-clicking</em> 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), hold down the right mouse button and trace out a rectangle around the source, then <em>double click</em> inside that rectangle to set it as a box. Note that the CLEAN box must turn <em>white</em> for it to be registered; if the box is not white, it has not been set! 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 polygonal icon highlighted in red (the oval on the right) shown in the figure. 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. <em>Double-click</em> inside this region and the green outline will turn white. You have now set the clean region. To toggle back to the rectangle tracer again, right-click on the icon circled in green (the oval on the left) shown in the figure. If you have made a mistake with your clean box, click on the "Erase" button, trace out a rectangle around your erroneous region, and <em>double click</em> 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 the 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 <tt>imagename</tt>. These include:<br />
* <tt>.image</tt> - 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 />
* <tt>.flux</tt> - effective response of the telescope (the primary beam)<br />
* <tt>.flux.pbcoverage</tt> - effective response of the full mosaic image<br />
* <tt>.mask</tt> - areas where [[clean]] has been allowed to search for emission<br />
* <tt>.model</tt> - sum of all the clean components, which also has been stored as the MODEL_DATA column in the measurement set<br />
* <tt>.psf</tt> - dirty beam, which is being deconvolved from the true sky brightness during the clean process<br />
* <tt>.residual</tt> - 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 (<tt>minpb</tt>)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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4151EVLA Continuum Tutorial 3C3912010-06-16T21:13:45Z<p>Jlazio: /* Imaging */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
<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 />
<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.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-0938, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0938, 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 [[polcal]] is used for polarization calibration. 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 I, Q, and U values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The 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 />
gainfield=['','','J0319+4130'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* <strong>caltable='3c391_ctm_mosaic_10s_spw0.D1'</strong> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <strong>field='J0319+4130'</strong> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <strong>spw='0:5~58'</strong> : In this example, the edge channels are not used in finding the solution. Because the bandpass is one of the calibration tables being applied (in <tt>gaintable</tt>), this restriction is not necessary. However, if one restricts the spectral window here, it <em>must</em> also be restricted in the remainder of the calibration steps, particularly [[applycal]], otherwise the final data set will contain frequency channels for which the leakage terms have not been calibrated.<br />
* <strong>poltype='Df'</strong> : 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 (<tt>poltype='Df+QU</tt>).<br />
* <strong>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.G1']</strong> : 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 />
* <strong>gainfield=[' ',' ','J0319+4130']</strong> : The gain caltable that is being applied on the fly, <tt>3c391_ctm_mosaic_10s_spw0.G1</tt>, contains the solutions for multiple sources. Only the solutions from J0319+4130 should be applied to itself in the process of finding the polarization leakage terms.<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 />
==== Solving for the R-L polarization angle ====<br />
<br />
Having calibrated the instrumental polarization, the total polarization is now correct, but the <br />
R-L phase still needs to calibrated in order to obtain an accurate polarization position angle. We use the same task, {{polcal}}, but this time set <tt>poltype='Xf</tt>, which specifies a frequency-dependent (''f'') position angle (''X'') calibration, using the source J1331+3030 (a.k.a. 3C 286), whose position angle is known, 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 (<tt>3c391_ctm_mosaic_10s_spw0.D1</tt>) to the gain tables that 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 />
gainfield=[' ', ' ', 'J1331+3030', ' ')<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_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 />
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 />
* <strong>mode='mfs'</strong> : 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 />
* <strong>niter=5000</strong>, <strong>gain=0.1</strong>, <strong>threshold='1.0mJy'</strong> : Recall that the CLEAN gain is the amount by which a CLEAN component is subtracted during the CLEANing process. <tt>niter</tt> and <tt>threshold</tt> are (coupled) means of determining when to stop the CLEANing process, with <tt>niter</tt> specifying to find and subtract that many CLEAN components while <tt>threshold</tt> specifies a minimum flux density threshold a CLEAN component can have before CLEAN stops. See also <tt>interactive</tt> 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 />
* <strong>interactive=T</strong> : 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, <tt>interactive</tt> 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 <tt>niter</tt>, 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 the discussion below.<br />
* <strong>imsize=[576]</strong>, <strong>cell=['2.5arcsec']</strong> : See the discussion below regarding the setting of the image size and cell size.<br />
* <strong>stokes='IQUV'</strong>, <strong>psfmode='clarkstokes'</strong> : Separate images will be made in all four polarizations (total intensity I, linear polarizations Q and U, and circular polarization V), and, with <tt>psfmode='clarkstokes'</tt>, the Clark CLEAN algorithm will deconvolve each Stokes plane separately thereby making the polarization image more independent of the total intensity.<br />
* <strong>weighting='briggs'</strong>, <strong>robust=0.0</strong> : 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 />
* <strong>imagermode='mosaic'</strong>, <strong>ftmachine='mosaic'</strong> : 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 />
* <strong>multiscale=[0, 6, 18, 54]</strong>, <strong>smallscalebias=0.9</strong> : 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 <tt>multiscale</tt> 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 <tt>smallscalebias</tt> 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 to <tt>multiscale=[]</tt> 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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4150EVLA Continuum Tutorial 3C3912010-06-16T21:01:16Z<p>Jlazio: </p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
<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 />
<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.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-0938, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0938, 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 [[polcal]] is used for polarization calibration. 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 I, Q, and U values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The 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 />
gainfield=['','','J0319+4130'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* <strong>caltable='3c391_ctm_mosaic_10s_spw0.D1'</strong> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <strong>field='J0319+4130'</strong> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <strong>spw='0:5~58'</strong> : In this example, the edge channels are not used in finding the solution. Because the bandpass is one of the calibration tables being applied (in <tt>gaintable</tt>), this restriction is not necessary. However, if one restricts the spectral window here, it <em>must</em> also be restricted in the remainder of the calibration steps, particularly [[applycal]], otherwise the final data set will contain frequency channels for which the leakage terms have not been calibrated.<br />
* <strong>poltype='Df'</strong> : 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 (<tt>poltype='Df+QU</tt>).<br />
* <strong>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.G1']</strong> : 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 />
* <strong>gainfield=[' ',' ','J0319+4130']</strong> : The gain caltable that is being applied on the fly, <tt>3c391_ctm_mosaic_10s_spw0.G1</tt>, contains the solutions for multiple sources. Only the solutions from J0319+4130 should be applied to itself in the process of finding the polarization leakage terms.<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 />
==== Solving for the R-L polarization angle ====<br />
<br />
Having calibrated the instrumental polarization, the total polarization is now correct, but the <br />
R-L phase still needs to calibrated in order to obtain an accurate polarization position angle. We use the same task, {{polcal}}, but this time set <tt>poltype='Xf</tt>, which specifies a frequency-dependent (''f'') position angle (''X'') calibration, using the source J1331+3030 (a.k.a. 3C 286), whose position angle is known, 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 (<tt>3c391_ctm_mosaic_10s_spw0.D1</tt>) to the gain tables that 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 />
gainfield=[' ', ' ', 'J1331+3030', ' ')<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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=4149EVLA Advanced Topics 3C3912010-06-16T00:58:59Z<p>Jlazio: /* 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 (see below). 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 I-only image is generated (3c391_ctm_spw0_I.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). Note that in the clean before the self-cal, we only image I so that any cleaned polarization does not affect the gaincal.<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_I',<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='I',<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 />
calwt=F)<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 />
* Care is required in the setting of <tt>imagename</tt>. If one has an image that already exists, CASA will continue CLEANing it, which is almost certainly not what one wants during self-calibration. Rather one wants a unique <tt>imagename</tt> for each pass of self-calibration.<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 />
* One should consider examining the solutions from [[gaincal]], using [[plotcal]], in order to assure one's self that the corrections are sensible. Smoothly varying phases are good, jumps are usually not. (However, because the phases are often plotted +/- 180 degrees, there can be apparent "jumps," if the phases are very near +180 deg or -180 deg.)<br />
<br />
== On Your Own: 3C391 second frequency and G93.3+6.9 ==<br />
<br />
Now that you have run through spw 0 of 3C391, you are ready to strike off on your own with other datasets. We have provided two options here, described below. The first option is simplest as it is the same object (different spectral window). But for a more rewarding challenge try the L-band dataset on G93.3+6.9!<br />
<br />
You can find the data in the [http://casa.nrao.edu/Data/Synth2010/AdvancedEVLAcont.tgz CASA repository]. Both datasets are contained in this "tarball". Note that these MSes do not have the scratch columns pre-made (to keep the sizes small) so you can do an inintial clearcal to force the creation (or wait until you first calibration task does it for you).<br />
<br />
1. 3C391 spw 1 (at 7.5 GHz)<br />
<br />
This is the second spectral window split off from the 3C391 dataset. You can process this as you did the first, but beware of RFI in this band! You will have to avoid it (through channel ranges) and/or edit it out. Once you have processed this data and imaged it, you can combine those images in immath to make a spectral index image (see above), or combine the two calibrated MSes in clean to make a deeper MFS image (this might be tricky). You can also look for signs of Faraday Rotation by searching for a polarization angle change between the two spw. Can you derive the "rotation measure" (RM)?<br />
<br />
2. Supernova Remnant G93.3+6.9 at L-band<br />
<br />
This is data taken at L-band of an entirely different Supernova Remnant, centered near 1400 MHz. You should be able to process this data in a very similar manner to the C-band data on 3C391. Note that we are not telling you what you will see in the image ahead of time - you'll have to try it to see! Here are some data reduction hints to help you along:<br />
<br />
* There is strong RFI in this spectral window of the original 2 spw dataset. You will need to find it (e.g. using plotms) and avoid it in imaging. You can also flag those channels using flagdata, but this is not necessary. Note that there is a single baseline that shows very strong interference, see if you can find it! You can flag it using the baseline syntax in flagdata (e.g. antenna='ea0x&ea0y').<br />
<br />
* We have not edited out bad or dead antennas for you (unlike in 3C391). You will need to find these using plotms and then flagdata them. One helpful plotms trick is to set antenna='ea01' and pick a few channels (like spw='0:30~33') and a single scan (e.g. scan='2~3') and plot the amp versus Antenna2 on the x-axis. You should see the bad antennas (the low ones). As a check set antenna='ea02' and repeat. Is it the same?<br />
<br />
* In spite of RFI, the antenna-based calibration is remarkably resilient to moderate to low RFI contamination (which tends to be baseline-based). So rather than flagging channels with RFI, you might try going ahead with calibration and seeing if the solutions make sense. We were able to calibrate this data without flagging channels (only getting the bad baseline noted above).<br />
<br />
* There is no observation of a flux or polarization angle calibrator like J1331+3030. You need to use setjy to set the I flux of the gain calibrator. We use the approximate flux density of 5.8 Jy for J2038+5119.<br />
<br />
* When it comes time to calibrate the polarization leakage, we are in good shape since J2038+5119 was observed through a range of parallactic angle (use plotms to plot versus ParAngle). Use poltype='Df+QU' to solve for leakage and the unknown polarization of this source. We do not know the true polarization angle of this source, so before doing poltype='Xf' use setjy to set the Q flux to 5.8Jy * fractional pol (determined in leakage polcal run). This will at least align the polarization when you image it.<br />
<br />
* The L-band field of view is much larger than at C-band. From the [http://evlaguides.nrao.edu/index.php?title=Category:Status EVLA Observation Status Summary] the resolution should be around 45" in D-config. Use a cellsize of 15" or smaller. What is the primary beam of the VLA at 1.4MHz? How big should you make your image? <br />
<br />
* As you clean you will see faint sources all over the field. Welcome to L-band imaging! This SNR has lots of structure - try both standard and multi-scale clean.<br />
<br />
== 3C391 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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4148EVLA Continuum Tutorial 3C3912010-06-16T00:52:24Z<p>Jlazio: /* Solving for the R-L polarization angle */</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.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-0938, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0938, 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 [[polcal]] is used for polarization calibration. 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 I, Q, and U values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The 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 />
gainfield=['','','J0319+4130'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* <strong>caltable='3c391_ctm_mosaic_10s_spw0.D1'</strong> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <strong>field='J0319+4130'</strong> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <strong>spw='0:5~58'</strong> : In this example, the edge channels are not used in finding the solution. Because the bandpass is one of the calibration tables being applied (in <tt>gaintable</tt>), this restriction is not necessary. However, if one restricts the spectral window here, it <em>must</em> also be restricted in the remainder of the calibration steps, particularly [[applycal]], otherwise the final data set will contain frequency channels for which the leakage terms have not been calibrated.<br />
* <strong>poltype='Df'</strong> : 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 (<tt>poltype='Df+QU</tt>).<br />
* <strong>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.G1']</strong> : 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 />
* <strong>gainfield=[' ',' ','J0319+4130']</strong> : The gain caltable that is being applied on the fly, <tt>3c391_ctm_mosaic_10s_spw0.G1</tt>, contains the solutions for multiple sources. Only the solutions from J0319+4130 should be applied to itself in the process of finding the polarization leakage terms.<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 />
==== Solving for the R-L polarization angle ====<br />
<br />
Having calibrated the instrumental polarization, the total polarization is now correct, but the <br />
R-L phase still needs to calibrated in order to obtain an accurate polarization position angle. We use the same task, {{polcal}}, but this time set <tt>poltype='Xf</tt>, which specifies a frequency-dependent (''f'') position angle (''X'') calibration, using the source J1331+3030 (a.k.a. 3C 286), whose position angle is known, 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 (<tt>3c391_ctm_mosaic_10s_spw0.D1</tt>) to the gain tables that 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 />
gainfield=[' ', ' ', 'J1331+3030', ' ')<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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4147EVLA Continuum Tutorial 3C3912010-06-16T00:51:24Z<p>Jlazio: /* Solving for the Leakage Terms */</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.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-0938, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0938, 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 [[polcal]] is used for polarization calibration. 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 I, Q, and U values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The 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 />
gainfield=['','','J0319+4130'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* <strong>caltable='3c391_ctm_mosaic_10s_spw0.D1'</strong> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <strong>field='J0319+4130'</strong> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <strong>spw='0:5~58'</strong> : In this example, the edge channels are not used in finding the solution. Because the bandpass is one of the calibration tables being applied (in <tt>gaintable</tt>), this restriction is not necessary. However, if one restricts the spectral window here, it <em>must</em> also be restricted in the remainder of the calibration steps, particularly [[applycal]], otherwise the final data set will contain frequency channels for which the leakage terms have not been calibrated.<br />
* <strong>poltype='Df'</strong> : 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 (<tt>poltype='Df+QU</tt>).<br />
* <strong>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.G1']</strong> : 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 />
* <strong>gainfield=[' ',' ','J0319+4130']</strong> : The gain caltable that is being applied on the fly, <tt>3c391_ctm_mosaic_10s_spw0.G1</tt>, contains the solutions for multiple sources. Only the solutions from J0319+4130 should be applied to itself in the process of finding the polarization leakage terms.<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 />
==== Solving for the R-L polarization angle ====<br />
<br />
Having calibrated the instrumental polarization, the total polarization is now correct, but the <br />
R-L phase still needs to calibrated in order to obtain an accurate polarization position angle. We use the same task, {{polcal}}, but this time set <tt>poltype='Xf</tt>, which specifies a frequency-dependent (''f'') position angle (''X'') calibration, using the source J1331+3030 (a.k.a. 3C 286), whose position angle is known, 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 (<tt>3c391_ctm_mosaic_10s_spw0.D1</tt>) to the gain tables that 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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4146EVLA Continuum Tutorial 3C3912010-06-16T00:50:30Z<p>Jlazio: /* Polarization Calibration */</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.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-0938, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0938, 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 [[polcal]] is used for polarization calibration. 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 I, Q, and U values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The 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 />
gainfield=['','','J0319+4130'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* <strong>caltable='3c391_ctm_mosaic_10s_spw0.D1'</strong> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <strong>field='J0319+4130'</strong> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <strong>spw='0:5~58'</strong> : In this example, the edge channels are not used in finding the solution. Because the bandpass is one of the calibration tables being applied (in <tt>gaintable</tt>), this restriction is not necessary. However, if one restricts the spectral window here, it <em>must</em> also be restricted in the remainder of the calibration steps, particularly [[applycal]], otherwise the final data set will contain frequency channels for which the leakage terms have not been calibrated.<br />
* <strong>poltype='Df'</strong> : 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 (<tt>poltype='Df+QU</tt>).<br />
* <strong>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.G1']</strong> : 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 />
* <strong>gainfield=['','','J0319+4130']</strong> : The gain caltable that is being applied on the fly, <tt>3c391_ctm_mosaic_10s_spw0.G1</tt>, contains the solutions for multiple sources. Only the solutions from J0319+4130 should be applied to itself in the process of finding the polarization leakage terms.<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 the <br />
R-L phase still needs to calibrated in order to obtain an accurate polarization position angle. We use the same task, {{polcal}}, but this time set <tt>poltype='Xf</tt>, which specifies a frequency-dependent (''f'') position angle (''X'') calibration, using the source J1331+3030 (a.k.a. 3C 286), whose position angle is known, 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 (<tt>3c391_ctm_mosaic_10s_spw0.D1</tt>) to the gain tables that 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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4089EVLA Continuum Tutorial 3C3912010-06-12T13:57:35Z<p>Jlazio: /* Solving for the R-L polarization angle */</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.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-0938, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0938, 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 [[polcal]] is used for polarization calibration. 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 I, Q, and U values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The 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 />
gainfield=['','','J0319+4130'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* <strong>caltable='3c391_ctm_mosaic_10s_spw0.D1'</strong> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <strong>field='J0319+4130'</strong> : We use the unpolarized source J0319+4130 (a.k.a. 3C 84) to solve for the leakages.<br />
* <strong>poltype='Df'</strong> : 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 (<tt>poltype='Df+QU</tt>).<br />
* <strong>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.G1']</strong> : 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 />
* <strong>gainfield=['','','J0319+4130']</strong> : The gain caltable that is being applied on the fly, <tt>3c391_ctm_mosaic_10s_spw0.G1</tt>, contains the solutions for multiple sources. Only the solutions from J0319+4130 should be applied to itself in the process of finding the polarization leakage terms.<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 the <br />
R-L phase still needs to calibrated in order to obtain an accurate polarization position angle. We use the same task, {{polcal}}, but this time set <tt>poltype='Xf</tt>, which specifies a frequency-dependent (''f'') position angle (''X'') calibration, using the source J1331+3030 (a.k.a. 3C 286), whose position angle is known, 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 (<tt>3c391_ctm_mosaic_10s_spw0.D1</tt>) to the gain tables that 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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4088EVLA Continuum Tutorial 3C3912010-06-12T13:38:44Z<p>Jlazio: /* Solving for the Leakage Terms */</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.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-0938, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0938, 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 [[polcal]] is used for polarization calibration. 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 I, Q, and U values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The 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 />
gainfield=['','','J0319+4130'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* <strong>caltable='3c391_ctm_mosaic_10s_spw0.D1'</strong> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <strong>field='J0319+4130'</strong> : We use the unpolarized source J0319+4130 (a.k.a. 3C 84) to solve for the leakages.<br />
* <strong>poltype='Df'</strong> : 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 (<tt>poltype='Df+QU</tt>).<br />
* <strong>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', '3c391_ctm_mosaic_10s_spw0.B0', '3c391_ctm_mosaic_10s_spw0.G1']</strong> : 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 />
* <strong>gainfield=['','','J0319+4130']</strong> : The gain caltable that is being applied on the fly, <tt>3c391_ctm_mosaic_10s_spw0.G1</tt>, contains the solutions for multiple sources. Only the solutions from J0319+4130 should be applied to itself in the process of finding the polarization leakage terms.<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 />
==== 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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4087EVLA Continuum Tutorial 3C3912010-06-12T13:37:53Z<p>Jlazio: /* Solving for the Leakage Terms */</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.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-0938, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0938, 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 [[polcal]] is used for polarization calibration. 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 I, Q, and U values in the MODEL_DATA column (Q and U being zero for our unpolarized calibrator) to derive the leakage solutions. The 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 />
gainfield=['','','J0319+4130'])<br />
</source><br />
<br />
[[Image: 3C391_polcal.png|200px|thumb|right|polcal inputs for leakage correction]]<br />
* <strong>caltable='3c391_ctm_mosaic_10s_spw0.D1'</strong> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <strong>field='J0319+4130'</strong> : We use the unpolarized source J0319+4130 (a.k.a. 3C 84) to solve for the leakages.<br />
* <strong>poltype='Df'</strong> : 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 (<tt>poltype='Df+QU</tt>).<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 />
* gainfield=['','','J0319+4130'] : The gain caltable that is being applied on the fly, <tt>3c391_ctm_mosaic_10s_spw0.G1</tt>, contains the solutions for multiple sources. Only the solutions from J0319+4130 should be applied to itself in the process of finding the polarization leakage terms.<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 />
==== 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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4086EVLA Continuum Tutorial 3C3912010-06-11T16:45:03Z<p>Jlazio: /* Gain Calibration */</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.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-0938, R polarization]]<br />
[[Image:plotcal-J1822-0398-phase-L.png|200px|thumb|center|gain phase solutions for J1822-0938, 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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4085EVLA Continuum Tutorial 3C3912010-06-11T16:42:41Z<p>Jlazio: /* Bandpass Calibration */</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.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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4084EVLA Continuum Tutorial 3C3912010-06-11T16:39:41Z<p>Jlazio: /* Bandpass Calibration */</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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4083EVLA Continuum Tutorial 3C3912010-06-11T16:37:23Z<p>Jlazio: /* Applying the Calibration */</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_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 />
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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4082EVLA Continuum Tutorial 3C3912010-06-11T16:36:09Z<p>Jlazio: /* Bandpass Calibration */</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>Jlaziohttps://casaguides.nrao.edu/index.php?title=Initial_instructions_for_2010&diff=4076Initial instructions for 20102010-06-10T22:39:39Z<p>Jlazio: /* DSOC */</p>
<hr />
<div>The data reduction tutorials will be taking place across the [http://www.nmt.edu/images/stories/maps/map_big.jpg NMT campus], specifically in Weir Hall (Rm. 128 and 209), the Martin Speare Building (Rm 23), and the Array Operations Center/Dominici Science Operations Center. There are slight differences in installations between the various buildings. This document describes how to use CASA in the various buildings.<br />
<br />
== Weir Hall and Speare Bldg. ==<br />
<br />
=== Gaining Access ===<br />
<br />
The data reduction tutorials will use the <tt>imaging</tt> account. If the machine you will be using is not already logged into this account, do so. The tutorial leads will provide the password.<br />
<br />
The home directory for the <tt>imaging</tt> account is common to <em>all</em> machines. <strong>Do not modify any files in the home directory.</strong><br />
<br />
=== First Steps===<br />
<br />
Each machine has a local installation of CASA and a local copy of the relevant data files and calibration models.<br />
* Open a <tt>terminal</tt> window. <br />
* Start the Opera Web browser and navigate to the relevant tutorials at [http://casaguides.nrao.edu/index.php?title=Main_Page CASAguides] - specifically the EVLA [[EVLA Tutorials | Tutorials]]. <br />
** Continuum: [[EVLA_Continuum_Tutorial_3C391]]<br />
** Spectral Line: [[EVLA_Spectral_Line_Calibration_IRC%2B10216]]<br />
<br />
<strong>Do not use the Firefox browser.</strong> If you attempt to do so, you'll most likely be met with error messages.<br />
<br />
=== Second Step ===<br />
<br />
In the terminal window, <tt>cd</tt> into the directory <tt>/nrao</tt>, which is where the relevant data files and calibration models are stored. A directory listing, using <tt>ls -R</tt> should show the following:<br />
<pre><br />
bash-3.2$ ls<br />
AdvancedTopicsLine_Tuesday_EVLA_3C391 <br />
casapy-stable-30.2.11705-001-64b MMLineMosaic_Tuesday_CARMA_M99<br />
ContiuumMosaic_Friday_EVLA_3C391 SpectralLine_Friday_EVLA_IRC10216<br />
data summerschool_data<br />
<br />
% ls ContiuumMosaic_Friday_EVLA_3C391<br />
3c391_ctm_mosaic_10s_spw0.ms<br />
<br />
% ls AdvancedTopicsLine_Tuesday_EVLA_3C391<br />
3c391_line_10s_summerschool.ms<br />
<br />
% ls SpectralLine_Friday_EVLA_IRC10216<br />
day2_TDEM0003_10s_norx<br />
<br />
%ls MMLineMosaic_Tuesday_CARMA_M99<br />
fits<br />
</pre><br />
<br />
Change directories (<tt>cd</tt>) into the directory relevant for your tutorial. Start CASA with <tt>casapy</tt> and begin the relevant tutorial.<br />
<br />
== DSOC ==<br />
<br />
=== Gaining Access ===<br />
<br />
The data reduction tutorials will use the <tt>synimgwk</tt> account. If the machine you will be using is not already logged into this account, do so. The tutorial leads will provide the password.<br />
<br />
=== First Steps===<br />
<br />
Each machine has a local installation of CASA and a local copy of the relevant data files and calibration models.<br />
* Open a <tt>terminal</tt> window. <br />
* Start a Web browser and navigate to the relevant tutorials at [http://casaguides.nrao.edu/index.php?title=Main_Page CASAguides] - specifically the EVLA [[EVLA Tutorials | Tutorials]]. <br />
** Continuum: [[EVLA_Continuum_Tutorial_3C391]]<br />
** Spectral Line: [[EVLA_Spectral_Line_Calibration_IRC%2B10216]]<br />
<br />
=== Second Step ===<br />
<br />
In the terminal window, <tt>cd</tt> into the directory <tt>/nrao</tt>, which is where the relevant data files and calibration models are stored. A directory listing, using <tt>ls -R</tt> should show the following:<br />
<pre><br />
% ls<br />
AdvancedTopicsLine_Tuesday_EVLA_3C391 Desktop<br />
casapy-stable-30.2.11705-001-64b MMLineMosaic_Tuesday_CARMA_M99<br />
ContiuumMosaic_Friday_EVLA_3C391 SpectralLine_Friday_EVLA_IRC10216<br />
data summerschool_data<br />
<br />
% ls ContiuumMosaic_Friday_EVLA_3C391<br />
3c391_ctm_mosaic_10s_spw0.ms<br />
<br />
% ls AdvancedTopicsLine_Tuesday_EVLA_3C391<br />
3c391_line_10s_summerschool.ms<br />
<br />
% ls SpectralLine_Friday_EVLA_IRC10216<br />
day2_TDEM0003_10s_norx<br />
<br />
% ls MMLineMosaic_Tuesday_CARMA_M99<br />
fits<br />
</pre><br />
<br />
Change directories (<tt>cd</tt>) into the directory relevant for your tutorial. Start CASA with <tt>casapy</tt> and begin the relevant tutorial.</div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Initial_instructions_for_2010&diff=4075Initial instructions for 20102010-06-10T22:38:49Z<p>Jlazio: /* Weir Hall and Speare Bldg. */</p>
<hr />
<div>The data reduction tutorials will be taking place across the [http://www.nmt.edu/images/stories/maps/map_big.jpg NMT campus], specifically in Weir Hall (Rm. 128 and 209), the Martin Speare Building (Rm 23), and the Array Operations Center/Dominici Science Operations Center. There are slight differences in installations between the various buildings. This document describes how to use CASA in the various buildings.<br />
<br />
== Weir Hall and Speare Bldg. ==<br />
<br />
=== Gaining Access ===<br />
<br />
The data reduction tutorials will use the <tt>imaging</tt> account. If the machine you will be using is not already logged into this account, do so. The tutorial leads will provide the password.<br />
<br />
The home directory for the <tt>imaging</tt> account is common to <em>all</em> machines. <strong>Do not modify any files in the home directory.</strong><br />
<br />
=== First Steps===<br />
<br />
Each machine has a local installation of CASA and a local copy of the relevant data files and calibration models.<br />
* Open a <tt>terminal</tt> window. <br />
* Start the Opera Web browser and navigate to the relevant tutorials at [http://casaguides.nrao.edu/index.php?title=Main_Page CASAguides] - specifically the EVLA [[EVLA Tutorials | Tutorials]]. <br />
** Continuum: [[EVLA_Continuum_Tutorial_3C391]]<br />
** Spectral Line: [[EVLA_Spectral_Line_Calibration_IRC%2B10216]]<br />
<br />
<strong>Do not use the Firefox browser.</strong> If you attempt to do so, you'll most likely be met with error messages.<br />
<br />
=== Second Step ===<br />
<br />
In the terminal window, <tt>cd</tt> into the directory <tt>/nrao</tt>, which is where the relevant data files and calibration models are stored. A directory listing, using <tt>ls -R</tt> should show the following:<br />
<pre><br />
bash-3.2$ ls<br />
AdvancedTopicsLine_Tuesday_EVLA_3C391 <br />
casapy-stable-30.2.11705-001-64b MMLineMosaic_Tuesday_CARMA_M99<br />
ContiuumMosaic_Friday_EVLA_3C391 SpectralLine_Friday_EVLA_IRC10216<br />
data summerschool_data<br />
<br />
% ls ContiuumMosaic_Friday_EVLA_3C391<br />
3c391_ctm_mosaic_10s_spw0.ms<br />
<br />
% ls AdvancedTopicsLine_Tuesday_EVLA_3C391<br />
3c391_line_10s_summerschool.ms<br />
<br />
% ls SpectralLine_Friday_EVLA_IRC10216<br />
day2_TDEM0003_10s_norx<br />
<br />
%ls MMLineMosaic_Tuesday_CARMA_M99<br />
fits<br />
</pre><br />
<br />
Change directories (<tt>cd</tt>) into the directory relevant for your tutorial. Start CASA with <tt>casapy</tt> and begin the relevant tutorial.<br />
<br />
== DSOC ==<br />
<br />
=== Gaining Access ===<br />
<br />
The data reduction tutorials will use the <tt>synimgwk</tt> account. If the machine you will be using is not already logged into this account, do so. The tutorial leads will provide the password.<br />
<br />
=== First Steps===<br />
<br />
Each machine has a local installation of CASA and a local copy of the relevant data files and calibration models.<br />
* Open a <tt>terminal</tt> window. <br />
* Start a Web browser and navigate to the relevant tutorials at [http://casaguides.nrao.edu/index.php?title=Main_Page CASAguides] - specifically the EVLA [[EVLA Tutorials | Tutorials]]. <br />
** Continuum: [[EVLA_Continuum_Tutorial_3C391]]<br />
** Spectral Line: [[EVLA_Spectral_Line_Calibration_IRC%2B10216]]<br />
<br />
=== Second Step ===<br />
<br />
In the terminal window, <tt>cd</tt> into the directory <tt>/nrao</tt>, which is where the relevant data files and calibration models are stored. A directory listing, using <tt>ls -R</tt> should show the following:<br />
<pre><br />
% ls -R<br />
ContiuumMosaic_Friday_EVLA_3C391:<br />
3c391_ctm_mosaic_10s_spw0.ms<br />
<br />
AdvancedTopicsLine_Tuesday_EVLA_3C391:<br />
3c391_line_10s_summerschool.ms<br />
<br />
SpectralLine_Friday_EVLA_IRC10216:<br />
day2_TDEM0003_10s_norx<br />
<br />
MMLineMosaic_Tuesday_CARMA_M99:<br />
M99_CARMA.fits<br />
</pre><br />
<br />
Change directories (<tt>cd</tt>) into the directory relevant for your tutorial. Start CASA with <tt>casapy</tt> and begin the relevant tutorial.</div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Initial_instructions_for_2010&diff=4072Initial instructions for 20102010-06-10T22:35:35Z<p>Jlazio: </p>
<hr />
<div>The data reduction tutorials will be taking place across the [http://www.nmt.edu/images/stories/maps/map_big.jpg NMT campus], specifically in Weir Hall (Rm. 128 and 209), the Martin Speare Building (Rm 23), and the Array Operations Center/Dominici Science Operations Center. There are slight differences in installations between the various buildings. This document describes how to use CASA in the various buildings.<br />
<br />
== Weir Hall and Speare Bldg. ==<br />
<br />
=== Gaining Access ===<br />
<br />
The data reduction tutorials will use the <tt>imaging</tt> account. If the machine you will be using is not already logged into this account, do so. The tutorial leads will provide the password.<br />
<br />
The home directory for the <tt>imaging</tt> account is common to <em>all</em> machines. <strong>Do not modify any files in the home directory.</strong><br />
<br />
=== First Steps===<br />
<br />
Each machine has a local installation of CASA and a local copy of the relevant data files and calibration models.<br />
* Open a <tt>terminal</tt> window. <br />
* Start the Opera Web browser and navigate to the relevant tutorials at [http://casaguides.nrao.edu/index.php?title=Main_Page CASAguides] - specifically the EVLA [[EVLA Tutorials | Tutorials]]. <br />
** Continuum: [[EVLA_Continuum_Tutorial_3C391]]<br />
** Spectral Line: [[EVLA_Spectral_Line_Calibration_IRC%2B10216]]<br />
<br />
<strong>Do not use the Firefox browser.</strong> If you attempt to do so, you'll most likely be met with error messages.<br />
<br />
=== Second Step ===<br />
<br />
In the terminal window, <tt>cd</tt> into the directory <tt>/nrao</tt>, which is where the relevant data files and calibration models are stored. A directory listing, using <tt>ls -R</tt> should show the following:<br />
<pre><br />
% ls -R<br />
ContiuumMosaic_Friday_EVLA_3C391:<br />
3c391_ctm_mosaic_10s_spw0.ms<br />
<br />
AdvancedTopicsLine_Tuesday_EVLA_3C391:<br />
3c391_line_10s_summerschool.ms<br />
<br />
SpectralLine_Friday_EVLA_IRC10216:<br />
day2_TDEM0003_10s_norx<br />
<br />
MMLineMosaic_Tuesday_CARMA_M99:<br />
M99_CARMA.fits<br />
</pre><br />
<br />
Change directories (<tt>cd</tt>) into the directory relevant for your tutorial. Start CASA with <tt>casapy</tt> and begin the relevant tutorial.<br />
<br />
<br />
== DSOC ==<br />
<br />
=== Gaining Access ===<br />
<br />
The data reduction tutorials will use the <tt>synimgwk</tt> account. If the machine you will be using is not already logged into this account, do so. The tutorial leads will provide the password.<br />
<br />
=== First Steps===<br />
<br />
Each machine has a local installation of CASA and a local copy of the relevant data files and calibration models.<br />
* Open a <tt>terminal</tt> window. <br />
* Start a Web browser and navigate to the relevant tutorials at [http://casaguides.nrao.edu/index.php?title=Main_Page CASAguides] - specifically the EVLA [[EVLA Tutorials | Tutorials]]. <br />
** Continuum: [[EVLA_Continuum_Tutorial_3C391]]<br />
** Spectral Line: [[EVLA_Spectral_Line_Calibration_IRC%2B10216]]<br />
<br />
=== Second Step ===<br />
<br />
In the terminal window, <tt>cd</tt> into the directory <tt>/nrao</tt>, which is where the relevant data files and calibration models are stored. A directory listing, using <tt>ls -R</tt> should show the following:<br />
<pre><br />
% ls -R<br />
ContiuumMosaic_Friday_EVLA_3C391:<br />
3c391_ctm_mosaic_10s_spw0.ms<br />
<br />
AdvancedTopicsLine_Tuesday_EVLA_3C391:<br />
3c391_line_10s_summerschool.ms<br />
<br />
SpectralLine_Friday_EVLA_IRC10216:<br />
day2_TDEM0003_10s_norx<br />
<br />
MMLineMosaic_Tuesday_CARMA_M99:<br />
M99_CARMA.fits<br />
</pre><br />
<br />
Change directories (<tt>cd</tt>) into the directory relevant for your tutorial. Start CASA with <tt>casapy</tt> and begin the relevant tutorial.</div>Jlaziohttps://casaguides.nrao.edu/index.php?title=Initial_instructions_for_2010&diff=4071Initial instructions for 20102010-06-10T22:28:19Z<p>Jlazio: </p>
<hr />
<div>The data reduction tutorials will be taking place across the [http://www.nmt.edu/images/stories/maps/map_big.jpg NMT campus], specifically in Weir Hall (Rm. 128 and 209), the Martin Speare Building (Rm 23), and the Array Operations Center/Dominici Science Operations Center. There are slight differences in installations between the various buildings. This document describes how to use CASA in the various buildings.<br />
<br />
<br />
== Weir Hall and Speare Bldg. ==<br />
<br />
<br />
<br />
<br />
=== Gaining Access ===<br />
<br />
The data reduction tutorials will use the <tt>imaging</tt> account. If the machine you will be using is not already logged into this account, do so. The tutorial leads will provide the password.<br />
<br />
The home directory for the <tt>imaging</tt> account is common to <em>all</em> machines. <strong>Do not modify any files in the home directory.</strong><br />
<br />
=== First Steps===<br />
<br />
Each machine has a local installation of CASA and a local copy of the relevant data files and calibration models.<br />
* Open a <tt>terminal</tt> window. <br />
* Start the Opera Web browser and navigate to the relevant tutorials at [http://casaguides.nrao.edu/index.php?title=Main_Page CASAguides] - specifically the EVLA [[EVLA Tutorials | Tutorials]]. <br />
** Continuum: [[EVLA_Continuum_Tutorial_3C391]]<br />
** Spectral Line: [[EVLA_Spectral_Line_Calibration_IRC%2B10216]]<br />
<br />
<strong>Do not use the Firefox browser.</strong> If you attempt to do so, you'll most likely be met with error messages.<br />
<br />
=== Second Step ===<br />
<br />
In the terminal window, <tt>cd</tt> into the directory <tt>/nrao</tt>, which is where the relevant data files and calibration models are stored. A directory listing, using <tt>ls -R</tt> should show the following:<br />
<pre><br />
% ls -R<br />
ContiuumMosaic_Friday_EVLA_3C391:<br />
3c391_ctm_mosaic_10s_spw0.ms<br />
<br />
AdvancedTopicsLine_Tuesday_EVLA_3C391:<br />
3c391_line_10s_summerschool.ms<br />
<br />
SpectralLine_Friday_EVLA_IRC10216:<br />
day2_TDEM0003_10s_norx<br />
<br />
MMLineMosaic_Tuesday_CARMA_M99:<br />
M99_CARMA.fits<br />
</pre><br />
<br />
Change directories (<tt>cd</tt>) into the directory relevant for your tutorial. Start CASA with <tt>casapy</tt> and begin the relevant tutorial.<br />
<br />
<br />
== DSOC ==<br />
<br />
=== Gaining Access ===<br />
<br />
The data reduction tutorials will use the <tt>synimgwk</tt> account. If the machine you will be using is not already logged into this account, do so. The tutorial leads will provide the password.<br />
<br />
=== First Steps===<br />
<br />
Each machine has a local installation of CASA and a local copy of the relevant data files and calibration models.<br />
* Open a <tt>terminal</tt> window. <br />
* Start a Web browser and navigate to the relevant tutorials at [http://casaguides.nrao.edu/index.php?title=Main_Page CASAguides] - specifically the EVLA [[EVLA Tutorials | Tutorials]]. <br />
** Continuum: [[EVLA_Continuum_Tutorial_3C391]]<br />
** Spectral Line: [[EVLA_Spectral_Line_Calibration_IRC%2B10216]]<br />
<br />
=== Second Step ===<br />
<br />
In the terminal window, <tt>cd</tt> into the directory <tt>/nrao</tt>, which is where the relevant data files and calibration models are stored. A directory listing, using <tt>ls -R</tt> should show the following:<br />
<pre><br />
% ls -R<br />
ContiuumMosaic_Friday_EVLA_3C391:<br />
3c391_ctm_mosaic_10s_spw0.ms<br />
<br />
AdvancedTopicsLine_Tuesday_EVLA_3C391:<br />
3c391_line_10s_summerschool.ms<br />
<br />
SpectralLine_Friday_EVLA_IRC10216:<br />
day2_TDEM0003_10s_norx<br />
<br />
MMLineMosaic_Tuesday_CARMA_M99:<br />
M99_CARMA.fits<br />
</pre><br />
<br />
Change directories (<tt>cd</tt>) into the directory relevant for your tutorial. Start CASA with <tt>casapy</tt> and begin the relevant tutorial.</div>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4069EVLA Continuum Tutorial 3C3912010-06-10T20:26:16Z<p>Jlazio: /* Polarization Calibration */</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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4067EVLA Continuum Tutorial 3C3912010-06-10T20:16:30Z<p>Jlazio: /* Examining the Data */</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><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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4066EVLA Continuum Tutorial 3C3912010-06-10T18:32:10Z<p>Jlazio: /* Bandpass Calibration */</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 />
== 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, 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><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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4065EVLA Continuum Tutorial 3C3912010-06-10T18:28:28Z<p>Jlazio: /* Gain Calibration */</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 />
== 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, 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.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.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.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_10s_spw0.gcal0',<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.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.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 />
<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><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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4064EVLA Continuum Tutorial 3C3912010-06-10T18:27:26Z<p>Jlazio: /* Gain Calibration */</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 />
== 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, 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.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.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.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_10s_spw0.gcal0',<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.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.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 />
<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.bcal0'] : 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><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>Jlaziohttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=4063EVLA Continuum Tutorial 3C3912010-06-10T18:26:12Z<p>Jlazio: /* 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 />
== 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, 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.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.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.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_10s_spw0.gcal0',<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.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.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 />
<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.bcal0'])<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.bcal0'] : 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><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>Jlazio