https://casaguides.nrao.edu/api.php?action=feedcontributions&user=Smyers&feedformat=atomCASA Guides - User contributions [en]2024-03-28T09:19:00ZUser contributionsMediaWiki 1.38.6https://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391&diff=16783EVLA Advanced Topics 3C3912015-04-20T20:36:40Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391-CASA4.3 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391-CASA4.3 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391-CASA4.3 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use. For example, for a particular instance of<br />
the previous clean, we found:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 9.50934186]),<br />
'max': array([ 0.15526876]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00089436]),<br />
'medabsdevmed': array([ 0.00015567]),<br />
'median': array([ 1.27408730e-05]),<br />
'min': array([-0.00516682]),<br />
'minpos': array([279, 429, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.48.079, I, 4.59901e+09Hz',<br />
'npts': array([ 474784.]),<br />
'quartile': array([ 0.00031206]),<br />
'rms': array([ 0.00607521]),<br />
'sigma': array([ 0.00600903]),<br />
'sum': array([ 424.62918042]),<br />
'sumsq': array([ 17.52343054]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 22119 4.242001e+02 9.499733e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
1.917809e-02 2.799428e-02 2.039361e-02 -2.618031e-03 1.552688e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 9.5 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image <br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.092479e+00 -6.925440e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-5.865299e-05 5.103085e-04 5.069314e-04 -1.945960e-03 2.282981e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -1.474115e-01 -3.301201e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-2.795856e-06 5.614272e-05 5.607359e-05 -3.039683e-04 2.997937e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 7.583902e-02 1.698374e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.438388e-06 5.492329e-05 5.490497e-05 -3.513077e-04 2.247283e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.244009e-01 -7.264784e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.152697e-06 1.186217e-04 1.184631e-04 -4.345808e-04 3.379770e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.51 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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-CASA4.3#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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-CASA4.3 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False],applymode='calflag')<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean. Note that the <br />
<tt>gaincal</tt> step will report a number of solutions with insufficient SNR. By default with <tt>applymode='calflag'</tt> data with no good solutions will be flagged by <tt>applycal</tt>, in this case you will see it report the flagged fraction increasing from 28% to 43%. This may or may not be a good thing. You can control the action of <tt>applycal</tt> in this regard by changing the value of <tt>applymode</tt>: setting <tt>applymode='calflagstrict'</tt> will be even more stringent about flagging things without valid calibration, while <tt>applymode='calonly'</tt> will calibrate those with solutions while passing through data without unchanged. Note that you can see ahead of time what applycal will do by running with <tt>applymode='trial'</tt> which will do the reporting but nothing else.<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Does allowing applycal to flag the data give better images?<br />
* Or, does using <tt>applymode='calonly'</tt> give improved results?<br />
|-<br />
|}<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391&diff=16782EVLA Continuum Tutorial 3C3912015-04-20T20:34:32Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes in CASA development. <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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.3.1/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0 for pang = 33deg (Q+iU phase = 66deg)<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0 for pang = 33deg (Q+iU phase = 66deg)<br />
</source><br />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
--><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
--><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure value for the calibrator, for 3C286 it is zero<br />
--><br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability, although as of 4.3.1 it will not work correctly for all values of polangle and thus is still experimental. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those shown at right (you might get slightly different values).<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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False</tt> : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.3406474, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.00617762, 0. , 0. , 0. ]),<br />
'numSol': array([ 48., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.92407097, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.03710194, 0. , 0. , 0. ]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 (freq=4.536e+09 Hz) is: 2.34065 +/- 0.00617762 (SNR = 378.891, N = 48)<br />
Flux density for J0319+4130 in SpW=0 (freq=4.536e+09 Hz) is: 13.9241 +/- 0.0371019 (SNR = 375.292, N = 46)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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-CASA4.3#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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-CASA4.3#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16781EVLA Advanced Topics 3C391-CASA4.32015-04-20T20:32:05Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391-CASA4.3 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391-CASA4.3 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391-CASA4.3 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use. For example, for a particular instance of<br />
the previous clean, we found:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 9.50934186]),<br />
'max': array([ 0.15526876]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00089436]),<br />
'medabsdevmed': array([ 0.00015567]),<br />
'median': array([ 1.27408730e-05]),<br />
'min': array([-0.00516682]),<br />
'minpos': array([279, 429, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.48.079, I, 4.59901e+09Hz',<br />
'npts': array([ 474784.]),<br />
'quartile': array([ 0.00031206]),<br />
'rms': array([ 0.00607521]),<br />
'sigma': array([ 0.00600903]),<br />
'sum': array([ 424.62918042]),<br />
'sumsq': array([ 17.52343054]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 22119 4.242001e+02 9.499733e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
1.917809e-02 2.799428e-02 2.039361e-02 -2.618031e-03 1.552688e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 9.5 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image <br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.092479e+00 -6.925440e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-5.865299e-05 5.103085e-04 5.069314e-04 -1.945960e-03 2.282981e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -1.474115e-01 -3.301201e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-2.795856e-06 5.614272e-05 5.607359e-05 -3.039683e-04 2.997937e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 7.583902e-02 1.698374e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.438388e-06 5.492329e-05 5.490497e-05 -3.513077e-04 2.247283e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.244009e-01 -7.264784e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.152697e-06 1.186217e-04 1.184631e-04 -4.345808e-04 3.379770e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.51 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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-CASA4.3#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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-CASA4.3 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False],applymode='calflag')<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean. Note that the <br />
<tt>gaincal</tt> step will report a number of solutions with insufficient SNR. By default with <tt>applymode='calflag'</tt> data with no good solutions will be flagged by <tt>applycal</tt>, in this case you will see it report the flagged fraction increasing from 28% to 43%. This may or may not be a good thing. You can control the action of <tt>applycal</tt> in this regard by changing the value of <tt>applymode</tt>: setting <tt>applymode='calflagstrict'</tt> will be even more stringent about flagging things without valid calibration, while <tt>applymode='calonly'</tt> will calibrate those with solutions while passing through data without unchanged. Note that you can see ahead of time what applycal will do by running with <tt>applymode='trial'</tt> which will do the reporting but nothing else.<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Does allowing applycal to flag the data give better images?<br />
* Or, does using <tt>applymode='calonly'</tt> give improved results?<br />
|-<br />
|}<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=Template:Checked_4.3.1&diff=16780Template:Checked 4.3.12015-04-20T20:28:21Z<p>Smyers: Created page with "<div style="background-color: #CCFF99;"> Last checked on CASA Version 4.3.1. </div>"</p>
<hr />
<div><div style="background-color: #CCFF99;"><br />
Last checked on CASA Version 4.3.1.<br />
</div></div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16779EVLA Continuum Tutorial 3C391-CASA4.32015-04-20T20:25:17Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes in CASA development. <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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.3.1/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0 for pang = 33deg (Q+iU phase = 66deg)<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0 for pang = 33deg (Q+iU phase = 66deg)<br />
</source><br />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
--><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
--><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure value for the calibrator, for 3C286 it is zero<br />
--><br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability, although as of 4.3.1 it will not work correctly for all values of polangle and thus is still experimental. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those shown at right (you might get slightly different values).<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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False</tt> : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.3406474, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.00617762, 0. , 0. , 0. ]),<br />
'numSol': array([ 48., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.92407097, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.03710194, 0. , 0. , 0. ]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 (freq=4.536e+09 Hz) is: 2.34065 +/- 0.00617762 (SNR = 378.891, N = 48)<br />
Flux density for J0319+4130 in SpW=0 (freq=4.536e+09 Hz) is: 13.9241 +/- 0.0371019 (SNR = 375.292, N = 46)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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-CASA4.3#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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-CASA4.3#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16778EVLA Continuum Tutorial 3C391-CASA4.32015-04-20T20:22:56Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes in CASA development. <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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0 for pang = 33deg (Q+iU phase = 66deg)<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0 for pang = 33deg (Q+iU phase = 66deg)<br />
</source><br />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
--><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
--><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure value for the calibrator, for 3C286 it is zero<br />
--><br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability, although as of 4.3.1 it will not work correctly for all values of polangle and thus is still experimental. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those shown at right (you might get slightly different values).<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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False</tt> : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.3406474, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.00617762, 0. , 0. , 0. ]),<br />
'numSol': array([ 48., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.92407097, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.03710194, 0. , 0. , 0. ]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 (freq=4.536e+09 Hz) is: 2.34065 +/- 0.00617762 (SNR = 378.891, N = 48)<br />
Flux density for J0319+4130 in SpW=0 (freq=4.536e+09 Hz) is: 13.9241 +/- 0.0371019 (SNR = 375.292, N = 46)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16777EVLA Continuum Tutorial 3C391-CASA4.32015-04-20T20:21:51Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes in CASA development. <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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0 for pang = 33deg (Q+iU phase = 66deg)<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0 for pang = 33deg (Q+iU phase = 66deg)<br />
</source><br />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
--><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
--><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure value for the calibrator, for 3C286 it is zero<br />
--><br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability, although as of 4.3.1 it will not work correctly for all values of polangle and thus is still experimental. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those shown at right (you might get slightly different values).<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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False</tt> : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.3406474, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.00617762, 0. , 0. , 0. ]),<br />
'numSol': array([ 48., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.92407097, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.03710194, 0. , 0. , 0. ]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 (freq=4.536e+09 Hz) is: 2.34065 +/- 0.00617762 (SNR = 378.891, N = 48)<br />
Flux density for J0319+4130 in SpW=0 (freq=4.536e+09 Hz) is: 13.9241 +/- 0.0371019 (SNR = 375.292, N = 46)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16776EVLA Advanced Topics 3C391-CASA4.32015-04-20T19:49:27Z<p>Smyers: /* Self-Calibration */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use. For example, for a particular instance of<br />
the previous clean, we found:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 9.50934186]),<br />
'max': array([ 0.15526876]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00089436]),<br />
'medabsdevmed': array([ 0.00015567]),<br />
'median': array([ 1.27408730e-05]),<br />
'min': array([-0.00516682]),<br />
'minpos': array([279, 429, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.48.079, I, 4.59901e+09Hz',<br />
'npts': array([ 474784.]),<br />
'quartile': array([ 0.00031206]),<br />
'rms': array([ 0.00607521]),<br />
'sigma': array([ 0.00600903]),<br />
'sum': array([ 424.62918042]),<br />
'sumsq': array([ 17.52343054]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 22119 4.242001e+02 9.499733e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
1.917809e-02 2.799428e-02 2.039361e-02 -2.618031e-03 1.552688e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 9.5 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image <br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.092479e+00 -6.925440e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-5.865299e-05 5.103085e-04 5.069314e-04 -1.945960e-03 2.282981e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -1.474115e-01 -3.301201e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-2.795856e-06 5.614272e-05 5.607359e-05 -3.039683e-04 2.997937e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 7.583902e-02 1.698374e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.438388e-06 5.492329e-05 5.490497e-05 -3.513077e-04 2.247283e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.244009e-01 -7.264784e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.152697e-06 1.186217e-04 1.184631e-04 -4.345808e-04 3.379770e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.51 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False],applymode='calflag')<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean. Note that the <br />
<tt>gaincal</tt> step will report a number of solutions with insufficient SNR. By default with <tt>applymode='calflag'</tt> data with no good solutions will be flagged by <tt>applycal</tt>, in this case you will see it report the flagged fraction increasing from 28% to 43%. This may or may not be a good thing. You can control the action of <tt>applycal</tt> in this regard by changing the value of <tt>applymode</tt>: setting <tt>applymode='calflagstrict'</tt> will be even more stringent about flagging things without valid calibration, while <tt>applymode='calonly'</tt> will calibrate those with solutions while passing through data without unchanged. Note that you can see ahead of time what applycal will do by running with <tt>applymode='trial'</tt> which will do the reporting but nothing else.<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Does allowing applycal to flag the data give better images?<br />
* Or, does using <tt>applymode='calonly'</tt> give improved results?<br />
|-<br />
|}<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16775EVLA Advanced Topics 3C391-CASA4.32015-04-20T19:48:34Z<p>Smyers: /* Self-Calibration */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use. For example, for a particular instance of<br />
the previous clean, we found:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 9.50934186]),<br />
'max': array([ 0.15526876]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00089436]),<br />
'medabsdevmed': array([ 0.00015567]),<br />
'median': array([ 1.27408730e-05]),<br />
'min': array([-0.00516682]),<br />
'minpos': array([279, 429, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.48.079, I, 4.59901e+09Hz',<br />
'npts': array([ 474784.]),<br />
'quartile': array([ 0.00031206]),<br />
'rms': array([ 0.00607521]),<br />
'sigma': array([ 0.00600903]),<br />
'sum': array([ 424.62918042]),<br />
'sumsq': array([ 17.52343054]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 22119 4.242001e+02 9.499733e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
1.917809e-02 2.799428e-02 2.039361e-02 -2.618031e-03 1.552688e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 9.5 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image <br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.092479e+00 -6.925440e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-5.865299e-05 5.103085e-04 5.069314e-04 -1.945960e-03 2.282981e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -1.474115e-01 -3.301201e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-2.795856e-06 5.614272e-05 5.607359e-05 -3.039683e-04 2.997937e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 7.583902e-02 1.698374e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.438388e-06 5.492329e-05 5.490497e-05 -3.513077e-04 2.247283e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.244009e-01 -7.264784e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.152697e-06 1.186217e-04 1.184631e-04 -4.345808e-04 3.379770e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.51 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False],applymode='')<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean. Note that the <br />
<tt>gaincal</tt> step will report a number of solutions with insufficient SNR. By default with <tt>applymode=''</tt> data with no good solutions will be flagged by <tt>applycal</tt>, in this case you will see it report the flagged fraction increasing from 28% to 43%. This may or may not be a good thing. You can control the action of <tt>applycal</tt> in this regard by changing the value of <tt>applymode</tt>: setting <tt>applymode='calflagstrict'</tt> will be even more stringent about flagging things without valid calibration, while <tt>applymode='calonly'</tt> will calibrate those with solutions while passing through data without unchanged. Note that you can see ahead of time what applycal will do by running with <tt>applymode='trial'</tt> which will do the reporting but nothing else.<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Does allowing applycal to flag the data give better images?<br />
* Or, does using <tt>applymode='calonly'</tt> give improved results?<br />
|-<br />
|}<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16774EVLA Advanced Topics 3C391-CASA4.32015-04-20T19:46:51Z<p>Smyers: /* Self-Calibration */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use. For example, for a particular instance of<br />
the previous clean, we found:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 9.50934186]),<br />
'max': array([ 0.15526876]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00089436]),<br />
'medabsdevmed': array([ 0.00015567]),<br />
'median': array([ 1.27408730e-05]),<br />
'min': array([-0.00516682]),<br />
'minpos': array([279, 429, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.48.079, I, 4.59901e+09Hz',<br />
'npts': array([ 474784.]),<br />
'quartile': array([ 0.00031206]),<br />
'rms': array([ 0.00607521]),<br />
'sigma': array([ 0.00600903]),<br />
'sum': array([ 424.62918042]),<br />
'sumsq': array([ 17.52343054]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 22119 4.242001e+02 9.499733e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
1.917809e-02 2.799428e-02 2.039361e-02 -2.618031e-03 1.552688e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 9.5 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image <br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.092479e+00 -6.925440e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-5.865299e-05 5.103085e-04 5.069314e-04 -1.945960e-03 2.282981e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -1.474115e-01 -3.301201e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-2.795856e-06 5.614272e-05 5.607359e-05 -3.039683e-04 2.997937e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 7.583902e-02 1.698374e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.438388e-06 5.492329e-05 5.490497e-05 -3.513077e-04 2.247283e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.244009e-01 -7.264784e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.152697e-06 1.186217e-04 1.184631e-04 -4.345808e-04 3.379770e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.51 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean. Note that the <br />
<tt>gaincal</tt> step will report a number of solutions with insufficient SNR. By default with <tt>applymode=''</tt> data with no good solutions will be flagged by <tt>applycal</tt>, in this case you will see it report the flagged fraction increasing from 28% to 43%. This may or may not be a good thing. You can control the action of <tt>applycal</tt> in this regard by changing the value of <tt>applymode</tt>: setting <tt>applymode='calflagstrict'</tt> will be even more stringent about flagging things without valid calibration, while <tt>applymode='calonly'</tt> will calibrate those with solutions while passing through data without unchanged. Note that you can see ahead of time what applycal will do by running with <tt>applymode='trial'</tt> which will do the reporting but nothing else.<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Does allowing applycal to flag the data give better images?<br />
* Or, does using <tt>applymode='calonly'</tt> give improved results?<br />
|-<br />
|}<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16773EVLA Advanced Topics 3C391-CASA4.32015-04-20T19:45:18Z<p>Smyers: /* Self-Calibration */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use. For example, for a particular instance of<br />
the previous clean, we found:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 9.50934186]),<br />
'max': array([ 0.15526876]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00089436]),<br />
'medabsdevmed': array([ 0.00015567]),<br />
'median': array([ 1.27408730e-05]),<br />
'min': array([-0.00516682]),<br />
'minpos': array([279, 429, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.48.079, I, 4.59901e+09Hz',<br />
'npts': array([ 474784.]),<br />
'quartile': array([ 0.00031206]),<br />
'rms': array([ 0.00607521]),<br />
'sigma': array([ 0.00600903]),<br />
'sum': array([ 424.62918042]),<br />
'sumsq': array([ 17.52343054]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 22119 4.242001e+02 9.499733e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
1.917809e-02 2.799428e-02 2.039361e-02 -2.618031e-03 1.552688e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 9.5 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image <br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.092479e+00 -6.925440e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-5.865299e-05 5.103085e-04 5.069314e-04 -1.945960e-03 2.282981e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -1.474115e-01 -3.301201e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-2.795856e-06 5.614272e-05 5.607359e-05 -3.039683e-04 2.997937e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 7.583902e-02 1.698374e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.438388e-06 5.492329e-05 5.490497e-05 -3.513077e-04 2.247283e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.244009e-01 -7.264784e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.152697e-06 1.186217e-04 1.184631e-04 -4.345808e-04 3.379770e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.51 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean. Note that the <br />
<tt>gaincal</tt> step will report a number of solutions with SNR<3. By default with <tt>applymode=''</tt> data with no good solutions will be flagged by <tt>applycal</tt>, in this case you will see it report the flagged fraction increasing from 28% to 43%. This may or may not be a good thing. You can control the action of <tt>applycal</tt> in this regard by changing the value of <tt>applymode</tt>: setting <tt>applymode='calflagstrict'</tt> will be even more stringent about flagging things without valid calibration, while <tt>applymode='calonly'</tt> will calibrate those with solutions while passing through data without unchanged. Note that you can see ahead of time what applycal will do by running with <tt>applymode='trial'</tt> which will do the reporting but nothing else.<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Does allowing applycal to flag the data give better images?<br />
* Or, does using <tt>applymode='calonly'</tt> give improved results?<br />
|-<br />
|}<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16772EVLA Advanced Topics 3C391-CASA4.32015-04-20T16:40:16Z<p>Smyers: /* Spectral Index Imaging */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use. For example, for a particular instance of<br />
the previous clean, we found:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 9.50934186]),<br />
'max': array([ 0.15526876]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00089436]),<br />
'medabsdevmed': array([ 0.00015567]),<br />
'median': array([ 1.27408730e-05]),<br />
'min': array([-0.00516682]),<br />
'minpos': array([279, 429, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.48.079, I, 4.59901e+09Hz',<br />
'npts': array([ 474784.]),<br />
'quartile': array([ 0.00031206]),<br />
'rms': array([ 0.00607521]),<br />
'sigma': array([ 0.00600903]),<br />
'sum': array([ 424.62918042]),<br />
'sumsq': array([ 17.52343054]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 22119 4.242001e+02 9.499733e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
1.917809e-02 2.799428e-02 2.039361e-02 -2.618031e-03 1.552688e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 9.5 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image <br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.092479e+00 -6.925440e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-5.865299e-05 5.103085e-04 5.069314e-04 -1.945960e-03 2.282981e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -1.474115e-01 -3.301201e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-2.795856e-06 5.614272e-05 5.607359e-05 -3.039683e-04 2.997937e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 7.583902e-02 1.698374e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.438388e-06 5.492329e-05 5.490497e-05 -3.513077e-04 2.247283e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.244009e-01 -7.264784e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.152697e-06 1.186217e-04 1.184631e-04 -4.345808e-04 3.379770e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.51 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16771EVLA Advanced Topics 3C391-CASA4.32015-04-17T23:30:19Z<p>Smyers: /* Image Analysis and Manipulation */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use. For example, for a particular instance of<br />
the previous clean, we found:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 9.50934186]),<br />
'max': array([ 0.15526876]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00089436]),<br />
'medabsdevmed': array([ 0.00015567]),<br />
'median': array([ 1.27408730e-05]),<br />
'min': array([-0.00516682]),<br />
'minpos': array([279, 429, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.48.079, I, 4.59901e+09Hz',<br />
'npts': array([ 474784.]),<br />
'quartile': array([ 0.00031206]),<br />
'rms': array([ 0.00607521]),<br />
'sigma': array([ 0.00600903]),<br />
'sum': array([ 424.62918042]),<br />
'sumsq': array([ 17.52343054]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 22119 4.242001e+02 9.499733e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
1.917809e-02 2.799428e-02 2.039361e-02 -2.618031e-03 1.552688e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 9.5 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image <br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.092479e+00 -6.925440e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-5.865299e-05 5.103085e-04 5.069314e-04 -1.945960e-03 2.282981e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -1.474115e-01 -3.301201e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-2.795856e-06 5.614272e-05 5.607359e-05 -3.039683e-04 2.997937e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 7.583902e-02 1.698374e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.438388e-06 5.492329e-05 5.490497e-05 -3.513077e-04 2.247283e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 52725 -3.244009e-01 -7.264784e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.152697e-06 1.186217e-04 1.184631e-04 -4.345808e-04 3.379770e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.51 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16770EVLA Advanced Topics 3C391-CASA4.32015-04-17T23:24:01Z<p>Smyers: /* Image Analysis and Manipulation */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use. For example, for a particular instance of<br />
the previous clean, we found:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 9.50934186]),<br />
'max': array([ 0.15526876]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00089436]),<br />
'medabsdevmed': array([ 0.00015567]),<br />
'median': array([ 1.27408730e-05]),<br />
'min': array([-0.00516682]),<br />
'minpos': array([279, 429, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.48.079, I, 4.59901e+09Hz',<br />
'npts': array([ 474784.]),<br />
'quartile': array([ 0.00031206]),<br />
'rms': array([ 0.00607521]),<br />
'sigma': array([ 0.00600903]),<br />
'sum': array([ 424.62918042]),<br />
'sumsq': array([ 17.52343054]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 44.6539 22119 4.242001e+02 9.499733e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
1.917809e-02 2.799428e-02 2.039361e-02 -2.618031e-03 1.552688e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 9.5 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16768EVLA Advanced Topics 3C391-CASA4.32015-04-17T23:18:04Z<p>Smyers: /* Image Analysis and Manipulation */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use. For example, for a particular instance of<br />
the previous clean, we found:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16767EVLA Advanced Topics 3C391-CASA4.32015-04-17T23:11:29Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b> If you are using a later version of CASA and this is the most recent <br />
available guide, then you should be able to use most, if not all, of this casaguide, as we try to limit script breaking changes<br />
in CASA development.<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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391-CASA4.3&diff=16766EVLA Advanced Topics 3C391-CASA4.32015-04-17T22:09:25Z<p>Smyers: Created page with "Category:EVLA This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 T..."</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.3.1 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16765EVLA Continuum Tutorial 3C391-CASA4.32015-04-17T20:39:26Z<p>Smyers: /* Polarization Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
p0=0.112*i0 # Fractional polarization=11.2%<br />
q0=p0*cos(66*pi/180) # Stokes Q for spw 0 for pang = 33deg (Q+iU phase = 66deg)<br />
u0=p0*sin(66*pi/180) # Stokes U for spw 0 for pang = 33deg (Q+iU phase = 66deg)<br />
</source><br />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
--><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
--><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure value for the calibrator, for 3C286 it is zero<br />
--><br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability, although as of 4.3.1 it will not work correctly for all values of polangle and thus is still experimental. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those shown at right (you might get slightly different values).<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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False</tt> : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.3406474, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.00617762, 0. , 0. , 0. ]),<br />
'numSol': array([ 48., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.92407097, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.03710194, 0. , 0. , 0. ]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 (freq=4.536e+09 Hz) is: 2.34065 +/- 0.00617762 (SNR = 378.891, N = 48)<br />
Flux density for J0319+4130 in SpW=0 (freq=4.536e+09 Hz) is: 13.9241 +/- 0.0371019 (SNR = 375.292, N = 46)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16764EVLA Continuum Tutorial 3C391-CASA4.32015-04-17T20:38:05Z<p>Smyers: /* Polarization Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
--><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
--><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure value for the calibrator, for 3C286 it is zero<br />
--><br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability, although as of 4.3.1 it will not work correctly for all values of polangle and thus is still experimental. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those shown at right (you might get slightly different values).<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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False</tt> : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.3406474, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.00617762, 0. , 0. , 0. ]),<br />
'numSol': array([ 48., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.92407097, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.03710194, 0. , 0. , 0. ]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 (freq=4.536e+09 Hz) is: 2.34065 +/- 0.00617762 (SNR = 378.891, N = 48)<br />
Flux density for J0319+4130 in SpW=0 (freq=4.536e+09 Hz) is: 13.9241 +/- 0.0371019 (SNR = 375.292, N = 46)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16763EVLA Continuum Tutorial 3C391-CASA4.32015-04-17T20:37:13Z<p>Smyers: /* Polarization Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
--><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
--><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure value for the calibrator, for 3C286 it is zero<br />
--><br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability, although as of 4.3.1 it will not work correctly for all values of polangle and thus is still experimental. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those shown at right (you might get slightly different values).<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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False</tt> : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.3406474, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.00617762, 0. , 0. , 0. ]),<br />
'numSol': array([ 48., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.92407097, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.03710194, 0. , 0. , 0. ]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 (freq=4.536e+09 Hz) is: 2.34065 +/- 0.00617762 (SNR = 378.891, N = 48)<br />
Flux density for J0319+4130 in SpW=0 (freq=4.536e+09 Hz) is: 13.9241 +/- 0.0371019 (SNR = 375.292, N = 46)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16762EVLA Continuum Tutorial 3C391-CASA4.32015-04-17T20:36:37Z<p>Smyers: /* Polarization Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
--><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
--><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
<!-- *as of 4.3.1 the following will not work correctly for general cases, so we do not include this here<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure value for the calibrator, for 3C286 it is zero<br />
--><br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability, although as of 4.3.1 it will not work correctly for all values of polangle and thus is still experimental. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those shown at right (you might get slightly different values).<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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False</tt> : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.3406474, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.00617762, 0. , 0. , 0. ]),<br />
'numSol': array([ 48., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.92407097, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.03710194, 0. , 0. , 0. ]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 (freq=4.536e+09 Hz) is: 2.34065 +/- 0.00617762 (SNR = 378.891, N = 48)<br />
Flux density for J0319+4130 in SpW=0 (freq=4.536e+09 Hz) is: 13.9241 +/- 0.0371019 (SNR = 375.292, N = 46)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16753EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T22:15:15Z<p>Smyers: /* Scaling the Amplitude Gains */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure valuse for the calibrator, for 3C286 it is zero<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those shown at right (you might get slightly different values).<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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False</tt> : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.3406474, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.00617762, 0. , 0. , 0. ]),<br />
'numSol': array([ 48., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.92407097, 0. , 0. , 0. ]),<br />
'fluxdErr': array([ 0.03710194, 0. , 0. , 0. ]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 (freq=4.536e+09 Hz) is: 2.34065 +/- 0.00617762 (SNR = 378.891, N = 48)<br />
Flux density for J0319+4130 in SpW=0 (freq=4.536e+09 Hz) is: 13.9241 +/- 0.0371019 (SNR = 375.292, N = 46)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16752EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T22:09:34Z<p>Smyers: /* Solving for the Leakage Terms */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure valuse for the calibrator, for 3C286 it is zero<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those shown at right (you might get slightly different values).<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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16751EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T21:49:30Z<p>Smyers: /* Polarization Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 33 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 0<br />
</source><br />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 33.0*pi/180.0 # 3C286 33deg to radians<br />
</source><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure valuse for the calibrator, for 3C286 it is zero<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png',overwrite=True)<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png',overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees (twice the polarization<br />
angle) as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png',<br />
overwrite=True)<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16750EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T21:37:15Z<p>Smyers: /* Polarization Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4 onward, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>. Finally, in CASA 4.3, we have the ability to set the polarization angle and fraction directly (earlier versions you must set Q and U).<br />
<source lang="python"><br />
# In CASA<br />
fpol = 0.112 # Fractional polarization=11.2%<br />
pang = 66.0*pi/180.0 # 3C286 66deg to radians<br />
</source><br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using the abovevalues. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,0,0,0],spix=alpha,reffreq='4536.0MHz',<br />
polindex=[fpol],polangle=[pang],rotmeas=0.0,<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>polindex=[fpol] : the fractional polarization of 3C286 at this frequency set earlier<br />
* <tt>polindex=[pang] : the polarization angle of 3C286 at this frequency set earlier (in radians)<br />
* <tt>rotmeas=0.0 : you can set a rotation measure valuse for the calibrator, for 3C286 it is zero<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. CASA 4.3 added the polindex, polangle and rotmeas capability. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16749EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T20:40:10Z<p>Smyers: /* Initial Phase Calibration */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get to ea05, note the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16748EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T20:36:27Z<p>Smyers: /* Flux Density Scale */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
Note that setjy also returns a python dictionary (CASA record) containing the reference flux density used. In our case, you will find on the command line the return value:<br />
<pre><br />
{'0': {'0': {'fluxd': array([ 7.81694196, 0. , 0. , 0. ])},<br />
'fieldName': 'J1331+3030'},<br />
'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}<br />
</pre><br />
If desired, one can capture this by calling the task by setting it to a variable, e.g. <tt>myset = setjy(...</tt>.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get top ea05, ote the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16747EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T20:32:57Z<p>Smyers: /* Flux Density Scale */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im <br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/...<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09,...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get top ea05, ote the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16746EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T20:31:33Z<p>Smyers: /* Flux Density Scale */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 (some lines are truncated over what is in the logger):<br />
<pre style="background-color: #ffe4b5;"><br />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im for modimage.<br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09, 4.599e+09, 4.663e+09)Hz...<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get top ea05, ote the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16745EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T20:30:09Z<p>Smyers: /* Flux Density Scale */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im for modimage.<br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09, 4.599e+09, 4.663e+09)Hz for visibility prediction (a few representative values are shown).<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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. Also, setjy will clear any previous calibration model that fits the selection. In this case, no such previous model data was found.<br />
<br />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get top ea05, ote the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16744EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T20:28:26Z<p>Smyers: /* Flux Density Scale */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 />
setjy::::casa ##########################################<br />
setjy::::casa ##### Begin Task: setjy #####<br />
setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,timerange="",<br />
setjy::::casa+ scan="",intent="",observation="",scalebychan=True,standard="Perley-Butler 2010",<br />
setjy::::casa+ model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,spix=0.0,<br />
setjy::::casa+ reffreq="1GHz",polindex=[],polangle=[],rotmeas=0.0,fluxdict={},<br />
setjy::::casa+ useephemdir=False,interpolation="nearest",usescratch=False)<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.3_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im for modimage.<br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy @ 4.536e+09Hz, (Perley-Butler 2010)<br />
imager::setjy() Using model image /home/casa/packages/RHEL5/release/casa-release-4.3.1-el5/data/nrao/VLA/CalModels/3C286_C.im<br />
imager::setjy() Scaling spw(s) [0]'s model image by channel to I = 7.81801, 7.75036, 7.68404 Jy @(4.535e+09, 4.599e+09, 4.663e+09)Hz for visibility prediction (a few representative values are shown).<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) not found.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
setjy::::casa ##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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 />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get top ea05, ote the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16743EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T19:24:50Z<p>Smyers: /* A priori Antenna Position Corrections */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but are instead in the old VLA database, as they were determined before the changeover in Jan 2010. They will have been applied at the time of observation.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 />
##########################################<br />
##### Begin Task: setjy #####<br />
setjy::::casa setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,<br />
setjy::::casa+ timerange="",scan="",intent="",observation="",scalebychan=True,<br />
setjy::::casa+ standard="Perley-Butler 2010",model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,<br />
setjy::::casa+ spix=0.0,reffreq="1GHz",fluxdict={},useephemdir=False,interpolation="nearest",<br />
setjy::::casa+ usescratch=False)<br />
setjy::::casa standard=Perley-Butler 2010<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.2_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels/3C286_C.im for modimage.<br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy, (Perley-Butler 2010)<br />
imager::setjy() Using model image /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels/3C286_C.im<br />
imager::setjy() Scaling spw 0's model image by channel to I = [7.81908, 7.81688, 7.81468, 7.81248, 7.81028, 7.80808, 7.80588, 7.80369, 7.80149, 7.7993, 7.79711, 7.79492, 7.79273, 7.79055, 7.78836, 7.78618, 7.784, 7.78182, 7.77964, 7.77746, 7.77528, 7.77311, 7.77093, 7.76876, 7.76659, 7.76442, 7.76225, 7.76009, 7.75792, 7.75576, 7.7536, 7.75143, 7.74927, 7.74712, 7.74496, 7.7428, 7.74065, 7.7385, 7.73635, 7.7342, 7.73205, 7.7299, 7.72776, 7.72561, 7.72347, 7.72133, 7.71919, 7.71705, 7.71491, 7.71277, 7.71064, 7.70851, 7.70637, 7.70424, 7.70211, 7.69999, 7.69786, 7.69574, 7.69361, 7.69149, 7.68937, 7.68725, 7.68513, 7.68301] Jy (ch 0) for visibility prediction.<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) deleted.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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 />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get top ea05, ote the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16742EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T19:23:34Z<p>Smyers: /* A priori Antenna Position Corrections */</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><br />
The observations were taken 24-April-2010, so antennas that were moved BEFORE that date, but whose corrections were not applied before that date need to be corrected. Note in reading this table a blank in the first column means that the antenna was not moved at that time but has updated locations that need to be applied. One complication specific to this and other observations with the early EVLA (early 2010) is that previous location determinations are not necessarily in the EVLA database but might be in the old VLA database, as they were determined before the changeover in Jan 2010.<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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 />
##########################################<br />
##### Begin Task: setjy #####<br />
setjy::::casa setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,<br />
setjy::::casa+ timerange="",scan="",intent="",observation="",scalebychan=True,<br />
setjy::::casa+ standard="Perley-Butler 2010",model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,<br />
setjy::::casa+ spix=0.0,reffreq="1GHz",fluxdict={},useephemdir=False,interpolation="nearest",<br />
setjy::::casa+ usescratch=False)<br />
setjy::::casa standard=Perley-Butler 2010<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.2_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels/3C286_C.im for modimage.<br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy, (Perley-Butler 2010)<br />
imager::setjy() Using model image /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels/3C286_C.im<br />
imager::setjy() Scaling spw 0's model image by channel to I = [7.81908, 7.81688, 7.81468, 7.81248, 7.81028, 7.80808, 7.80588, 7.80369, 7.80149, 7.7993, 7.79711, 7.79492, 7.79273, 7.79055, 7.78836, 7.78618, 7.784, 7.78182, 7.77964, 7.77746, 7.77528, 7.77311, 7.77093, 7.76876, 7.76659, 7.76442, 7.76225, 7.76009, 7.75792, 7.75576, 7.7536, 7.75143, 7.74927, 7.74712, 7.74496, 7.7428, 7.74065, 7.7385, 7.73635, 7.7342, 7.73205, 7.7299, 7.72776, 7.72561, 7.72347, 7.72133, 7.71919, 7.71705, 7.71491, 7.71277, 7.71064, 7.70851, 7.70637, 7.70424, 7.70211, 7.69999, 7.69786, 7.69574, 7.69361, 7.69149, 7.68937, 7.68725, 7.68513, 7.68301] Jy (ch 0) for visibility prediction.<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) deleted.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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 />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get top ea05, ote the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391-CASA4.3&diff=16741EVLA Continuum Tutorial 3C391-CASA4.32015-04-15T19:16:32Z<p>Smyers: Created page with "Category:EVLACategory:Calibration This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Adva..."</p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.3.1 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 />
##########################################<br />
##### Begin Task: setjy #####<br />
setjy::::casa setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,<br />
setjy::::casa+ timerange="",scan="",intent="",observation="",scalebychan=True,<br />
setjy::::casa+ standard="Perley-Butler 2010",model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,<br />
setjy::::casa+ spix=0.0,reffreq="1GHz",fluxdict={},useephemdir=False,interpolation="nearest",<br />
setjy::::casa+ usescratch=False)<br />
setjy::::casa standard=Perley-Butler 2010<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.2_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels/3C286_C.im for modimage.<br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy, (Perley-Butler 2010)<br />
imager::setjy() Using model image /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels/3C286_C.im<br />
imager::setjy() Scaling spw 0's model image by channel to I = [7.81908, 7.81688, 7.81468, 7.81248, 7.81028, 7.80808, 7.80588, 7.80369, 7.80149, 7.7993, 7.79711, 7.79492, 7.79273, 7.79055, 7.78836, 7.78618, 7.784, 7.78182, 7.77964, 7.77746, 7.77528, 7.77311, 7.77093, 7.76876, 7.76659, 7.76442, 7.76225, 7.76009, 7.75792, 7.75576, 7.7536, 7.75143, 7.74927, 7.74712, 7.74496, 7.7428, 7.74065, 7.7385, 7.73635, 7.7342, 7.73205, 7.7299, 7.72776, 7.72561, 7.72347, 7.72133, 7.71919, 7.71705, 7.71491, 7.71277, 7.71064, 7.70851, 7.70637, 7.70424, 7.70211, 7.69999, 7.69786, 7.69574, 7.69361, 7.69149, 7.68937, 7.68725, 7.68513, 7.68301] Jy (ch 0) for visibility prediction.<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) deleted.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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 />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get top ea05, ote the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 spectral window, 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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.3.1}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2&diff=15571EVLA Advanced Topics 3C391 CASA 4.22014-02-06T18:10:14Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 CASA 4.2 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 CASA 4.2#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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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 CASA 4.2 | 3C391 Continuum Tutorial]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2&diff=15570EVLA Continuum Tutorial 3C391 CASA 4.22014-02-06T17:26:39Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.2.0 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 />
##########################################<br />
##### Begin Task: setjy #####<br />
setjy::::casa setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,<br />
setjy::::casa+ timerange="",scan="",intent="",observation="",scalebychan=True,<br />
setjy::::casa+ standard="Perley-Butler 2010",model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,<br />
setjy::::casa+ spix=0.0,reffreq="1GHz",fluxdict={},useephemdir=False,interpolation="nearest",<br />
setjy::::casa+ usescratch=False)<br />
setjy::::casa standard=Perley-Butler 2010<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.2_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels/3C286_C.im for modimage.<br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy, (Perley-Butler 2010)<br />
imager::setjy() Using model image /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels/3C286_C.im<br />
imager::setjy() Scaling spw 0's model image by channel to I = [7.81908, 7.81688, 7.81468, 7.81248, 7.81028, 7.80808, 7.80588, 7.80369, 7.80149, 7.7993, 7.79711, 7.79492, 7.79273, 7.79055, 7.78836, 7.78618, 7.784, 7.78182, 7.77964, 7.77746, 7.77528, 7.77311, 7.77093, 7.76876, 7.76659, 7.76442, 7.76225, 7.76009, 7.75792, 7.75576, 7.7536, 7.75143, 7.74927, 7.74712, 7.74496, 7.7428, 7.74065, 7.7385, 7.73635, 7.7342, 7.73205, 7.7299, 7.72776, 7.72561, 7.72347, 7.72133, 7.71919, 7.71705, 7.71491, 7.71277, 7.71064, 7.70851, 7.70637, 7.70424, 7.70211, 7.69999, 7.69786, 7.69574, 7.69361, 7.69149, 7.68937, 7.68725, 7.68513, 7.68301] Jy (ch 0) for visibility prediction.<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) deleted.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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 />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get top ea05, ote the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2#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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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_CASA_4.2#Polarization_Calibration Polarization Calibration]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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_CASA_4.2#Polarization_Calibration Polarization_Calibration]] section, the .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_6cmWideband_Tutorial_SN2010FZ_CASA_4.2&diff=15569EVLA 6cmWideband Tutorial SN2010FZ CASA 4.22014-02-06T17:17:52Z<p>Smyers: /* Imaging */</p>
<hr />
<div>This is an Advanced EVLA data reduction tutorial that calibrates and images a 6-cm wide-band continuum dataset.<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><br />
== Overview ==<br />
<br />
This article describes the calibration and imaging of a single-pointing 6-cm EVLA wideband continuum dataset of the galaxy NGC2967 (UGC5180) which was the location of the supernova candidate SN2010FZ. No supernova was detected in this observation, but the galactic continuum emission from this face-on spiral is nicely imaged. The data were taken in with 1024 MHz of bandwidth in each of two widely spaced basebands (each comprised of 8 128-MHz spectral windows), spanning 4.5 to 7.5 GHz. We will use wideband imaging techniques in this tutorial.<br />
<br />
This is a more advanced tutorial, and if you are a relative novice (and <em>particularly</em> for EVLA continuum calibration and imaging), it is <em>strongly</em> recommended that you start with the [[EVLA Continuum Tutorial 3C391 CASA 4.2]] (at least read it through) before tackling this dataset. We will not include basic information on CASA processing in this tutorial.<br />
<br />
From the [http://casaguides.nrao.edu MainPage] of this guide you can find helpful information:<br />
* [[What is CASA?]]<br />
* [[Getting Started in CASA]]<br />
* [[CASA Reference Manuals]]<br />
* [[Hints, Tips, & Tricks]]<br />
* [[AIPS-to-CASA Cheat Sheet]]<br />
<br />
In this tutorial we will be invoking the tasks as function calls. You can cut and paste these to your casapy session. We also recommend that you copy all the commands you use, with any relevant commentary, to a text file. This is good practice when tackling large datasets. If you wish, you can use the [http://casaguides.nrao.edu/index.php?title=Extracting_scripts_from_these_tutorials Script Extractor] to create a file with the tutorial commands, which can subsequently be edited as desired.<br />
<br />
Occasionally we will be setting Python variables (e.g. as lists for flags) outside the function call so make sure you<br />
set those before running the task command. Note that when you call a CASA task as a function the task parameters you<br />
do not set in the function call (assuming there is at least one) will be set to their defaults, and will not use values<br />
you set in previous calls or outside the call. See [[Getting_Started_in_CASA#Task_Execution]] for more <br />
on calling tasks and setting parameters in the scripting interface.<br />
<br />
NOTE: If you find that the figures on the right margin of the browser window overlap the text too much and make reading difficult,<br />
go ahead and widen the browser window.<br />
<br />
== Obtaining the Data ==<br />
<br />
The data for this tutorial were taken with the EVLA under program AS1015 as the scheduling block (SB) <tt>AS1015_sb1658169_1.55388.89474846065</tt>, and was run on 2010-07-11 from 21:28 to 22:28 UT (size 37.74GB). <br />
<br />
The data can be directly downloaded from [http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz] (dataset size: 2.9 GB). For example, in you Linux terminal:<br />
<br />
<source lang="bash"><br />
wget http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz<br />
</source><br />
<br />
Your first step will be to unzip and untar the file in a terminal, before you start CASA:<br />
<br />
<source lang="bash"><br />
tar -xzvf SN2010FZ_10s.ms.tar.gz <br />
</source><br />
<br />
If you are brave enough, you can also get the data straight from the EVLA archive. Go to the [https://archive.nrao.edu/archive/advquery.jsp NRAO Science Data Archive], and search for project **AS1015**. Then select the <tt>AS1015_sb1658169_1.55388.89474846065</tt> dataset and choose to apply the online flags (check box "Apply flags generated during observing") and time-averaging of 10 seconds. (The data were taken in D-configuration [max baselines 1km], so one can safely average to 3s or even 10s to reduce dataset size.) Also select the tar option. This will create a file equivalent to what is used at the workshop.<br />
<br />
== Starting CASA ==<br />
<br />
{{CaltechCASAStartup}}<br />
<br />
== Examining the MS ==<br />
<br />
We use {{listobs}} to summarize our MS:<br />
<source lang="python"><br />
# In CASA<br />
listobs('SN2010FZ_10s.ms')<br />
</source><br />
<br />
In the logger you should see:<br />
<br />
<pre><br />
##########################################<br />
##### Begin Task: listobs #####<br />
<br />
================================================================================<br />
MeasurementSet Name: SN2010FZ_10s.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. Alicia M. Soderberg Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 1570726 Total integration time = 3359 seconds<br />
Observed from 11-Jul-2010/21:30:44.0 to 11-Jul-2010/22:26:43.0 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) SpwIds ScanIntent<br />
11-Jul-2010/21:30:44.0 - 21:30:52.0 2 0 J0925+0019 404 6.43 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:31:02.0 - 21:32:22.0 3 0 J0925+0019 5062 9.68 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:32:32.0 - 21:33:52.0 4 0 J0925+0019 6277 9.91 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:34:02.0 - 21:34:52.0 5 0 J0925+0019 4148 9.96 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:35:02.0 - 21:35:51.5 6 0 J0925+0019 32640 9.44 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:36:01.0 - 21:38:20.5 7 0 J0925+0019 81600 9.93 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:38:44.0 - 21:39:51.0 9 1 SN2010FZ 43520 9.16 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:40:01.0 - 21:41:20.5 10 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:41:30.0 - 21:42:50.0 11 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:43:00.0 - 21:44:20.0 12 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:44:30.0 - 21:45:50.0 13 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:46:00.0 - 21:47:19.5 14 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:47:29.0 - 21:47:49.0 15 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:48:12.0 - 21:49:18.5 16 0 J0925+0019 43520 9 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:49:42.0 - 21:50:49.0 17 1 SN2010FZ 43520 9.17 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:50:59.0 - 21:52:19.0 18 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:52:29.0 - 21:53:48.5 19 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:53:58.0 - 21:55:18.0 20 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:55:28.0 - 21:56:48.0 21 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:56:58.0 - 21:58:18.0 22 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:58:28.0 - 21:58:47.5 23 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:59:10.5 - 22:00:17.0 24 0 J0925+0019 43520 8.99 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:00:39.5 - 22:01:47.0 25 1 SN2010FZ 43520 9.18 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:01:57.0 - 22:03:17.0 26 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:03:27.0 - 22:04:47.0 27 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:04:57.0 - 22:06:16.5 28 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:06:26.0 - 22:07:46.0 29 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:07:56.0 - 22:09:16.0 30 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:09:26.0 - 22:09:45.5 31 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:10:08.0 - 22:11:15.5 32 0 J0925+0019 43520 9.13 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:11:38.0 - 22:12:45.5 33 1 SN2010FZ 43520 9.19 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:12:55.0 - 22:14:15.0 34 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:14:25.0 - 22:15:45.0 35 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:15:55.0 - 22:17:15.0 36 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:17:25.0 - 22:18:44.5 37 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:18:54.0 - 22:20:14.0 38 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:20:24.0 - 22:20:43.5 39 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:21:06.0 - 22:22:13.5 40 0 J0925+0019 42690 9.15 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:25:13.0 - 22:25:13.0 42 2 3C286 1028 2.87 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
22:25:23.0 - 22:26:43.0 43 2 3C286 47757 9.6 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
(nVis = Total number of time/baseline visibilities per scan) <br />
Fields: 3<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 D J0925+0019 09:25:07.81503 +00.19.13.9334 J2000 0 303381 <br />
1 NONE SN2010FZ 09:42:04.77000 +00.19.51.0000 J2000 1 1218560<br />
2 K 3C286 13:31:08.28798 +30.30.32.9589 J2000 2 48785 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (18 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 64 TOPO 7686 2000 128000 RR RL LR LL <br />
1 64 TOPO 7836 2000 128000 RR RL LR LL <br />
2 64 TOPO 4488 2000 128000 RR RL LR LL <br />
3 64 TOPO 4616 2000 128000 RR RL LR LL <br />
4 64 TOPO 4744 2000 128000 RR RL LR LL <br />
5 64 TOPO 4872 2000 128000 RR RL LR LL <br />
6 64 TOPO 5000 2000 128000 RR RL LR LL <br />
7 64 TOPO 5128 2000 128000 RR RL LR LL <br />
8 64 TOPO 5256 2000 128000 RR RL LR LL <br />
9 64 TOPO 5384 2000 128000 RR RL LR LL <br />
10 64 TOPO 6488 2000 128000 RR RL LR LL <br />
11 64 TOPO 6616 2000 128000 RR RL LR LL <br />
12 64 TOPO 6744 2000 128000 RR RL LR LL <br />
13 64 TOPO 6872 2000 128000 RR RL LR LL <br />
14 64 TOPO 7000 2000 128000 RR RL LR LL <br />
15 64 TOPO 7128 2000 128000 RR RL LR LL <br />
16 64 TOPO 7256 2000 128000 RR RL LR LL <br />
17 64 TOPO 7384 2000 128000 RR RL LR LL <br />
Sources: 50<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J0925+0019 0 - - <br />
0 J0925+0019 1 - - <br />
0 J0925+0019 2 - - <br />
0 J0925+0019 3 - - <br />
0 J0925+0019 4 - - <br />
0 J0925+0019 5 - - <br />
0 J0925+0019 6 - - <br />
0 J0925+0019 7 - - <br />
0 J0925+0019 8 - - <br />
0 J0925+0019 9 - - <br />
0 J0925+0019 10 - - <br />
0 J0925+0019 11 - - <br />
0 J0925+0019 12 - - <br />
0 J0925+0019 13 - - <br />
0 J0925+0019 14 - - <br />
0 J0925+0019 15 - - <br />
0 J0925+0019 16 - - <br />
0 J0925+0019 17 - - <br />
1 SN2010FZ 2 - - <br />
1 SN2010FZ 3 - - <br />
1 SN2010FZ 4 - - <br />
1 SN2010FZ 5 - - <br />
1 SN2010FZ 6 - - <br />
1 SN2010FZ 7 - - <br />
1 SN2010FZ 8 - - <br />
1 SN2010FZ 9 - - <br />
1 SN2010FZ 10 - - <br />
1 SN2010FZ 11 - - <br />
1 SN2010FZ 12 - - <br />
1 SN2010FZ 13 - - <br />
1 SN2010FZ 14 - - <br />
1 SN2010FZ 15 - - <br />
1 SN2010FZ 16 - - <br />
1 SN2010FZ 17 - - <br />
2 3C286 2 - - <br />
2 3C286 3 - - <br />
2 3C286 4 - - <br />
2 3C286 5 - - <br />
2 3C286 6 - - <br />
2 3C286 7 - - <br />
2 3C286 8 - - <br />
2 3C286 9 - - <br />
2 3C286 10 - - <br />
2 3C286 11 - - <br />
2 3C286 12 - - <br />
2 3C286 13 - - <br />
2 3C286 14 - - <br />
2 3C286 15 - - <br />
2 3C286 16 - - <br />
2 3C286 17 - - <br />
Antennas: 27:<br />
ID Name Station Diam. Long. Lat. <br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
5 ea06 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
8 ea10 N03 25.0 m -107.37.06.3 +33.54.04.8 <br />
9 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
10 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
11 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
12 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
13 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
14 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
15 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
16 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
17 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
18 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
19 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
20 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
21 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
22 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
23 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
24 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
25 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
26 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
<br />
##### End Task: listobs #####<br />
##########################################<br />
</pre><br />
<br />
This task displays a lot of information about the MS. We can see that the observation was performed with the EVLA, for a total integration of 3359 seconds (1 hour). The number of data records (1570726) is equal to the number of baselines (N_antenna * [N_antenna - 1] / 2) X the number of integrations (observing time / time-average binning) X the number of spectral windows. For this observation, this is roughly 351 baselines (27X26/2) X 360 integrations (3600s total/10s avg) X 16 spectral windows = 2021760. Note that this is high by ~30%; this is because the archive already flagged bad data, and there are some scans which only have two (rather than 16) spectral windows present. Extra exercise: examine the MS using {{browsetable}} to see what a data record looks like (equivalent to a row, as displayed by this task).<br />
<br />
The most useful parts of the {{listobs}} output are the scan, field, and spectral window listings. <br />
<br />
From the spectral window information, we can see that there were a total of 18 (0 through 17) spectral windows in this dataset. The first two of these (0 and 1) were only used to help set up the correlator. <br />
<br />
Looking at the scan listing, we can see that the first four scans which are present used only these spectral windows. These are referred to as "dummy scans". We will not be using these, since they often contain bad data. <br />
<br />
The C-band data of interest is contained in scans 6-44 and spectral windows 2 to 17. Careful examination shows that scan 8 is missing but from the time ranges that the data has been merged into scan 7. This sort of correlator back-end data-capture issue was occasionally seen during 2010. Hopefully, it will not affect our data, but we should keep an eye out for problems with scan 7. <br />
<br />
The field listing shows three sources: <br />
<br />
* J0925+0019 (also referred to by its field ID, 0), which will serve as a calibrator for the visibility phases, <br />
* SN2010FZ (1), our science target field, and <br />
* 3C286 (2), which will serve as a calibrator for the visibility amplitudes, i.e., it is assumed to have a precisely known flux density; as well as the spectral bandpass.<br />
<br />
== Flagging the MS ==<br />
<br />
The online flags, which are a record of known bad data produced by the EVLA online system, have already been applied by the archive as it generated the MS. However, it's good to have a sense of what was deleted in this process. A record of the flags is also stored in a separate table in the MS, called <tt>FLAG_CMD</tt>. (In fact, the information for this table is actually a subdirectory within the MS; you can see this by listing the contents of <tt>SN2010FZ_10s.ms</tt>.)<br />
<br />
[[Image:PlotSN2010FZ_flagcmd_3.4.png|200px|thumb|right|online flags plotted from flagcmd]]<br />
You can examine the commands stored in the <tt>FLAG_CMD</tt> table using {{flagcmd}}.<br />
<source lang="python"><br />
# In CASA<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='table',action='list')<br />
</source><br />
These will go to the logger or terminal (they appear to go to the terminal now in 4.2).<br />
<br />
You can also plot the commands stored in the <tt>FLAG_CMD</tt> table:<br />
<source lang="python"><br />
# In CASA<br />
myrows = range(285)<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='table',action='plot',tablerows=myrows)<br />
</source><br />
<br />
Note that we are only plotting the first 285 rows -- this is because the last few are from flagging zeros in the data (caused by correlator errors) and data which have been flagged due to [http://evlaguides.nrao.edu/index.php?title=Observational_Status_Summary#Shadowing_and_Cross-Talk antenna shadowing]. Note that you can not do the <tt>tablerows</tt> selection and plot those too, you will just get lines at the bottom marked as "All" antennas for these flags.<br />
<br />
This will bring up a <tt>matplotlib</tt> plotter. You can have it plot to a PNG file instead:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagcmd(vis='SN2010FZ_10s.ms', inpmode='table', action='plot', tablerows=myrows, <br />
plotfile='PlotSN2010FZ_flagcmd_4.2.png')<br />
</source><br />
<br />
The flags as plotted in the figure to the above right look normal. <br />
They are color-coded by REASON, and you see ANTENNA_NOT_ON_SOURCE flags between scans, and the occasional SUBREFLECTOR_ERROR flag also between scans (most likely after band changes when the subreflector rotates to <br />
pick up the new feed on the ring, some are slower than others). What you watch for here are long blocks of unexpected flags, which might be false alarms and cause you to flag too much data. In that case, look at the data itself in {{plotms}} (see below for examples) to decide whether or not to apply all flags.<br />
<br />
[[Image:plotSN2010FZ_plotants.png|200px|thumb|right|plotants plotter]]<br />
To plot up the antenna positions in the array:<br />
<source lang="python"><br />
# In CASA<br />
plotants('SN2010FZ_10s.ms')<br />
</source><br />
<br />
NOTE: if after this point (or any other) you get "table locks", which may occur erroneously and are sometimes triggered by plotting tasks, use {{clearstat}} to clear them:<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat<br />
</source><br />
<br />
Now we examine the MS looking for bad data to flag. We will use {{plotms}} to bring up an interactive GUI that will display 2-D Y vs.X style line plots. <b>NOTE: We do not recommend using the editing/flagging features of plotms.</b> It is very easy to mess up your data this way. Also, to improve speed we will be restricting the scope of plotting so most box/flag operations would not get rid of all the bad data. <br />
<br />
We will instead use plotms to identify bad data and then use flagcmd to flag it. This will also allow full scripting of the flagging, which is ultimately the best way to keep track of what's been deleted. Given the large dataset sizes now being generated, reproducibility is extremely important. Imaging spending a day flagging your data, then a disk error corrupts the MS. It's imperative that you have an automated way to regenerate your work. This is also why we encourage you to keep a running file with all the commands you use on a dataset.<br />
<br />
NOTE: If you need an introduction to {{plotms}}, see:<br />
* [[Data flagging with plotms]]<br />
* [[Averaging data in plotms]]<br />
* [[What's the difference between Antenna1 and Antenna2? Axis definitions in plotms]]<br />
<br />
WARNING: The '''Flag''' [[Image:FlagThoseData.png]] button on the plotms GUI is close to other buttons you will be using, in particular the one that gets rid of boxes you have drawn. Be careful and don't hit the '''Flag''' button by mistake!<br />
<br />
As we found above, the useful spectral windows are 2-17. To get an idea of the data layout, plot a single baseline (ea01&ea02) and channel (31, for all spectral windows) versus time:<br />
<br />
[[Image:screenshotPlotSN2010FZ_plotms_ants1_4.0.png|200px|thumb|right|plotms ea01&ea02 amp vs time]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='',spw='2~17:31~31', \<br />
antenna='ea01&ea02',correlation='RR,LL',xaxis='time',yaxis='amp')<br />
</source><br />
<br />
Here, we can see the alternating phase calibration and science target scans, as well as the (brighter) flux calibrator at the end of the observation. Feel free to play with ways to view, or color the data: for example, go to the "Display" left-hand tab, and choose "Colorize by: Field". You can also change the size of the plotted points, if they are too small to see easily, by setting "Unflagged Points Symbol" to "Custom" and increasing the number of pixels under "Style".<br />
<br />
[[Image:screenshotPlotSN2010FZ_plotms_ants2_4.0.png|200px|thumb|right|plotms ea01 for field 2 showing amp versus ANTENNA2]]<br />
Look for bad antennas by picking the last field and plotting baselines versus antenna <tt>ea01</tt>:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17:31~31', \<br />
antenna='ea01',correlation='RR,LL',xaxis='antenna2',yaxis='amp')<br />
</source><br />
<br />
You should be able to see that antenna 11 (= ea13) is bad (very low amplitude, it has no C-band receiver!) and that some of the spectral windows on 15 and 23 (ea17, ea25) are also on the low side. Boxing with the '''Mark Regions''' [[Image:MarkRegionsButton.png]] tool and using the '''Locate''' [[File:casaplotms-locate-tool.png]] tool will show in the logger that spw 10-17 are suspect for these antennas. (Note: you may also leave these in for now if you like; if this were truly a first pass through the data it is unlikely that they would be caught. Since this is a tutorial, and there is limited time for a second pass through the data, it's probably best to trust us and delete them now.)<br />
<br />
[[Image:plotSN2010FZ_plotms_ea02.png|200px|thumb|right|plotms field 2 ea02 amp vs frequency]]<br />
Now look at the bandpass for ea02 - it is in the inner core and a prospective reference antenna. Exclude ea13 using negation (represented by "!") in the selection:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17', \<br />
antenna='ea02;!ea13',correlation='RR,LL',xaxis='frequency',yaxis='amp')<br />
</source><br />
There is clearly less data for spw 11, and use of Locate shows spw 11 data only for ea02,ea03,04,08,09,11,12. We will later delete this incomplete spw. Note also the very strong RFI spike at 6614 MHz (spw 10 ch 63) with clear ringing contaminating both spw 10 and 11. There is also a tremendous roll-off in spw 10. We will drop these spectral window when we process the data.<br />
<br />
[[Image:plotSN2010FZ_plotms_ea02ea20.png|200px|thumb|right|plotms ea02 iteration with baseline stopped at ea02&ea20 showing phase vs frequency]]<br />
We can also step through the baselines to our antenna using iteraxis:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02;!ea13', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',iteraxis='baseline')<br />
</source><br />
and use the '''Next Iteration''' [[Image:NextIterationButton.png]] button to step through the baselines.<br />
This will make it easier to isolate the bad antennas. Now plot the phases, iterating through baselines to ea02:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02;!ea13', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',iteraxis='baseline')<br />
</source><br />
You see the slopes due to residual delays. Mostly a turn or less over a 128MHz subband, but there are some outliers.<br />
Step through to ea20. You see that there is a very large delay in RR (via locate) for<br />
the first baseband (spw 0~7). We will delete this (will also delete LL so there are no orphan polarization products, which would be ignored by {{clean}} in the imaging stage).<br />
Note ea17 and ea25 baselines drop close to zero in the middle of upper baseband (e.g. plot 'ea17&ea25') so we will delete these.<br />
<br />
To carry out flagging, we again use {{flagcmd}} in the mode where it takes a list of command strings:<br />
<source lang="python"><br />
# In CASA<br />
flaglist = ['antenna="ea13"',<br />
'antenna="ea17" spw="10~17"',<br />
'antenna="ea25" spw="10~17"',<br />
'antenna="ea20" spw="2~9"']<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='list',inpfile=flaglist,action='apply',flagbackup=True)<br />
</source><br />
These commands will be carried out as well as being added to the FLAG_CMD table (marked as applied).<br />
<br />
Plot the data again, now that is has been flagged:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='',spw='5:30~33',avgchannel='64', \<br />
antenna='ea01&ea02',correlation='RR,LL',xaxis='time',yaxis='amp')<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
<br />
[[Image:plotSN2010FZ_plotms_ea02fld0.png|200px|thumb|right|plotms field 0 ea02 amp vs frequency]]<br />
Now our phase calibrator - it is weaker, and we now start to really see the RFI:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='0',spw='2~17',antenna='ea02', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
Use the Zoom feature, Mark rectangles and use Locate to identify the frequency/channel of RFI. In particular, we note in our analysis:<br />
* 6614MHz (spw 10 ch 63) super strong<br />
* 6772-6778MHz (spw 12 ch 14-17)<br />
* 7260-7264MHz (spw 16 ch 2-4)<br />
* 7314-7340MHz (spw 16 ch 29-42)<br />
* 7402-7418MHz (spw 17 ch 9-17)<br />
* 7458-7466MHz (spw 17 ch 37-41)<br />
* 7488MHz (spw 17 ch 52)<br />
<br />
If you plot all antennas and avoid the band edges you see spw 16 and 17 are pretty wiped out:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='0',spw='2~17:4~59',antenna='', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
<br />
For now we will not flag these spectral windows, but note the bad channels, which we will mask out when creating continuum calibration tables and images.<br />
<br />
Finally, split off the good scans and spw, this will allow us to work on the data without having to start completely over (if we mess something up badly) as well as letting us do simpler data selections. Note that we do not include spw 10, because of the bad RFI, or spw 11, because of the many missing antennas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_flagged10s.ms')<br />
split(vis='SN2010FZ_10s.ms',outputvis='SN2010FZ_flagged10s.ms',datacolumn='data',spw='2~9,12~17',scan='7~43')<br />
</source><br />
<br />
You now have a MS called <tt>SN2010FZ_flagged10s.ms</tt> in your working area. This should be 2.8GB in size, which you can see while still at the CASA command prompt by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('du -sh SN2010FZ_flagged10s.ms')<br />
</source><br />
<br />
Note that the built-in <tt>system</tt> function allows one to execute UNIX shell commands within a CASA session. (Some, like <tt>ls</tt>, don't need this extra wrapper, but most are not automatically understood.)<br />
<br />
[[Image:PlotSN2010FZ_plotms_datastream_zoomed.png|200px|thumb|right|plotms antenna2 vs. time "datastream" plot, zoomed in on last scan]]<br />
At this point it is useful to plot a "datastream" view of the dataset to show what antennas are present at what time. You can do this using<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
This shows the times where data is present on baselines TO a given Antenna2 (which means there is no line for ea01 which is antenna 0). You can pick up ea01 (and drop ea28) by setting <tt>yaxis='antenna1'</tt>. To the right we show this plot, having zoomed in on the last scan on 3C286. You see here that some antennas are present in this scan earlier than others (e.g. ea02 comes in one 10s integration later than ea04).<br />
<br />
== Calibration ==<br />
<br />
Summarize the split flagged MS:<br />
<source lang="python"><br />
# In CASA<br />
listobs('SN2010FZ_flagged10s.ms')<br />
</source><br />
In the logger we see:<br />
<pre><br />
##########################################<br />
##### Begin Task: listobs #####<br />
<br />
================================================================================<br />
MeasurementSet Name: SN2010FZ_flagged10s.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. Alicia M. Soderberg Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 1375038 Total integration time = 3042 seconds<br />
Observed from 11-Jul-2010/21:36:01.0 to 11-Jul-2010/22:26:43.0 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) SpwIds ScanIntent<br />
11-Jul-2010/21:36:01.0 - 21:38:20.5 7 0 J0925+0019 73710 9.93 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
21:38:44.0 - 21:39:51.0 9 1 SN2010FZ 39312 9.16 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:40:01.0 - 21:41:20.5 10 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:41:30.0 - 21:42:50.0 11 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:43:00.0 - 21:44:20.0 12 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:44:30.0 - 21:45:50.0 13 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:46:00.0 - 21:47:19.5 14 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:47:29.0 - 21:47:49.0 15 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:48:12.0 - 21:49:18.5 16 0 J0925+0019 39312 9 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
21:49:42.0 - 21:50:49.0 17 1 SN2010FZ 39312 9.17 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:50:59.0 - 21:52:19.0 18 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:52:29.0 - 21:53:48.5 19 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:53:58.0 - 21:55:18.0 20 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:55:28.0 - 21:56:48.0 21 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:56:58.0 - 21:58:18.0 22 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:58:28.0 - 21:58:47.5 23 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:59:10.5 - 22:00:17.0 24 0 J0925+0019 39312 8.99 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:00:39.5 - 22:01:47.0 25 1 SN2010FZ 39312 9.18 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:01:57.0 - 22:03:17.0 26 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:03:27.0 - 22:04:47.0 27 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:04:57.0 - 22:06:16.5 28 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:06:26.0 - 22:07:46.0 29 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:07:56.0 - 22:09:16.0 30 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:09:26.0 - 22:09:45.5 31 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:10:08.0 - 22:11:15.5 32 0 J0925+0019 39312 9.13 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:11:38.0 - 22:12:45.5 33 1 SN2010FZ 39312 9.19 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:12:55.0 - 22:14:15.0 34 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:14:25.0 - 22:15:45.0 35 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:15:55.0 - 22:17:15.0 36 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:17:25.0 - 22:18:44.5 37 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:18:54.0 - 22:20:14.0 38 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:20:24.0 - 22:20:43.5 39 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:21:06.0 - 22:22:13.5 40 0 J0925+0019 38584 9.15 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:25:13.0 - 22:25:13.0 42 2 3C286 924 2.88 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
22:25:23.0 - 22:26:43.0 43 2 3C286 43148 9.6 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
(nVis = Total number of time/baseline visibilities per scan) <br />
Fields: 3<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 D J0925+0019 09:25:07.81503 +00.19.13.9334 J2000 0 230230 <br />
1 NONE SN2010FZ 09:42:04.77000 +00.19.51.0000 J2000 1 1100736<br />
2 K 3C286 13:31:08.28798 +30.30.32.9589 J2000 2 44072 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (14 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 64 TOPO 4488 2000 128000 RR RL LR LL <br />
1 64 TOPO 4616 2000 128000 RR RL LR LL <br />
2 64 TOPO 4744 2000 128000 RR RL LR LL <br />
3 64 TOPO 4872 2000 128000 RR RL LR LL <br />
4 64 TOPO 5000 2000 128000 RR RL LR LL <br />
5 64 TOPO 5128 2000 128000 RR RL LR LL <br />
6 64 TOPO 5256 2000 128000 RR RL LR LL <br />
7 64 TOPO 5384 2000 128000 RR RL LR LL <br />
8 64 TOPO 6744 2000 128000 RR RL LR LL <br />
9 64 TOPO 6872 2000 128000 RR RL LR LL <br />
10 64 TOPO 7000 2000 128000 RR RL LR LL <br />
11 64 TOPO 7128 2000 128000 RR RL LR LL <br />
12 64 TOPO 7256 2000 128000 RR RL LR LL <br />
13 64 TOPO 7384 2000 128000 RR RL LR LL <br />
<snip><br />
</pre><br />
Note that the spectral windows are re-numbered to 0 through 13.<br />
<br />
=== Setting the flux density scale ===<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#x195-1920004 Synthesis Calibration] in the CASA Cookbook and User Reference Manual .<br />
<br />
Before calibrating, we insert a model for flux calibration source 3C286 into the MS. In order to do this, we first have to locate the model image on our system with {{setjy}}, which we will also use to set the flux density scale. The {{setjy}} task (in release 3.3.0 and later) has an option to list possible model images it knows about:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='SN2010FZ_flagged10s.ms', listmodels=True)<br />
</source><br />
which sends output to your terminal (but not the logger). For example, on an NRAO workstation:<br />
<pre><br />
<br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
The relevant image for our purposes is <tt>3C286_C.im</tt>, in the directory <tt>/usr/lib64/casapy/release/data/nrao/VLA/CalModels</tt>. Your system may show a different location (for example <tt>/home/casa/data/nrao/VLA/CalModels/</tt>, or <tt>/Applications/CASA.app/Contents/data/nrao/VLA/CalModels</tt> on a Mac). Since it knows about this image, we only have to give the image name and not the entire path. Otherwise, you will need to give it the entire path. We now run the task using this model:<br />
<br />
<source lang="python"><br />
# In CASA<br />
mysetjy = setjy(vis='SN2010FZ_flagged10s.ms', field='2', scalebychan=True, model='3C286_C.im', usescratch=False)<br />
</source><br />
<br />
* <tt>scalebychan=True</tt>: will fill the model with per-channel values; otherwise, {{setjy}} would use a single value per spectral window.<br />
* <tt>usescratch=False</tt>: put the model in the header instead of creating scratch columns in the MS. This will take up considerably less disk space.<br />
<br />
We have not specified a Flux Density Scale Standard and are thus using the default (<tt>standard='Perley-Butler 2010'</tt>) as that was current when these observations were taken. In particular, there is a more recent "Perley-Butler 2013" scale that most users will want to use! See <tt>help setjy</tt> for more details.<br />
<br />
Inspecting the logger report shows that 3C286 is about 7.7 Jy at lower end of the band to 5.7 Jy at the upper end.<br />
<br />
Note: With release 4.2 {{setjy}} now returns a dictionary to Python, which we have captured in a variable. This can be used in scripts.<br />
<br />
=== Deriving pre-determined calibrations: antenna position corrections, gain-elevation curves, and requantizer gains ===<br />
<br />
Some calibration products are carried along throughout the calibration process and used as priors for subsequent calibration steps. These include the antenna position corrections, gain-elevation curves, and requantizer gains.<br />
<br />
We use {{gencal}} to determine any antenna-position corrections that need to be applied to the data. This is based on a database of corrections with the time they were determined and when they were applied by the observing system, compared to the times in your observations.<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.antpos',caltype='antpos',antenna='')<br />
</source><br />
You should see in the logger:<br />
<pre style="background-color: #fffacd;"><br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea06 : 0.00220 0.00100 0.00590<br />
offsets for antenna ea10 : 0.00080 0.00300 -0.00140<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.00370 -0.00130 0.00000<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
</pre><br />
Note that there are significant position corrections for a number of the antennas. <br />
<br />
In CASA 4.1 and later, we now have the option to use {{gencal}} to create a calibration table containing the gain curves for the antennas. Although you can still use the <tt>gaincurve=True</tt> option in each task, we will make use of this new feature (note that the <tt>gaincurve=True</tt> will be phased out in future CASA releases):<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.gaincurve',caltype='gc')<br />
</source><br />
<br />
Finally, we will use {{gencal}} to create a calibration table containing corrections for the requantizer gains. Although this is only necessary for 3-bit data (and our SN2010FZ is 8-bit), we include it here for completeness. It will not affect the calibration for our 8-bit data, but if one is following this CASA Guide as a template for 3-bit data, this step is needed to account for the small gain changes (~5-10%) that result from resetting the quantizer gains as the correlator changes to a new 3-bit configuration.<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.requantizer',caltype='rq')<br />
</source><br />
<br />
Since we're running {{gencal}} on 3-bit data, it logs that it found "0 TIME/SPW switched power samples."<br />
<br />
The caltables we have generated -- <tt>calSN2010FZ.antpos</tt>, <tt>calSN2010FZ.gaincurve</tt>, and <tt>calSN2010FZ.requantizer</tt> -- will need to be pre-applied in subsequent calibration steps.<br />
<br />
=== Calibrating delays and bandpass ===<br />
<br />
[[Image:plotSN2010FZ_plotcal_G0p1_4.0.png|200px|thumb|right|plotcal G0 phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G0p2_4.0.png|200px|thumb|right|plotcal G0 phase ant 16~26]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_delays_4.2.png|200px|thumb|right|plotcal K0 delay vs. antenna]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_B0a1_4.0.png|200px|thumb|right|plotcal B0 bandpass amp ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_B0a2_4.0.png|200px|thumb|right|plotcal B0 bandpass amp ant 16~26]]<br />
[[Image:plotSN2010FZ_plotcal_B0p1_4.0.png|200px|thumb|right|plotcal B0 bandpass phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_B0p2_4.0.png|200px|thumb|right|plotcal B0 bandpass phase ant 16~26]]<br />
[[Image:plotSN2010FZ_plotcal_B0ea14_4.0.png|200px|thumb|right|plotcal B0 amp and phase vs. freq for ea14]]<br />
<br />
First, we do a phase-only calibration solution on a narrow range of channels in each spw on the bandpass/flux calibrator 3c286 to flatten them before solving for the bandpass. Note where we saw RFI in the higher spw and avoid those channels. The range 23~28 should work. Pick a refant near center - ea04 is a reasonable bet (see above):<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G0',field='2',spw='0~13:23~28', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve'],\<br />
gaintype='G',refant='ea04',calmode='p',solint='int',minsnr=3) <br />
</source><br />
<br />
* <tt>refant='ea04'</tt> : try to use ea04 as the reference antenna<br />
* <tt>solint='int'</tt> : do a per-integration solve (every 10 seconds, since we've time-averaged the data)<br />
* <tt>minsnr=3</tt> : apply a minimum signal-to-noise cutoff. Solutions with less than this value will be flagged<br />
* <tt>gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve']</tt> : pre-apply the antpos and gaincurve caltables<br />
<br />
Plot the phase solutions (using full phase range, -180 to 180, instead of autorange):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Step through the antenna-based solutions. They look good (and fairly flat over the scans).<br />
<br />
NOTE: When you are done plotting and want to use the caltable in another task, use the Quit button on the GUI to dismiss the plotter and free up the lock on the caltable. You should see a message in your terminal window saying "Resetting plotcal" which means you are good to go!<br />
<br />
If you want to make single-page multipanel plots (like those shown to the right), particularly for a<br />
hardcopy (where it only shows the first page), you can do:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase', \<br />
antenna='0~10,12~15',subplot=531,iteration='antenna', \<br />
plotrange=[-1,-1,-180,180],showgui=False,fontsize=6.0, \<br />
figfile='plotSN2010FZ_plotcal_G0p1.png')<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase', \<br />
antenna='16~26',subplot=531,iteration='antenna', \<br />
plotrange=[-1,-1,-180,180],showgui=False,fontsize=6.0, \<br />
figfile='plotSN2010FZ_plotcal_G0p2.png')<br />
</source><br />
<br />
We can now solve for the residual antenna-based delays that we saw in phase vs. frequency.<br />
This uses the new gaintype='K' option in gaincal. Note that this currently does not do a "global fringe-fitting" solution for delays,<br />
but instead does a baseline-based delay solution to all baselines to the refant, treating these<br />
as antenna-based delays. In most cases with high-enough S/N to get baseline-based delay solutions<br />
this will suffice. We avoid the beginning of spw 0 due to the extreme roll-off (with loss of S/N) at the<br />
starting edge.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.K0',\<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.G0'],\<br />
field='2',spw='0:8~59,1~13:4~59',gaintype='K', \<br />
refant='ea04',combine='scan',solint='inf',minsnr=3)<br />
</source><br />
We pre-apply our initial phase table, and produce a new K-type caltable for input to bandpass calibration.<br />
We can plot the delays, in nanoseconds, as a function of antenna index (you will get one for each subband and polarization):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.K0', xaxis='antenna', yaxis='delay')<br />
</source><br />
<br />
The delays range from around -6 to 6 nanoseconds.<br />
<br />
Now solve for the bandpass using the previous tables:<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.B0', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve', \<br />
'calSN2010FZ.G0','calSN2010FZ.K0'], \<br />
field='2',refant='ea04',solnorm=False, \<br />
bandtype='B', combine='scan', solint='inf')<br />
</source><br />
'''WARNING''': You must set <tt>solnorm=False</tt> here or later on you will find some offsets<br />
between spw due to how amplitude scaling adjusts weights internally during solving.<br />
<br />
You will see in the terminal some reports of solutions failing below our default S/N>3 cutoff:<br />
<pre><br />
32 of 50 solutions flagged due to SNR < 3 in spw=0 (chan=1) at 2010/07/11/22:26:05.4<br />
44 of 50 solutions flagged due to SNR < 3 in spw=0 (chan=0) at 2010/07/11/22:26:05.4<br />
</pre><br />
<br />
These are in the first two edge channels of the first spw where the response is low, and not unexpected. <br />
In the logger you will also see reports of reference antennas jumping in those channels, which can be <br />
be safely ignored (we will drop those channels later anyway).<br />
<br />
This is the first amplitude-scaling calibration that we do, so it is important to have used the <tt>calSN2010FZ.gaincurve</tt> caltable (or set <tt>gaincurve=True</tt>). If we were at higher frequency we would also have made an opacity caltable (or set <tt>opacity</tt>).<br />
<br />
Now plot this, in amplitude then phase:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',iteration='antenna')<br />
#<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
or to plot them all together<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',<br />
antenna='0~10,12~15',subplot=531,iteration='antenna',<br />
fontsize=6.0, figfile='plotSN2010FZ_plotcal_B0a1_4.2.png')<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',<br />
antenna='16~26',subplot=531,iteration='antenna',<br />
fontsize=6.0, figfile='plotSN2010FZ_plotcal_B0a2_4.2.png')<br />
#<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',<br />
antenna='0~10,12~15',subplot=531,iteration='antenna',<br />
plotrange=[-1,-1,-180,180],fontsize=6.0, <br />
figfile='plotSN2010FZ_plotcal_B0p1_4.2.png')<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',<br />
antenna='16~26',subplot=531,iteration='antenna',<br />
plotrange=[-1,-1,-180,180],fontsize=6.0, <br />
figfile='plotSN2010FZ_plotcal_B0p2_4.2.png')<br />
</source><br />
(this can take a long time to plot).<br />
<br />
In the bandpass phase you no longer see the residual antenna delays (just residual spw phase offsets from <br />
the delay solution registration) but there are some band edge effects.<br />
Note that some antennas have a little strange bandpasses at upper end of lower baseband in spw 5,6,7<br />
(e.g. ea14,ea16,ea17,ea25).<br />
To plot amp and phase for a single antenna versus frequency (see plots at right):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp', \<br />
antenna='ea14',subplot=211)<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase', \<br />
antenna='ea14',subplot=212,plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Because our flux density calibrator 3C286 is bright enough, we were able to use this as the bandpass calibrator.<br />
Since {{setjy}} put the correct spectrum for 3C286 into the MODEL_DATA column, our bandpass will reflect the<br />
true bandpass of the instrument. However, if for your observation you were unable to use a source of known spectrum <br />
as the bandpass calibrator, then you would need to use the output of {{fluxscale}} later on to bootstrap a {{setjy}} <br />
on your bandpass source using the derived spectral index information.<br />
<br />
=== Final phase and amplitude calibration ===<br />
<br />
[[Image:plotSN2010FZ_plotcal_G1intp1_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G1intp2_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 16~26]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_G1intp_ea01_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G1infp_ea01_4.0.png|200px|thumb|right|plotcal G1inf per-scan phase ant 0~15]]<br />
<br />
Now calibrate phases using the full bandwidth. <br />
First both our calibrators, one at a time - we could do them together, but in general you might need<br />
to do different solution intervals for each, so we keep the runs separate to illustrate how to <br />
do separate solutions and append them.<br />
We exclude RFI channels here, and obtain one solution per integration (these are bright enough):<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1int', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='2',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='int',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1int', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='int',gaintype='G',calmode='p',append=True)<br />
</source><br />
These will get applied when solving for amplitudes, and when calibrating the calibrators themselves.<br />
<br />
The phases look reasonably connected:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G1int',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
To apply phase calibration to the target, we make a second table with one solution on our gain calibrator per scan:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1inf',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',gaintype='G',calmode='p')<br />
</source><br />
These scan phases will get interpolated by {{applycal}} onto our target. These look good also:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G1inf',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Now solve for amplitudes on a per scan interval, after applying the per-integration phases. <br />
Do these separately using <tt>gainfield</tt> so phases don't get<br />
transferred across fields. For field 2 (3C286) we use <tt>combine='scan'</tt> as there are two scans <br />
on this source, with the first one having much less data (and will thus give a noisy solution on its own).<br />
Note that {{gaincal}} uses linear interpolation of the previously determined phases by default, so <br />
set this to "nearest" if you want to override this.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'], \<br />
gainfield=['','','2','2','2'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='2',refant='ea04',solnorm=F,<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'],\<br />
gainfield=['','','2','2','0'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',gaintype='G',calmode='a',append=True)<br />
</source><br />
This is the table we will apply to the data.<br />
<br />
[[Image:plotSN2010FZ_plotcal_G2infa1_4.0.png|200px|thumb|right|plotcal G2 per-scan amp ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G2infa2_4.0.png|200px|thumb|right|plotcal G2 per-scan amp ant 16~26]]<br />
<br />
We do a second version of the amplitude calibration, this time using <tt>combine='scan'</tt> on field 0. This is <br />
to use for input to {{fluxscale}} in the next step.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G3', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'], \<br />
gainfield=['','','2','2','2'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='2',refant='ea04',solnorm=F,<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G3', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'],\<br />
gainfield=['','','2','2','0'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a',append=True)<br />
</source><br />
<br />
Since the flux on the gain calibrator is not scaled to its correct flux (but to 1.0 Jy by default),<br />
use {{fluxscale}} to transfer the amplitude gains from 3c286:<br />
<source lang="python"><br />
# In CASA<br />
myflux = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G3', \<br />
fluxtable='calSN2010FZ.F3inc',reference='2',transfer='0',<br />
incremental=True)<br />
</source><br />
where we have captured the returned dictionary in the Python variable <tt>myflux</tt>. We have use the<br />
<tt>incremental=True</tt> option (new to CASA 4.0) to make this table contain only the scale factors <br />
per-antenna per-spw per-field needed to scale the data (rather than rescaling the input table). Thus it<br />
can be applied in addition to our <tt>G2</tt> table even though it was derived from the <tt>G3</tt> table.<br />
<br />
The logger output gives:<br />
<pre><br />
Found reference field(s): 3C286<br />
Found transfer field(s): J0925+0019<br />
Flux density for J0925+0019 in SpW=0 (freq=4.488e+09 Hz) is: 0.977483 +/- 0.00278572 (SNR = 350.891, N = 50)<br />
Flux density for J0925+0019 in SpW=1 (freq=4.616e+09 Hz) is: 0.975972 +/- 0.00253876 (SNR = 384.429, N = 50)<br />
Flux density for J0925+0019 in SpW=2 (freq=4.744e+09 Hz) is: 0.978538 +/- 0.00242824 (SNR = 402.982, N = 50)<br />
Flux density for J0925+0019 in SpW=3 (freq=4.872e+09 Hz) is: 0.979278 +/- 0.00244155 (SNR = 401.088, N = 50)<br />
Flux density for J0925+0019 in SpW=4 (freq=5e+09 Hz) is: 0.981804 +/- 0.00219239 (SNR = 447.823, N = 50)<br />
Flux density for J0925+0019 in SpW=5 (freq=5.128e+09 Hz) is: 0.981478 +/- 0.00314805 (SNR = 311.773, N = 50)<br />
Flux density for J0925+0019 in SpW=6 (freq=5.256e+09 Hz) is: 0.985493 +/- 0.00343534 (SNR = 286.869, N = 50)<br />
Flux density for J0925+0019 in SpW=7 (freq=5.384e+09 Hz) is: 0.978491 +/- 0.00201807 (SNR = 484.865, N = 50)<br />
Flux density for J0925+0019 in SpW=8 (freq=6.744e+09 Hz) is: 0.959005 +/- 0.00260159 (SNR = 368.623, N = 48)<br />
Flux density for J0925+0019 in SpW=9 (freq=6.872e+09 Hz) is: 0.955123 +/- 0.00262785 (SNR = 363.462, N = 48)<br />
Flux density for J0925+0019 in SpW=10 (freq=7e+09 Hz) is: 0.954202 +/- 0.00281227 (SNR = 339.3, N = 48)<br />
Flux density for J0925+0019 in SpW=11 (freq=7.128e+09 Hz) is: 0.950797 +/- 0.00354085 (SNR = 268.522, N = 48)<br />
Flux density for J0925+0019 in SpW=12 (freq=7.256e+09 Hz) is: 0.94732 +/- 0.00391511 (SNR = 241.965, N = 48)<br />
Flux density for J0925+0019 in SpW=13 (freq=7.384e+09 Hz) is: 0.939356 +/- 0.00383532 (SNR = 244.922, N = 48)<br />
Fitted spectrum for J0925+0019 with fitorder=1: Flux density = 0.968048 +/- 0.00159415 (freq=5.74863 GHz) <br />
spidx=-0.0721976 +/- 0.00943577<br />
...<br />
</pre><br />
You may see slightly different numbers on your machine (and will see more extensive output). Note that "N" here is the number of antennas x the number of polarizations used for the calculations; in this case, there are 24 unflagged antennas and 2 polarizations. As of CASA 4.0, {{fluxscale}} now returns a fitted spectral index (and possibly curvature, e.g. if fitorder>1), which can be input to {{setjy}} if you want to use these derived fluxes for a model. <br />
<br />
As it so happens, the derived flux for J0925+0019 is about 1 Jy (you can plot up the raw amplitudes for fields 0,2 and convince yourself this is indeed true and not a bug). The spectrum rises a bit to peak in spw 6 then falls again. We will not use the fitted spectrum (setjy does not yet take fitorder>1) but will apply a incremental table in subsequent processing.<br />
<br />
== Applying the Calibration and Final Editing ==<br />
<br />
Next we actually apply all our accumulated calibration tables. We apply these to the <br />
calibration fields individually using the appropriate gainfields and interpolation for each:<br />
* For 3C286 (field 2) we did short-timescale phase solutions and a single scan amplitude, so use "linear" and "nearest" interpolation respectively.<br />
* For the nearby gain calibrator (field 0) we did only scan-based phase and amplitude solutions so we use "nearest" interpolation<br />
* For the target source we use field 0 to calibrate field 1, so use "linear" interpolation. This takes a few minutes.<br />
<br />
[[Image:plotSN2010FZ_plotms_applied_fld2.png|200px|thumb|right|plotms of 3C286 with calibration applied]]<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1int','calSN2010FZ.G2'], \<br />
gainfield=['','','','','2','2'],<br />
interp=['','','nearest','nearest','nearest','nearest'], \<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1int','calSN2010FZ.G2',<br />
'calSN2010FZ.F3inc'], \<br />
gainfield=['','','','','0','0','0'],<br />
interp=['','','nearest','nearest','nearest','nearest',''], \<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1inf','calSN2010FZ.G2',<br />
'calSN2010FZ.F3inc'], \<br />
gainfield=['','','','','0','0','0'],<br />
interp=['','','nearest','nearest','linear','linear',''], \<br />
parang=False,calwt=False)<br />
</source><br />
Because we used <tt>usesratch=False</tt> in {{setjy}}, the <tt>CORRECTED_DATA</tt> scratch column will be created the first time you run {{applycal}}. This will store the calibrated data.<br />
<br />
We can examine the corrected data on 3c286 using our RFI mask from above and avoiding band edges<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
See figure above right. There is clearly discrepant data visible spw 5 and 6, in particular for baseline ea17&ea25 (use the '''Mark Regions''' [[Image:MarkRegionsButton.png]] tool on some of it and then use the '''Locate''' [[File:casaplotms-locate-tool.png]] tool), which gives a really strange response. You can plot just this baseline to be sure:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='ea17&ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
You can exclude this through antenna negation:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='!ea17&ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Then use '''Locate''' [[File:casaplotms-locate-tool.png]] for the other bad points, which seem to indicate spw 5,6,7 for ea14,ea16,ea17,ea25.<br />
Exclude these and replot:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='!ea14;!ea16;!ea17;!ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld2.png|200px|thumb|right|plotms cal applied flagged fld2]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld2_phase.png|200px|thumb|right|plotms cal applied flagged fld2 phase]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_amp.png|200px|thumb|right|plotms cal applied flagged fld0 amp]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_phase.png|200px|thumb|right|plotms cal applied flagged fld0 phase]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_amp_exc_4.0.png|200px|thumb|right|plotms cal applied flagged fld0 amp, with new spw selection]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_ampavg_4.0.png|200px|thumb|right|plotms cal applied flagged fld0 amp averaged]]<br />
<br />
This now looks clean except for the RFI in the upper subbands.<br />
<br />
Do flagging based on these:<br />
<source lang="python"><br />
# In CASA<br />
flaglist2 = ['antenna="ea14,ea16,ea17,ea25" spw="5~7"']<br />
flagcmd(vis='SN2010FZ_flagged10s.ms',inpmode='list',inpfile=flaglist2,action='apply')<br />
</source><br />
<br />
Now replot the corrected data (you may have to force reload if you plotted same thing right before this):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Looks pretty good.<br />
<br />
Plot the phase:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
Note the characteristic "bowtie" pattern of the phases about the sub-band centers.<br />
Here we can see the effect of the EVLA "delay clunking", where the delay steps through discrete values such that<br />
the phase goes from -11deg to +11deg across the sub-band as the delay changes due to geometry. This is D-configuration so the delays change slowly, it will change faster in wider configurations. As of Q3 2011 we have not enabled the corrections for this in the EVLA system so you will always have this remaining delay error in your data. In principle, you could solve for delays on short timescales and take this out; in practice, this in not possible for your weaker science target source (where it would matter most for results).<br />
<br />
Now let's plot the corrected data amplitude for the phase calibrator (field 0):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
You can see the bandpass filter roll-off increasing the noise at the baseband edges (about 8-16 channels worth). Also, we can see some RFI we missed:<br />
* <6804 MHz spw 8 below ch 30 lots of bad stuff (a lot from ea18,ea22 but others too)<br />
* 7168 MHz spw 11 ch 20<br />
* pretty much all of spw 12,13<br />
The ch 20 ones are all harmonics of a notorious 128 MHz tone. NOTE: You can get the frequency of a RFI feature by looking at the logger report from using the '''Locate''' [[File:casaplotms-locate-tool.png]] tool.<br />
<br />
We will not flag these, but exclude them in imaging (so that more advanced students can try flagging these in detail or using auto-flagging). A good channel selection string for imaging might be:<br />
<br />
<pre><br />
spw = '0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59'<br />
</pre><br />
<br />
Without further flagging, it may be best to drop spw 12-13 for imaging (we will do so from now on).<br />
<br />
Plot again (including this selection for spw 0-11):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Looks better.<br />
<br />
Now plot amplitudes for the corrected data averaged over baseline to see the source spectrum:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0',<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59',<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
The "custom" plotting parameters show how to control the symbol shape and size from the task.<br />
<br />
The last two sub-bands spw 12-13 give reasonable values, with only a tiny offset from spw 8-11.<br />
There are also strange amplitude excursions, particularly in the low end of the first baseband. These must be coming<br />
from one or more scans. You can iterate over scan to see the strange amplitudes (mostly from scan 7):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0',<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59',<br />
correlation='RR,LL',avgbaseline=True,avgtime='600s',iteraxis='scan',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
<br />
Also, there is an offset with the amplitudes for spw 6, perhaps due to the problem with baseline ea17&ea25 (which we flagged, but didn't recalibrate afterward) and likely affected the {{fluxscale}} solution. This is troubling enough that we will quickly go through a second round of calibration.<br />
<br />
== A Quick Recalibration ==<br />
<br />
We now go back and recalibrate the data. We may as well flag scan 7 first, as well:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='SN2010FZ_flagged10s.ms', scan='7')<br />
#<br />
# Clear the corrected data and model from header<br />
clearcal('SN2010FZ_flagged10s.ms',addmodel=False)<br />
#<br />
chanStr = '0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59'<br />
#<br />
mysetjy2 = setjy(vis='SN2010FZ_flagged10s.ms', field='2', scalebychan=True, modimage='3C286_C.im')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G0.2',field='2',spw='0~11:23~28',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve'],<br />
gaintype='G',refant='ea04',calmode='p',solint='int',minsnr=3)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.K0.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.G0.2'],<br />
field='2', spw=chanStr, gaintype='K',<br />
refant='ea04', combine='scan', solint='inf', minsnr=3)<br />
#<br />
bandpass(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.B0.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.G0.2','calSN2010FZ.K0.2'],<br />
field='2',refant='ea04',solnorm=False,<br />
spw='0~11', <br />
bandtype='B', combine='scan', solint='inf')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2int',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='2',refant='ea04',solnorm=F, <br />
spw=chanStr,<br />
solint='int',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2int',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='int',gaintype='G',calmode='p',append=True)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2inf',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','2'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='2',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','0'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',gaintype='G',calmode='a',append=True)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.3',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','2'],<br />
interp=['','','nearest','nearest','nearest'],<br />
field='2',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.3',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','0'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a',append=True)<br />
#<br />
myflux2 = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G2.3',<br />
fluxtable='calSN2010FZ.F2.3inc',reference='2',transfer='0',<br />
incremental=True)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='2',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2'],<br />
gainfield=['','','','','2','2'],<br />
interp=['','','nearest','nearest','linear','nearest'],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3inc'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','nearest','nearest',''],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2inf','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3inc'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','linear','linear',''],<br />
parang=False,calwt=False)<br />
</source><br />
<br />
Note that we have set the variable <tt>chanStr</tt> for our channel selection; this makes the task commands shorter and easier to read.<br />
<br />
The {{fluxscale}} output this time around is slightly different to the last:<br />
<pre><br />
Found reference field(s): 3C286<br />
Found transfer field(s): J0925+0019<br />
Flux density for J0925+0019 in SpW=0 (freq=4.488e+09 Hz) is: 0.978946 +/- 0.00284837 (SNR = 343.686, N = 50)<br />
Flux density for J0925+0019 in SpW=1 (freq=4.616e+09 Hz) is: 0.978634 +/- 0.00264066 (SNR = 370.602, N = 50)<br />
Flux density for J0925+0019 in SpW=2 (freq=4.744e+09 Hz) is: 0.980438 +/- 0.00251668 (SNR = 389.575, N = 50)<br />
Flux density for J0925+0019 in SpW=3 (freq=4.872e+09 Hz) is: 0.980116 +/- 0.00255481 (SNR = 383.636, N = 50)<br />
Flux density for J0925+0019 in SpW=4 (freq=5e+09 Hz) is: 0.982175 +/- 0.00230804 (SNR = 425.545, N = 50)<br />
Flux density for J0925+0019 in SpW=5 (freq=5.128e+09 Hz) is: 0.979574 +/- 0.00269688 (SNR = 363.225, N = 42)<br />
Flux density for J0925+0019 in SpW=6 (freq=5.256e+09 Hz) is: 0.980193 +/- 0.00271312 (SNR = 361.279, N = 42)<br />
Flux density for J0925+0019 in SpW=7 (freq=5.384e+09 Hz) is: 0.98102 +/- 0.00249166 (SNR = 393.721, N = 42)<br />
Flux density for J0925+0019 in SpW=8 (freq=6.744e+09 Hz) is: 0.962693 +/- 0.00282815 (SNR = 340.397, N = 48)<br />
Flux density for J0925+0019 in SpW=9 (freq=6.872e+09 Hz) is: 0.960313 +/- 0.00285418 (SNR = 336.459, N = 48)<br />
Flux density for J0925+0019 in SpW=10 (freq=7e+09 Hz) is: 0.957056 +/- 0.00303716 (SNR = 315.116, N = 48)<br />
Flux density for J0925+0019 in SpW=11 (freq=7.128e+09 Hz) is: 0.953964 +/- 0.00378326 (SNR = 252.154, N = 48)<br />
Flux density for J0925+0019 in SpW=12 is: INSUFFICIENT DATA <br />
Flux density for J0925+0019 in SpW=13 is: INSUFFICIENT DATA <br />
Fitted spectrum for J0925+0019 with fitorder=1: Flux density = 0.973376 +/- 0.00118872 (freq=5.52174 GHz) <br />
spidx=-0.0573991 +/- 0.00778736201<br />
</pre><br />
<br />
The source spectrum plot now looks somewhat better:<br />
<br />
[[Image:plotSN2010FZ_plotms_reproc_fld0_ampavg_4.0.png|200px|thumb|right|plotms recalibrated applied flagged fld0 amp averaged]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
As you see in the figure to the right, there are still spectral window to window variations that deviate from a smooth spectrum. This is due to noise in the {{fluxscale}} median filter now used in CASA 4.0 (in this well-calibrated case, the old weighted means used by {{fluxscale}} in CASA3.4 behaved better). If we use {{plotcal}} to plot the solutions versus antenna<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G2.3',xaxis='antenna',yaxis='amp',field='0',<br />
subplot=211,plotrange=[-1,-1,0.9,1.1])<br />
plotcal(caltable='calSN2010FZ.G2.3',xaxis='antenna',yaxis='amp',field='2',<br />
subplot=212,plotrange=[-1,-1,0.9,1.1],figfile='plotSN2010FZ_plotcal_G2.3_ampant.png')<br />
</source><br />
we see that there are variations that will enter into the medians. Some antennas are better behaved than others, for example ea12 (index 10) seems better than most.<br />
<br />
[[Image:plotSN2010FZ_plotcal_G2.3_ampant.png|200px|thumb|right|plotcal of G2.3 table, showing variation of solutions per antenna]]<br />
[[Image:screenshotPlotSN2010FZ_plotcal_fluxedit3_ea12.png|200px|thumb|right|plotcal of G2.3.ea12 table, marking all solutions but those for ea12 for flagging]]<br />
[[Image:screenshotPlotSN2010FZ_plotms_recalibrated3_EA12_fld0_amp_4.0.png|200px|thumb|right|plotms for fld 0 after application of F2.3.ea12 table]]<br />
Because we are applying an incremental correction for the flux scale, we have the latitude to change the caltable that goes into {{fluxscale}} to get a better result. For example, we can restrict the antennas that are used to derive the scale. Although there is not yet antenna selection in {{fluxscale}} itself, we can edit the caltable using {{plotcal}}. For example, make a copy of the G2.3 caltable and select only a single antenna:<br />
<source lang="python"><br />
# In CASA<br />
os.system('cp -rf calSN2010FZ.G2.3 calSN2010FZ.G2.3.ea12')<br />
plotcal(caltable='calSN2010FZ.G2.3.ea12',xaxis='antenna',yaxis='amp')<br />
</source><br />
In the plot to the right we show the GUI where we have boxed all but antenna ea12.<br />
Now we carry on with the {{fluxscale}} and {{applycal}}:<br />
<source lang="python"><br />
# In CASA<br />
myfluxEdit3 = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G2.3.ea12',<br />
fluxtable='calSN2010FZ.F2.3.ea12',reference='2',transfer='0',<br />
incremental=True)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3.ea12'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','nearest','nearest',''],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2inf','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3.ea12'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','linear','linear',''],<br />
parang=False,calwt=False)<br />
</source><br />
The results appear better:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
Note that if you choose a different antenna than ea12 to use for this, you will get<br />
different results, usually worse. But this procedure illustrates how to use the<br />
incremental solutions from {{fluxscale}} to your possible advantage.<br />
<br />
We now return to examining our calibration.<br />
<br />
We can also plot the corrected phase - looks good:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
<br />
We can average over baseline and each scan:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='600s',<br />
xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_phaseavg.png|200px|thumb|right|plotms cal applied flagged fld0 phase averaged]]<br />
<br />
In this case, we can see the residual effect of the EVLA "delay clunking" described above, but it is reduced due to the averaging that we applied, but it is still there.<br />
<br />
You can look at the target source field='1', but there are lots of data so you will need to do a lot of averaging.<br />
For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='1',avgtime='300s', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Alas, the upper baseband still has lots of low level RFI.<br />
<br />
Now split off the data for calibrators and target, to avoid later issues that can corrupt the MSs. We don't keep spw 12-15, since they weren't included in the last round of calibration, and we don't plan to image them.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_split10s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_split10s.ms', \<br />
datacolumn='corrected',field='1',spw='0~11')<br />
#<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_3c28610s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_3c28610s.ms', \<br />
datacolumn='corrected',field='2',spw='0~11')<br />
#<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_J092510s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_J092510s.ms', \<br />
datacolumn='corrected',field='0',spw='0~11')<br />
</source><br />
<br />
== Imaging ==<br />
<br />
This is EVLA D-configuration data at C-band. To determine the best parameters for imaging, it helps to start with the relevant information in the [http://evlaguides.nrao.edu/index.php?title=Observational_Status_Summary_-_Current Observational Status Summary]:<br />
<br />
* Synthesized beam should be 12" at 6 GHz with primary beam field of view of 7.5 arcmin (450")<br />
<br />
Our data spans 4.5-7.5 GHz: this is a relatively large fractional bandwidth, resulting in substantial variation of the field of view over the entire frequency range. FOV = 45 arcmin / Frequency (GHz), giving 10 arcmin at 4.5 GHz, and 6 arcmin at 7.5 GHz. Likewise, the synthesized beam ranges from 16" at 4.5 GHz to 9.6" at 7.5 GHz. We want to subsample the synthesized beam by a factor of 3-4, so will use a cellsize of 3". To cover the full FOV (keeping it at the inner part of the image) at the lowest frequencies, we will want an image size of >400 pixels, or >20 arcmin.<br />
<br />
We will also use the Briggs robust (with <tt>robust=0.5</tt>) weighting, which is a compromise between uniform and natural weighting,<br />
and will give reasonable resolution but will allow us to still see larger scale structure.<br />
<br />
Due to the numerology of [http://www.fftw.org/ FFTW's] (which {{clean}} uses under the hood for FFTs) optimal sizes, <br />
<tt>imsize</tt> should be composite number with two and only two prime factors chosen from<br />
2, 3, and 5. Taking into account the x1.2 padding that clean uses internally to the imsize<br />
you give it (and 1.2 = 2*3/5), we choose 640 or 1280 as our imsize (640 = 2^7*5). Other<br />
reasonable sets would be 405, 1215, etc. (405 = 3^4*5) or 432, 648, 1296 (these are 2^n*3^m*5).<br />
In practice, if you give it non-optimal values for imsize, you may find that the transforms<br />
take a bit longer, which is noticeable if you are doing interactive clean.<br />
<br />
WARNING: By default, a single-field nterms=1 clean does NOT use Cotton-Schwab (CS) clean to break<br />
into major cycles going back to data residuals, it just does cleaning in a bunch of minor<br />
cycles in the image plane. This can give much poorer imaging quality in cases with poor<br />
uv coverage (snapshots) or in the case of complex emission structure (like ours) -- clean tends to<br />
diverge in this case. You should explicitly set <tt>imagermode='csclean'</tt> in your<br />
call to clean. Also, in our case the psf is very good using mfs, so by default it will not<br />
take many major cycle breaks. We use the <tt>cyclefactor</tt> parameter to control this, which<br />
sets the break threshold to be cyclefactor times the max psf sidelobe level (outside the main<br />
peak). We start at <tt>cyclefactor=1.5</tt> in a single spw, and ratchet it up to 4.5 when we<br />
clean all the spw. This seems to work ok. Rule of thumb is if it is gobbling up many hundreds of<br />
clean iterations in the minor cycles early on, increase cyclefactor. Conversely, if your psf is poor<br />
but you source structure is simple, you can reduce cyclefactor (e.g. below 1) to stop it from taking<br />
lots of extra major cycles.<br />
<br />
For more information on using {{clean}}, in particular on using the interactive GUI, see<br />
[[EVLA_Continuum_Tutorial_3C391_CASA_4.2#Initial Imaging]]. WARNING: In CASA 4.0 the GUI interface for clean <br />
and the viewer has changed slightly. Some of the screenshots shown below may differ slightly <br />
from what you see.<br />
<br />
NOTE: If you are pressed for time, then you might want to jump ahead to<br />
[[EVLA_6cmWideband_Tutorial_SN2010FZ_CASA_4.2#Cleaning_the_lower_baseband_using_two_MFS_Taylor_terms]] <br />
and while it is cleaning you can read the other Imaging descriptions.<br />
<br />
=== Cleaning a single spectral window ===<br />
<br />
Let us start by interactively cleaning one of the lower baseband spw (spw 5 in this example).<br />
NOTE: this first time will take a few minutes at start to create scratch columns<br />
in the MS in case we want to do self-calibration later.<br />
<br />
'''Note that interrupting {{clean}} by Ctrl+C may corrupt your visibilities -- you may be better off choosing to let {{clean}} finish. We are currently implementing a command that will nicely exit to prevent this from happening, but for the moment try to avoid Ctrl+C.'''<br />
<br />
[[Image:viewSN2010FZ_spw5_clean640_4.0.png|200px|thumb|right|interactive clean spw5 640x640 after around 1000 iterations]]<br />
[[Image:viewSN2010FZ_spw5_clean1280.png|200px|thumb|right|2nd interactive clean spw5 1280x1280 before cleaning]]<br />
[[Image:viewSN2010FZ_spw5_clean1280final_4.0.png|200px|thumb|right|viewer showing clean spw5 1280x1280 restored image]]<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw5_clean640*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='5:4~59', \<br />
imagename='imgSN2010FZ10s_spw5_clean640', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[640,640],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
* Start carefully by boxing the bright source and setting iterations to 10 at first<br />
* Gradually add more boxes and increase the number of iterations<br />
* Since this is not much more than a snapshot you see the six-fold sidelobe pattern<br />
of the extended emission in the center of the map. This decreases as you clean<br />
out this emission.<br />
* Stop cleaning when the residuals look like noise (and you cannot clearly see sources).<br />
* To stop, click the red [[File:clean-stop.png]] button.<br />
<br />
The top figure to the right shows a zoom in on the end state of the clean, where<br />
we have marked a number of boxes and cleaned them out.<br />
<br />
Note that there are some strange sidelobe patterns in lower left, possibly <br />
from a source outside the image area. We can make a bigger image starting from<br />
our current model:<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw5_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='5:4~59', \<br />
imagename='imgSN2010FZ10s_spw5_clean1280', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
modelimage='imgSN2010FZ10s_spw5_clean640.model', \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
Sure enough, there is a bright source near the lower left (see middle panel at right). <br />
Box it, clean it a bit, and look again. There is a second source in the mid-left (track<br />
it down by its sidelobes). Box this one, clean it a bit, and when satisfied stop.<br />
<br />
You can use the CASA {{viewer}} to display the images that {{clean}} creates. If you need more guidance<br />
on using the viewer, see the [http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html CASA Viewer Demo] video<br />
(note that this is for a much earlier version of the viewer, and the interface has changed since then). <br />
<br />
Bring up your restored image directly:<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw5_clean1280.image')<br />
</source><br />
<br />
The restored image is shown in the bottom panel to the right. I have chosen the Grayscale1 instead of default color<br />
map as I prefer "Grayscale" to false color "Rainbow" for assessing image quality. Also, you can change the scaling of the image using the "scaling power cycles" slider under "basic settings".<br />
<br />
Check the rms of the residuals using the {{imstat}} task:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw5_clean1280.residual')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
In this particular case, it's 31.8 uJy; yours will likely be slightly different.<br />
<br />
=== Cleaning the lower baseband ===<br />
<br />
[[Image:viewSN2010FZ_spw0to7_clean1280final.png|200px|thumb|right|clean spw0-7 restored image center]]<br />
Now, image the entire lower baseband (spw 0-7).<br />
Follow same iterative procedure as before, and get the best<br />
residuals you can without "cleaning the noise". <br />
<br />
* Because of the bandwidth and frequency synthesis, the sidelobe pattern is different than before and it is much easier to see fainter emission.<br />
* Be careful cleaning sources that lie near or on sidelobe splotches.<br />
* Clean the central emission region way down first to reduce the sidelobe level before adding components in the sidelobe areas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to7_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='0:16~59,1~6:4~59,7:4~54', \<br />
imagename='imgSN2010FZ10s_spw0to7_clean1280', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to7_clean1280.residual')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this run, the rms is 11.3 uJy (and there is clearly some structure left in the residual). To the right is a zoom-in on the center of the restored image.<br />
<br />
==== Cleaning the lower baseband using two MFS Taylor terms ====<br />
<br />
The mfs nterms=2 option creates two "Taylor Term" images - an average intensity image (with suffix <tt>.image.tt0</tt>) <br />
and a spectral slope image (with suffix <tt>.image.tt1</tt>) which is intensity x alpha (where alpha is spectral index).<br />
For convenience there is a spectral index image (with suffix <tt>.image.alpha</tt>). These Taylor expansions are with respect to the "Reference Frequency" of the image (by default the center frequency of the spw selected, but can be specified using the <tt>reffreq</tt> parameter in {{clean}}). The convention for spectral index alpha is that<br />
<br />
<math><br />
S \propto \nu^\alpha<br />
</math><br />
<br />
so negative spectral indexes indicate a "steep" spectrum (falling with frequency).<br />
<br />
[[Image:viewSN2010FZ_spw0to7_mfs2clean.png|200px|thumb|right|clean spw0-7 mfs nterms=2 in progress]]<br />
Let's try using multi-frequency synthesis with nterms=2 on the lower baseband.<br />
The dirty beam will have lower sidelobes so we turn up <tt>cyclefactor</tt> for <tt>csclean</tt> a bit. Note: if you're feeling a bit lazy, and trust your previous set of clean boxes, you can also set <tt>mask='imgSN2010FZ10s_spw0to7_clean1280.mask'</tt> to use these as a starting point:<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to7_mfs2_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='0:16~59,1~6:4~59,7:4~54', \<br />
imagename='imgSN2010FZ10s_spw0to7_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
weighting='briggs',robust=0.5,interactive=True,mask=[])<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to7_mfs2_clean1280.residual.tt0')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this run, the rms is 10.5 uJy (somewhat better-looking than the nterms=1).<br />
The top screenshot to the right shows an intermediate but early stage of cleaning where we are looking at<br />
the central emission and cleaning it out slowly.<br />
<br />
You can use the {{viewer}} to load the average intensity image:<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0')<br />
</source><br />
<br />
and then use the Open Data panel to load the spectral index image <tt>imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha</tt><br />
which can then be blinked (optionally plotted side-by-side using the Panel Display Options panel to set 2 panels in the x direction). <br />
<br />
[[Image:viewSN2010FZ_spw0to7_mfs2loadalpha_4.0.png|200px|thumb|right|clean spw0-7 mfs nterms=2 load alpha with LEL]]<br />
[[Image:viewSN2010FZ_spw0to7_mfs2panelalpha_4.0.png|200px|thumb|right|clean spw0-7 mfs nterms=2 tt0 and alpha (filtered at 0.1mJy in tt0)]]<br />
<br />
Note there is a lot of noise in alpha in the low-intensity regions, and thus filtering the alpha image based on the values in the tt0 image is desirable. You can use the {{immath}} task to make this filtered alpha image explicitly, using a <br />
Lattice Expression Language (LEL) expression: <br />
<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename=['imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha', <br />
'imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM1>1.0E-4]',<br />
outfile='imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha.filtered')<br />
</source><br />
<br />
This will use 0.1 mJy (or 10 x the sigma we found) as the cutoff.<br />
You can then view or manipulate the filtered alpha image as normal.<br />
<br />
We can also use LEL to filter the alpha image on the intensity on-the-fly when we load this raster in the Open Data panel<br />
by specifying a LEL string in the LEL box instead of selecting the image from the directory <br />
listing. The LEL string:<br />
<br />
<pre><br />
'imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha'['imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0'>1.0E-04]<br />
</pre><br />
<br />
will replicate what we did above. The middle figure to the right shows the Open Data panel<br />
with our LEL string in it. Just click the Raster button to load this.<br />
<br />
The lower panel to the right shows the intensity and LEL-filtered alpha images side-by-side in the viewer, zoomed<br />
in on the galaxy emission. Mousing over the alpha shows spectral indexes ranging from -1 to +1 in the center, with<br />
the brightest emission with alpha -0.7 in the knots in the disk.<br />
<br />
=== Cleaning using both basebands combined ===<br />
<br />
For the ultimate image, use the "clean" part of the upper baseband in addition<br />
to the lower (use spw 0-11). We will use mfs with nterms=2 (if you try nterms=1 <br />
on this wide bandwidth you will get much poorer residuals). Because of the added<br />
work and extra data involved, this will take much longer than our other runs of<br />
clean. Therefore, we will get a head start by doing a non-interactive clean using<br />
the mask left from the previous clean (spw 0-7). We will insert a clean threshold<br />
to limit runaway cleaning too far beneath the noise level. <br />
<br />
This will take a while, especially if there are other processes running on your machine (with nothing else running, expect ~30-40 minutes).<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
imagename='imgSN2010FZ10s_spw0to11_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=3000,gain=0.1,threshold='0.002mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
mask=['imgSN2010FZ10s_spw0to7_mfs2_clean1280.mask'], \<br />
weighting='briggs',robust=0.5,interactive=False)<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.residual.tt0')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this particular run, the rms was 8.9 uJy (noticeably better than the lower baseband only results).<br />
<br />
[[Image:viewSN2010FZ spw0to11_mfs2resid.png|200px|thumb|right|final residual and mask]]<br />
<br />
Let us see if there is more to clean. Bring this up in interactive mode:<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='SN2010FZ_split10s.ms', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
imagename='imgSN2010FZ10s_spw0to11_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=3000,gain=0.1,threshold='0.001mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
mask='imgSN2010FZ10s_spw0to11_mfs2_clean1280.mask', \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
This should start cleaning from where our previous non-interactive clean left off.<br />
<b>Note for 4.2.0:</b> In this case we have specified <tt>mask='imgSN2010FZ10s_spw0to11_mfs2_clean1280.mask'</tt> explicitly due to a bug where it will not otherwise allow you to edit the mask interactively.<br />
<br />
You might find a few more sources revealed in the outer parts of the image, and also more <br />
emission around the galaxy disk in the center. Try drawing new boxes, perhaps extend the box<br />
in the center, and do ~100-1000 more iterations. At the end, what is left should be dominated<br />
by the error patterns from mis-calibration. Only self-calibration will get rid of<br />
these. Stop cleaning for now. See the figure to the right for the interactive display panel<br />
showing final residuals and mask (changing the colormap to <tt>Greyscale 1</tt>).<br />
<br />
Check the residual levels:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.residual.tt0')<br />
sigma = mystat['sigma'][0]<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
The final rms achieved here is 8.7 uJy; slightly better.<br />
<br />
== Analyzing the image ==<br />
<br />
Let's see how close we got to expected noise and dynamic range:<br />
<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0')<br />
peak = mystat['max'][0]<br />
print 'Image max flux = '+str(mystat['max'][0])<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.model.tt0')<br />
total = mystat['sum'][0]<br />
print 'Model total flux = '+str(mystat['sum'][0])<br />
#<br />
snr = peak/sigma<br />
print 'SN2010FZ peak S/N = '+str(snr)<br />
#<br />
snr = total/sigma<br />
print 'SN2010FZ total S/N = '+str(snr)<br />
</source><br />
The output gives:<br />
<pre><br />
Residual standard deviation = 8.74577600158e-06<br />
Image max flux = 0.00993354152888<br />
Model total flux = 0.0341279412654<br />
SN2010FZ peak S/N = 1135.81019307<br />
SN2010FZ total S/N = 3902.2199127<br />
</pre><br />
These are the numbers I got in my run-through. You may get slightly different values depending on how deeply you cleaned.<br />
<br />
What do we expect? If we do {{listobs}} on this MS we see the scans:<br />
<pre><br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) <br />
11-Jul-2010/21:38:44.0 - 21:39:51.0 9 0 SN2010FZ 33696 9.16 <br />
21:40:01.0 - 21:41:20.5 10 0 SN2010FZ 37908 9.89 <br />
21:41:30.0 - 21:42:50.0 11 0 SN2010FZ 37908 10 <br />
21:43:00.0 - 21:44:20.0 12 0 SN2010FZ 37908 10 <br />
21:44:30.0 - 21:45:50.0 13 0 SN2010FZ 37908 10 <br />
21:46:00.0 - 21:47:19.5 14 0 SN2010FZ 37908 9.89 <br />
21:47:29.0 - 21:47:49.0 15 0 SN2010FZ 12636 9.67 <br />
21:49:42.0 - 21:50:49.0 17 0 SN2010FZ 33696 9.17 <br />
21:50:59.0 - 21:52:19.0 18 0 SN2010FZ 37908 10 <br />
21:52:29.0 - 21:53:48.5 19 0 SN2010FZ 37908 9.89 <br />
21:53:58.0 - 21:55:18.0 20 0 SN2010FZ 37908 10 <br />
21:55:28.0 - 21:56:48.0 21 0 SN2010FZ 37908 10 <br />
21:56:58.0 - 21:58:18.0 22 0 SN2010FZ 37908 10 <br />
21:58:28.0 - 21:58:47.5 23 0 SN2010FZ 12636 9.67 <br />
22:00:39.5 - 22:01:47.0 25 0 SN2010FZ 33696 9.18 <br />
22:01:57.0 - 22:03:17.0 26 0 SN2010FZ 37908 10 <br />
22:03:27.0 - 22:04:47.0 27 0 SN2010FZ 37908 10 <br />
22:04:57.0 - 22:06:16.5 28 0 SN2010FZ 37908 9.89 <br />
22:06:26.0 - 22:07:46.0 29 0 SN2010FZ 37908 10 <br />
22:07:56.0 - 22:09:16.0 30 0 SN2010FZ 37908 10 <br />
22:09:26.0 - 22:09:45.5 31 0 SN2010FZ 12636 9.67 <br />
22:11:38.0 - 22:12:45.5 33 0 SN2010FZ 33696 9.19 <br />
22:12:55.0 - 22:14:15.0 34 0 SN2010FZ 37908 10 <br />
22:14:25.0 - 22:15:45.0 35 0 SN2010FZ 37908 10 <br />
22:15:55.0 - 22:17:15.0 36 0 SN2010FZ 37908 10 <br />
22:17:25.0 - 22:18:44.5 37 0 SN2010FZ 37908 9.89 <br />
22:18:54.0 - 22:20:14.0 38 0 SN2010FZ 37908 10 <br />
22:20:24.0 - 22:20:43.5 39 0 SN2010FZ 12636 9.67 <br />
(nVis = Total number of time/baseline visibilities per scan) <br />
</pre><br />
(listing columns truncated) and we estimate about 37 minutes on target. We had about 25 antennas on average, and our spw selection picked out 610 channels (2 MHz each) for a total of 1220 MHz bandwidth. If we plug this<br />
into the<br />
[https://science.nrao.edu/facilities/evla/calibration-and-tools/exposure EVLA exposure calculator], at 5 GHz, we find that we expect a rms thermal noise level of 8.7 uJy, and at 7 GHz, 7.0 uJy. So, our values are within the expected range (a bit higher than theoretical, but that's expected). <br />
<br />
[[Image:plotSN2010FZ_viewerfinal.png|200px|thumb|right|final image]]<br />
Look at this in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0')<br />
</source><br />
Zoom in on the center (see figure to the right).<br />
<br />
[[Image:viewSN2010FZ_spw0to11_mfs2tt1.png|200px|thumb|right|final tt1 image with box]]<br />
In the previous section we demonstrated how to process and display the spectral index image. You can do<br />
the same for this final image. Here, we will do some rough analysis on the spectral index to determine<br />
an intensity-weighted mean spectral index over the core region.<br />
The <tt>.image.tt1</tt> from our mfs is an intensity times alpha image. See the figure to the right.<br />
Let's gate the Taylor-term images on intensity:<br />
<source lang="python"><br />
# In CASA<br />
# Removing any file output from previous runs, so immath will proceed<br />
os.system('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered')<br />
immath(imagename=['imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1',<br />
'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM1>5.0E-5]',<br />
outfile='imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered')<br />
#<br />
# Removing any file output from previous runs, so immath will proceed<br />
os.system('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered')<br />
immath(imagename=['imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM0>5.0E-5]',<br />
outfile='imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered')<br />
</source><br />
<br />
We can identify a box containing the central emission (see figure of tt1 in viewer) and note the corners.<br />
(We could also use the region tools from the viewer, but that is for another exercise.)<br />
Let us compute the intensity-weighted spectral index over this box by averaging<br />
these masked images using {{imstat}} and computing the ratio:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered',<br />
box='503,533,756,762')<br />
avgtt0alpha = mystat['mean'][0]<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered',<br />
box='503,533,756,762')<br />
avgtt0 = mystat['mean'][0]<br />
avgalpha = avgtt0alpha/avgtt0<br />
print 'SN2010FZ I-weighted Alpha = '+str(avgalpha)<br />
</source><br />
We get <br />
<pre><br />
SN2010FZ I-weighted Alpha = -1.38157453384<br />
</pre><br />
<br />
The emission in this source is on the steep side. At this point we do not know how reliable this is or<br />
what we expect (though our calibrators come out with correct spectral indexes if we image them the<br />
same way). But this illustrates a way to extract spectral information from our wideband mfs images.<br />
<br />
== Comparing with the Optical/Infrared ==<br />
<br />
As a final comparison, we turn to the Sloan Digital Sky Survey (SDSS) and a cutout image of our galaxy:<br />
[[Image:NGC_2967_UGC_5180_IRAS_09394+0033_irg.jpg|400px|thumb|center|]]<br />
from their [http://cosmo.nyu.edu/hogg/rc3/NGC_2967_UGC_5180_IRAS_09394+0033_irg.jpg RC3]<br />
album (courtesy D.Hogg, M.Blanton, SDSS collaboration - see [[#Credits]]). This looks like a nice nearby<br />
face-on spiral galaxy. How does our 6cm continuum emission line up with the optical?<br />
<br />
Here is the EVLA 6cm image side by side with a i-band image from the Sloan Digital Sky Survey (SDSS) registered to our image:<br />
<br />
[[Image:plotSN2010FZ viewerfinalandSDSS.png|600px|thumb|center|final and sdss image]]<br />
<br />
You can also find this image, named <tt>NGC_2967_UGC_5180_IRAS_09394+0033-i.fits</tt>, on the web at <tt>http://casa.nrao.edu/Data/EVLA/SN2010FZ/NGC_2967_UGC_5180_IRAS_09394+0033-i.fits</tt> (at the CASA workshop, it's in <tt>/data/casa/evla/</tt> or a similar location that will be given to you in the instructions). Load it into your viewer, and blink against our 6cm image.<br />
<br />
We can also plot one as a raster and the other overlaid as contours. You can load the SDSS image<br />
from the viewer Load Data panel and fiddle with contours. Once you know contour levels, you can<br />
also use the imview task to load a raster and contour image:<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={ 'file' : 'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'},<br />
contour = { 'file' : 'NGC_2967_UGC_5180_IRAS_09394+0033-i.fits',<br />
'levels' : [0.2, 0.5, 1, 1.5, 3],<br />
'base' : 0.0,<br />
'unit' : 1.0 } )<br />
</source><br />
<br />
The figure below shows the SDSS contours overlaid on our 6cm image (after fiddling with the <br />
colormap shift/slope for the EVLA raster image). <br />
<br />
[[Image:viewSN2010FZ_spw0to11_mfs2tt0plusSDSS.png|400px|thumb|center|6cm EVLA raster plus SDSS i-band contours]]<br />
<br />
Likewise, we can plot the SDSS image as a raster and overlay EVLA 6cm contours:<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={ 'file' : 'NGC_2967_UGC_5180_IRAS_09394+0033-i.fits',<br />
'scaling' : -2.0,<br />
'range' : [0,10] },<br />
contour = { 'file' : 'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0',<br />
'levels' : [0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56],<br />
'base' : 0.0,<br />
'unit' : 0.001 },<br />
zoom = { 'blc' : [397,300],<br />
'trc' : [1567,1231] } )<br />
</source><br />
<br />
This is shown in the figure below. Is the compact 6cm emission in upper left associated with a<br />
spiral arm?<br />
<br />
[[Image:viewSN2010FZ_spw0to11_SDSSiplusEVLA6cm.png|400px|thumb|center|SDSS i-band raster plus EVLA 6cm contours]]<br />
<br />
== What to do next: some exercises for the user ==<br />
<br />
Here are a number of things you can try after completing this tutorial:<br />
<br />
# Use self-calibration to improve the data and re-clean to make a better image. See [http://casaguides.nrao.edu/index.php?title=WorkshopSelfcal_(Caltech) this tutorial] for more information on self-calibration.<br />
# Use multi-scale clean by adding non-zero scales to the <tt>multiscale</tt> parameter.<br />
# Image the calibrators. What sort of dynamic range can you get on them? Is self-calibration needed (and if so what dynamic range do you get when you use it)?<br />
# Try the <tt>testautoflag</tt> task (in 3.3.0 and later) to automatically flag RFI from the upper sideband. There is more information on running <tt>testautoflag</tt> in [http://casaguides.nrao.edu/index.php?title=EVLA_Wide-Band_Wide-Field_Imaging:_G55.7_3.4 this tutorial].<br />
<br />
== Credits ==<br />
<br />
The EVLA data was taken by A. Soderberg et al. as part of project AS1015. See <br />
[https://science.nrao.edu/enews/3.8/index.shtml#evlanoise NRAO eNews 3.8] (1-Sep-2010) for more on this result.<br />
<br />
<blockquote><i><br />
The Expanded Very Large Array (EVLA) is a partnership of the United States, Canada, and Mexico. The EVLA is funded in the United States by the National Science Foundation, in Canada by the National Research Council, and in Mexico by the Comisión Nacional de Investigación CientÃfica y Tecnológica (CONICyT).<br />
</i></blockquote><br />
<br />
<blockquote><i><br />
The National Radio Astronomy Observatory is a facility of the National Science Foundation operated under cooperative agreement by Associated Universities, Inc.<br />
</i></blockquote><br />
<br />
SDSS image courtesy David Hogg & Michael Blanton, private communication. Data comes from<br />
SDSS DR7, see [http://adsabs.harvard.edu/abs/2009ApJS..182..543A Abazajian et. al 2009].<br />
<br />
<blockquote><i><br />
Funding for the SDSS and SDSS-II has been provided by the Alfred P. Sloan Foundation, the Participating Institutions, the National Science Foundation, the U.S. Department of Energy, the National Aeronautics and Space Administration, the Japanese Monbukagakusho, the Max Planck Society, and the Higher Education Funding Council for England. The SDSS Web Site is [http://www.sdss.org/].<br />
</i></blockquote><br />
<br />
<blockquote><i><br />
The SDSS is managed by the Astrophysical Research Consortium for the Participating Institutions. The Participating Institutions are the American Museum of Natural History, Astrophysical Institute Potsdam, University of Basel, University of Cambridge, Case Western Reserve University, University of Chicago, Drexel University, Fermilab, the Institute for Advanced Study, the Japan Participation Group, Johns Hopkins University, the Joint Institute for Nuclear Astrophysics, the Kavli Institute for Particle Astrophysics and Cosmology, the Korean Scientist Group, the Chinese Academy of Sciences (LAMOST), Los Alamos National Laboratory, the Max-Planck-Institute for Astronomy (MPIA), the Max-Planck-Institute for Astrophysics (MPA), New Mexico State University, Ohio State University, University of Pittsburgh, University of Portsmouth, Princeton University, the United States Naval Observatory, and the University of Washington.<br />
</i></blockquote><br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_6cmWideband_Tutorial_SN2010FZ_CASA_4.2&diff=15568EVLA 6cmWideband Tutorial SN2010FZ CASA 4.22014-02-06T17:09:19Z<p>Smyers: </p>
<hr />
<div>This is an Advanced EVLA data reduction tutorial that calibrates and images a 6-cm wide-band continuum dataset.<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><br />
== Overview ==<br />
<br />
This article describes the calibration and imaging of a single-pointing 6-cm EVLA wideband continuum dataset of the galaxy NGC2967 (UGC5180) which was the location of the supernova candidate SN2010FZ. No supernova was detected in this observation, but the galactic continuum emission from this face-on spiral is nicely imaged. The data were taken in with 1024 MHz of bandwidth in each of two widely spaced basebands (each comprised of 8 128-MHz spectral windows), spanning 4.5 to 7.5 GHz. We will use wideband imaging techniques in this tutorial.<br />
<br />
This is a more advanced tutorial, and if you are a relative novice (and <em>particularly</em> for EVLA continuum calibration and imaging), it is <em>strongly</em> recommended that you start with the [[EVLA Continuum Tutorial 3C391 CASA 4.2]] (at least read it through) before tackling this dataset. We will not include basic information on CASA processing in this tutorial.<br />
<br />
From the [http://casaguides.nrao.edu MainPage] of this guide you can find helpful information:<br />
* [[What is CASA?]]<br />
* [[Getting Started in CASA]]<br />
* [[CASA Reference Manuals]]<br />
* [[Hints, Tips, & Tricks]]<br />
* [[AIPS-to-CASA Cheat Sheet]]<br />
<br />
In this tutorial we will be invoking the tasks as function calls. You can cut and paste these to your casapy session. We also recommend that you copy all the commands you use, with any relevant commentary, to a text file. This is good practice when tackling large datasets. If you wish, you can use the [http://casaguides.nrao.edu/index.php?title=Extracting_scripts_from_these_tutorials Script Extractor] to create a file with the tutorial commands, which can subsequently be edited as desired.<br />
<br />
Occasionally we will be setting Python variables (e.g. as lists for flags) outside the function call so make sure you<br />
set those before running the task command. Note that when you call a CASA task as a function the task parameters you<br />
do not set in the function call (assuming there is at least one) will be set to their defaults, and will not use values<br />
you set in previous calls or outside the call. See [[Getting_Started_in_CASA#Task_Execution]] for more <br />
on calling tasks and setting parameters in the scripting interface.<br />
<br />
NOTE: If you find that the figures on the right margin of the browser window overlap the text too much and make reading difficult,<br />
go ahead and widen the browser window.<br />
<br />
== Obtaining the Data ==<br />
<br />
The data for this tutorial were taken with the EVLA under program AS1015 as the scheduling block (SB) <tt>AS1015_sb1658169_1.55388.89474846065</tt>, and was run on 2010-07-11 from 21:28 to 22:28 UT (size 37.74GB). <br />
<br />
The data can be directly downloaded from [http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz] (dataset size: 2.9 GB). For example, in you Linux terminal:<br />
<br />
<source lang="bash"><br />
wget http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz<br />
</source><br />
<br />
Your first step will be to unzip and untar the file in a terminal, before you start CASA:<br />
<br />
<source lang="bash"><br />
tar -xzvf SN2010FZ_10s.ms.tar.gz <br />
</source><br />
<br />
If you are brave enough, you can also get the data straight from the EVLA archive. Go to the [https://archive.nrao.edu/archive/advquery.jsp NRAO Science Data Archive], and search for project **AS1015**. Then select the <tt>AS1015_sb1658169_1.55388.89474846065</tt> dataset and choose to apply the online flags (check box "Apply flags generated during observing") and time-averaging of 10 seconds. (The data were taken in D-configuration [max baselines 1km], so one can safely average to 3s or even 10s to reduce dataset size.) Also select the tar option. This will create a file equivalent to what is used at the workshop.<br />
<br />
== Starting CASA ==<br />
<br />
{{CaltechCASAStartup}}<br />
<br />
== Examining the MS ==<br />
<br />
We use {{listobs}} to summarize our MS:<br />
<source lang="python"><br />
# In CASA<br />
listobs('SN2010FZ_10s.ms')<br />
</source><br />
<br />
In the logger you should see:<br />
<br />
<pre><br />
##########################################<br />
##### Begin Task: listobs #####<br />
<br />
================================================================================<br />
MeasurementSet Name: SN2010FZ_10s.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. Alicia M. Soderberg Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 1570726 Total integration time = 3359 seconds<br />
Observed from 11-Jul-2010/21:30:44.0 to 11-Jul-2010/22:26:43.0 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) SpwIds ScanIntent<br />
11-Jul-2010/21:30:44.0 - 21:30:52.0 2 0 J0925+0019 404 6.43 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:31:02.0 - 21:32:22.0 3 0 J0925+0019 5062 9.68 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:32:32.0 - 21:33:52.0 4 0 J0925+0019 6277 9.91 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:34:02.0 - 21:34:52.0 5 0 J0925+0019 4148 9.96 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:35:02.0 - 21:35:51.5 6 0 J0925+0019 32640 9.44 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:36:01.0 - 21:38:20.5 7 0 J0925+0019 81600 9.93 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:38:44.0 - 21:39:51.0 9 1 SN2010FZ 43520 9.16 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:40:01.0 - 21:41:20.5 10 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:41:30.0 - 21:42:50.0 11 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:43:00.0 - 21:44:20.0 12 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:44:30.0 - 21:45:50.0 13 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:46:00.0 - 21:47:19.5 14 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:47:29.0 - 21:47:49.0 15 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:48:12.0 - 21:49:18.5 16 0 J0925+0019 43520 9 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:49:42.0 - 21:50:49.0 17 1 SN2010FZ 43520 9.17 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:50:59.0 - 21:52:19.0 18 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:52:29.0 - 21:53:48.5 19 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:53:58.0 - 21:55:18.0 20 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:55:28.0 - 21:56:48.0 21 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:56:58.0 - 21:58:18.0 22 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:58:28.0 - 21:58:47.5 23 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:59:10.5 - 22:00:17.0 24 0 J0925+0019 43520 8.99 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:00:39.5 - 22:01:47.0 25 1 SN2010FZ 43520 9.18 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:01:57.0 - 22:03:17.0 26 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:03:27.0 - 22:04:47.0 27 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:04:57.0 - 22:06:16.5 28 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:06:26.0 - 22:07:46.0 29 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:07:56.0 - 22:09:16.0 30 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:09:26.0 - 22:09:45.5 31 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:10:08.0 - 22:11:15.5 32 0 J0925+0019 43520 9.13 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:11:38.0 - 22:12:45.5 33 1 SN2010FZ 43520 9.19 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:12:55.0 - 22:14:15.0 34 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:14:25.0 - 22:15:45.0 35 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:15:55.0 - 22:17:15.0 36 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:17:25.0 - 22:18:44.5 37 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:18:54.0 - 22:20:14.0 38 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:20:24.0 - 22:20:43.5 39 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:21:06.0 - 22:22:13.5 40 0 J0925+0019 42690 9.15 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:25:13.0 - 22:25:13.0 42 2 3C286 1028 2.87 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
22:25:23.0 - 22:26:43.0 43 2 3C286 47757 9.6 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
(nVis = Total number of time/baseline visibilities per scan) <br />
Fields: 3<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 D J0925+0019 09:25:07.81503 +00.19.13.9334 J2000 0 303381 <br />
1 NONE SN2010FZ 09:42:04.77000 +00.19.51.0000 J2000 1 1218560<br />
2 K 3C286 13:31:08.28798 +30.30.32.9589 J2000 2 48785 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (18 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 64 TOPO 7686 2000 128000 RR RL LR LL <br />
1 64 TOPO 7836 2000 128000 RR RL LR LL <br />
2 64 TOPO 4488 2000 128000 RR RL LR LL <br />
3 64 TOPO 4616 2000 128000 RR RL LR LL <br />
4 64 TOPO 4744 2000 128000 RR RL LR LL <br />
5 64 TOPO 4872 2000 128000 RR RL LR LL <br />
6 64 TOPO 5000 2000 128000 RR RL LR LL <br />
7 64 TOPO 5128 2000 128000 RR RL LR LL <br />
8 64 TOPO 5256 2000 128000 RR RL LR LL <br />
9 64 TOPO 5384 2000 128000 RR RL LR LL <br />
10 64 TOPO 6488 2000 128000 RR RL LR LL <br />
11 64 TOPO 6616 2000 128000 RR RL LR LL <br />
12 64 TOPO 6744 2000 128000 RR RL LR LL <br />
13 64 TOPO 6872 2000 128000 RR RL LR LL <br />
14 64 TOPO 7000 2000 128000 RR RL LR LL <br />
15 64 TOPO 7128 2000 128000 RR RL LR LL <br />
16 64 TOPO 7256 2000 128000 RR RL LR LL <br />
17 64 TOPO 7384 2000 128000 RR RL LR LL <br />
Sources: 50<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J0925+0019 0 - - <br />
0 J0925+0019 1 - - <br />
0 J0925+0019 2 - - <br />
0 J0925+0019 3 - - <br />
0 J0925+0019 4 - - <br />
0 J0925+0019 5 - - <br />
0 J0925+0019 6 - - <br />
0 J0925+0019 7 - - <br />
0 J0925+0019 8 - - <br />
0 J0925+0019 9 - - <br />
0 J0925+0019 10 - - <br />
0 J0925+0019 11 - - <br />
0 J0925+0019 12 - - <br />
0 J0925+0019 13 - - <br />
0 J0925+0019 14 - - <br />
0 J0925+0019 15 - - <br />
0 J0925+0019 16 - - <br />
0 J0925+0019 17 - - <br />
1 SN2010FZ 2 - - <br />
1 SN2010FZ 3 - - <br />
1 SN2010FZ 4 - - <br />
1 SN2010FZ 5 - - <br />
1 SN2010FZ 6 - - <br />
1 SN2010FZ 7 - - <br />
1 SN2010FZ 8 - - <br />
1 SN2010FZ 9 - - <br />
1 SN2010FZ 10 - - <br />
1 SN2010FZ 11 - - <br />
1 SN2010FZ 12 - - <br />
1 SN2010FZ 13 - - <br />
1 SN2010FZ 14 - - <br />
1 SN2010FZ 15 - - <br />
1 SN2010FZ 16 - - <br />
1 SN2010FZ 17 - - <br />
2 3C286 2 - - <br />
2 3C286 3 - - <br />
2 3C286 4 - - <br />
2 3C286 5 - - <br />
2 3C286 6 - - <br />
2 3C286 7 - - <br />
2 3C286 8 - - <br />
2 3C286 9 - - <br />
2 3C286 10 - - <br />
2 3C286 11 - - <br />
2 3C286 12 - - <br />
2 3C286 13 - - <br />
2 3C286 14 - - <br />
2 3C286 15 - - <br />
2 3C286 16 - - <br />
2 3C286 17 - - <br />
Antennas: 27:<br />
ID Name Station Diam. Long. Lat. <br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
5 ea06 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
8 ea10 N03 25.0 m -107.37.06.3 +33.54.04.8 <br />
9 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
10 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
11 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
12 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
13 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
14 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
15 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
16 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
17 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
18 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
19 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
20 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
21 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
22 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
23 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
24 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
25 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
26 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
<br />
##### End Task: listobs #####<br />
##########################################<br />
</pre><br />
<br />
This task displays a lot of information about the MS. We can see that the observation was performed with the EVLA, for a total integration of 3359 seconds (1 hour). The number of data records (1570726) is equal to the number of baselines (N_antenna * [N_antenna - 1] / 2) X the number of integrations (observing time / time-average binning) X the number of spectral windows. For this observation, this is roughly 351 baselines (27X26/2) X 360 integrations (3600s total/10s avg) X 16 spectral windows = 2021760. Note that this is high by ~30%; this is because the archive already flagged bad data, and there are some scans which only have two (rather than 16) spectral windows present. Extra exercise: examine the MS using {{browsetable}} to see what a data record looks like (equivalent to a row, as displayed by this task).<br />
<br />
The most useful parts of the {{listobs}} output are the scan, field, and spectral window listings. <br />
<br />
From the spectral window information, we can see that there were a total of 18 (0 through 17) spectral windows in this dataset. The first two of these (0 and 1) were only used to help set up the correlator. <br />
<br />
Looking at the scan listing, we can see that the first four scans which are present used only these spectral windows. These are referred to as "dummy scans". We will not be using these, since they often contain bad data. <br />
<br />
The C-band data of interest is contained in scans 6-44 and spectral windows 2 to 17. Careful examination shows that scan 8 is missing but from the time ranges that the data has been merged into scan 7. This sort of correlator back-end data-capture issue was occasionally seen during 2010. Hopefully, it will not affect our data, but we should keep an eye out for problems with scan 7. <br />
<br />
The field listing shows three sources: <br />
<br />
* J0925+0019 (also referred to by its field ID, 0), which will serve as a calibrator for the visibility phases, <br />
* SN2010FZ (1), our science target field, and <br />
* 3C286 (2), which will serve as a calibrator for the visibility amplitudes, i.e., it is assumed to have a precisely known flux density; as well as the spectral bandpass.<br />
<br />
== Flagging the MS ==<br />
<br />
The online flags, which are a record of known bad data produced by the EVLA online system, have already been applied by the archive as it generated the MS. However, it's good to have a sense of what was deleted in this process. A record of the flags is also stored in a separate table in the MS, called <tt>FLAG_CMD</tt>. (In fact, the information for this table is actually a subdirectory within the MS; you can see this by listing the contents of <tt>SN2010FZ_10s.ms</tt>.)<br />
<br />
[[Image:PlotSN2010FZ_flagcmd_3.4.png|200px|thumb|right|online flags plotted from flagcmd]]<br />
You can examine the commands stored in the <tt>FLAG_CMD</tt> table using {{flagcmd}}.<br />
<source lang="python"><br />
# In CASA<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='table',action='list')<br />
</source><br />
These will go to the logger or terminal (they appear to go to the terminal now in 4.2).<br />
<br />
You can also plot the commands stored in the <tt>FLAG_CMD</tt> table:<br />
<source lang="python"><br />
# In CASA<br />
myrows = range(285)<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='table',action='plot',tablerows=myrows)<br />
</source><br />
<br />
Note that we are only plotting the first 285 rows -- this is because the last few are from flagging zeros in the data (caused by correlator errors) and data which have been flagged due to [http://evlaguides.nrao.edu/index.php?title=Observational_Status_Summary#Shadowing_and_Cross-Talk antenna shadowing]. Note that you can not do the <tt>tablerows</tt> selection and plot those too, you will just get lines at the bottom marked as "All" antennas for these flags.<br />
<br />
This will bring up a <tt>matplotlib</tt> plotter. You can have it plot to a PNG file instead:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagcmd(vis='SN2010FZ_10s.ms', inpmode='table', action='plot', tablerows=myrows, <br />
plotfile='PlotSN2010FZ_flagcmd_4.2.png')<br />
</source><br />
<br />
The flags as plotted in the figure to the above right look normal. <br />
They are color-coded by REASON, and you see ANTENNA_NOT_ON_SOURCE flags between scans, and the occasional SUBREFLECTOR_ERROR flag also between scans (most likely after band changes when the subreflector rotates to <br />
pick up the new feed on the ring, some are slower than others). What you watch for here are long blocks of unexpected flags, which might be false alarms and cause you to flag too much data. In that case, look at the data itself in {{plotms}} (see below for examples) to decide whether or not to apply all flags.<br />
<br />
[[Image:plotSN2010FZ_plotants.png|200px|thumb|right|plotants plotter]]<br />
To plot up the antenna positions in the array:<br />
<source lang="python"><br />
# In CASA<br />
plotants('SN2010FZ_10s.ms')<br />
</source><br />
<br />
NOTE: if after this point (or any other) you get "table locks", which may occur erroneously and are sometimes triggered by plotting tasks, use {{clearstat}} to clear them:<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat<br />
</source><br />
<br />
Now we examine the MS looking for bad data to flag. We will use {{plotms}} to bring up an interactive GUI that will display 2-D Y vs.X style line plots. <b>NOTE: We do not recommend using the editing/flagging features of plotms.</b> It is very easy to mess up your data this way. Also, to improve speed we will be restricting the scope of plotting so most box/flag operations would not get rid of all the bad data. <br />
<br />
We will instead use plotms to identify bad data and then use flagcmd to flag it. This will also allow full scripting of the flagging, which is ultimately the best way to keep track of what's been deleted. Given the large dataset sizes now being generated, reproducibility is extremely important. Imaging spending a day flagging your data, then a disk error corrupts the MS. It's imperative that you have an automated way to regenerate your work. This is also why we encourage you to keep a running file with all the commands you use on a dataset.<br />
<br />
NOTE: If you need an introduction to {{plotms}}, see:<br />
* [[Data flagging with plotms]]<br />
* [[Averaging data in plotms]]<br />
* [[What's the difference between Antenna1 and Antenna2? Axis definitions in plotms]]<br />
<br />
WARNING: The '''Flag''' [[Image:FlagThoseData.png]] button on the plotms GUI is close to other buttons you will be using, in particular the one that gets rid of boxes you have drawn. Be careful and don't hit the '''Flag''' button by mistake!<br />
<br />
As we found above, the useful spectral windows are 2-17. To get an idea of the data layout, plot a single baseline (ea01&ea02) and channel (31, for all spectral windows) versus time:<br />
<br />
[[Image:screenshotPlotSN2010FZ_plotms_ants1_4.0.png|200px|thumb|right|plotms ea01&ea02 amp vs time]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='',spw='2~17:31~31', \<br />
antenna='ea01&ea02',correlation='RR,LL',xaxis='time',yaxis='amp')<br />
</source><br />
<br />
Here, we can see the alternating phase calibration and science target scans, as well as the (brighter) flux calibrator at the end of the observation. Feel free to play with ways to view, or color the data: for example, go to the "Display" left-hand tab, and choose "Colorize by: Field". You can also change the size of the plotted points, if they are too small to see easily, by setting "Unflagged Points Symbol" to "Custom" and increasing the number of pixels under "Style".<br />
<br />
[[Image:screenshotPlotSN2010FZ_plotms_ants2_4.0.png|200px|thumb|right|plotms ea01 for field 2 showing amp versus ANTENNA2]]<br />
Look for bad antennas by picking the last field and plotting baselines versus antenna <tt>ea01</tt>:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17:31~31', \<br />
antenna='ea01',correlation='RR,LL',xaxis='antenna2',yaxis='amp')<br />
</source><br />
<br />
You should be able to see that antenna 11 (= ea13) is bad (very low amplitude, it has no C-band receiver!) and that some of the spectral windows on 15 and 23 (ea17, ea25) are also on the low side. Boxing with the '''Mark Regions''' [[Image:MarkRegionsButton.png]] tool and using the '''Locate''' [[File:casaplotms-locate-tool.png]] tool will show in the logger that spw 10-17 are suspect for these antennas. (Note: you may also leave these in for now if you like; if this were truly a first pass through the data it is unlikely that they would be caught. Since this is a tutorial, and there is limited time for a second pass through the data, it's probably best to trust us and delete them now.)<br />
<br />
[[Image:plotSN2010FZ_plotms_ea02.png|200px|thumb|right|plotms field 2 ea02 amp vs frequency]]<br />
Now look at the bandpass for ea02 - it is in the inner core and a prospective reference antenna. Exclude ea13 using negation (represented by "!") in the selection:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17', \<br />
antenna='ea02;!ea13',correlation='RR,LL',xaxis='frequency',yaxis='amp')<br />
</source><br />
There is clearly less data for spw 11, and use of Locate shows spw 11 data only for ea02,ea03,04,08,09,11,12. We will later delete this incomplete spw. Note also the very strong RFI spike at 6614 MHz (spw 10 ch 63) with clear ringing contaminating both spw 10 and 11. There is also a tremendous roll-off in spw 10. We will drop these spectral window when we process the data.<br />
<br />
[[Image:plotSN2010FZ_plotms_ea02ea20.png|200px|thumb|right|plotms ea02 iteration with baseline stopped at ea02&ea20 showing phase vs frequency]]<br />
We can also step through the baselines to our antenna using iteraxis:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02;!ea13', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',iteraxis='baseline')<br />
</source><br />
and use the '''Next Iteration''' [[Image:NextIterationButton.png]] button to step through the baselines.<br />
This will make it easier to isolate the bad antennas. Now plot the phases, iterating through baselines to ea02:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02;!ea13', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',iteraxis='baseline')<br />
</source><br />
You see the slopes due to residual delays. Mostly a turn or less over a 128MHz subband, but there are some outliers.<br />
Step through to ea20. You see that there is a very large delay in RR (via locate) for<br />
the first baseband (spw 0~7). We will delete this (will also delete LL so there are no orphan polarization products, which would be ignored by {{clean}} in the imaging stage).<br />
Note ea17 and ea25 baselines drop close to zero in the middle of upper baseband (e.g. plot 'ea17&ea25') so we will delete these.<br />
<br />
To carry out flagging, we again use {{flagcmd}} in the mode where it takes a list of command strings:<br />
<source lang="python"><br />
# In CASA<br />
flaglist = ['antenna="ea13"',<br />
'antenna="ea17" spw="10~17"',<br />
'antenna="ea25" spw="10~17"',<br />
'antenna="ea20" spw="2~9"']<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='list',inpfile=flaglist,action='apply',flagbackup=True)<br />
</source><br />
These commands will be carried out as well as being added to the FLAG_CMD table (marked as applied).<br />
<br />
Plot the data again, now that is has been flagged:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='',spw='5:30~33',avgchannel='64', \<br />
antenna='ea01&ea02',correlation='RR,LL',xaxis='time',yaxis='amp')<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
<br />
[[Image:plotSN2010FZ_plotms_ea02fld0.png|200px|thumb|right|plotms field 0 ea02 amp vs frequency]]<br />
Now our phase calibrator - it is weaker, and we now start to really see the RFI:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='0',spw='2~17',antenna='ea02', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
Use the Zoom feature, Mark rectangles and use Locate to identify the frequency/channel of RFI. In particular, we note in our analysis:<br />
* 6614MHz (spw 10 ch 63) super strong<br />
* 6772-6778MHz (spw 12 ch 14-17)<br />
* 7260-7264MHz (spw 16 ch 2-4)<br />
* 7314-7340MHz (spw 16 ch 29-42)<br />
* 7402-7418MHz (spw 17 ch 9-17)<br />
* 7458-7466MHz (spw 17 ch 37-41)<br />
* 7488MHz (spw 17 ch 52)<br />
<br />
If you plot all antennas and avoid the band edges you see spw 16 and 17 are pretty wiped out:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='0',spw='2~17:4~59',antenna='', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
<br />
For now we will not flag these spectral windows, but note the bad channels, which we will mask out when creating continuum calibration tables and images.<br />
<br />
Finally, split off the good scans and spw, this will allow us to work on the data without having to start completely over (if we mess something up badly) as well as letting us do simpler data selections. Note that we do not include spw 10, because of the bad RFI, or spw 11, because of the many missing antennas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_flagged10s.ms')<br />
split(vis='SN2010FZ_10s.ms',outputvis='SN2010FZ_flagged10s.ms',datacolumn='data',spw='2~9,12~17',scan='7~43')<br />
</source><br />
<br />
You now have a MS called <tt>SN2010FZ_flagged10s.ms</tt> in your working area. This should be 2.8GB in size, which you can see while still at the CASA command prompt by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('du -sh SN2010FZ_flagged10s.ms')<br />
</source><br />
<br />
Note that the built-in <tt>system</tt> function allows one to execute UNIX shell commands within a CASA session. (Some, like <tt>ls</tt>, don't need this extra wrapper, but most are not automatically understood.)<br />
<br />
[[Image:PlotSN2010FZ_plotms_datastream_zoomed.png|200px|thumb|right|plotms antenna2 vs. time "datastream" plot, zoomed in on last scan]]<br />
At this point it is useful to plot a "datastream" view of the dataset to show what antennas are present at what time. You can do this using<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
This shows the times where data is present on baselines TO a given Antenna2 (which means there is no line for ea01 which is antenna 0). You can pick up ea01 (and drop ea28) by setting <tt>yaxis='antenna1'</tt>. To the right we show this plot, having zoomed in on the last scan on 3C286. You see here that some antennas are present in this scan earlier than others (e.g. ea02 comes in one 10s integration later than ea04).<br />
<br />
== Calibration ==<br />
<br />
Summarize the split flagged MS:<br />
<source lang="python"><br />
# In CASA<br />
listobs('SN2010FZ_flagged10s.ms')<br />
</source><br />
In the logger we see:<br />
<pre><br />
##########################################<br />
##### Begin Task: listobs #####<br />
<br />
================================================================================<br />
MeasurementSet Name: SN2010FZ_flagged10s.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. Alicia M. Soderberg Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 1375038 Total integration time = 3042 seconds<br />
Observed from 11-Jul-2010/21:36:01.0 to 11-Jul-2010/22:26:43.0 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) SpwIds ScanIntent<br />
11-Jul-2010/21:36:01.0 - 21:38:20.5 7 0 J0925+0019 73710 9.93 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
21:38:44.0 - 21:39:51.0 9 1 SN2010FZ 39312 9.16 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:40:01.0 - 21:41:20.5 10 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:41:30.0 - 21:42:50.0 11 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:43:00.0 - 21:44:20.0 12 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:44:30.0 - 21:45:50.0 13 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:46:00.0 - 21:47:19.5 14 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:47:29.0 - 21:47:49.0 15 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:48:12.0 - 21:49:18.5 16 0 J0925+0019 39312 9 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
21:49:42.0 - 21:50:49.0 17 1 SN2010FZ 39312 9.17 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:50:59.0 - 21:52:19.0 18 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:52:29.0 - 21:53:48.5 19 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:53:58.0 - 21:55:18.0 20 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:55:28.0 - 21:56:48.0 21 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:56:58.0 - 21:58:18.0 22 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:58:28.0 - 21:58:47.5 23 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:59:10.5 - 22:00:17.0 24 0 J0925+0019 39312 8.99 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:00:39.5 - 22:01:47.0 25 1 SN2010FZ 39312 9.18 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:01:57.0 - 22:03:17.0 26 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:03:27.0 - 22:04:47.0 27 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:04:57.0 - 22:06:16.5 28 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:06:26.0 - 22:07:46.0 29 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:07:56.0 - 22:09:16.0 30 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:09:26.0 - 22:09:45.5 31 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:10:08.0 - 22:11:15.5 32 0 J0925+0019 39312 9.13 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:11:38.0 - 22:12:45.5 33 1 SN2010FZ 39312 9.19 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:12:55.0 - 22:14:15.0 34 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:14:25.0 - 22:15:45.0 35 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:15:55.0 - 22:17:15.0 36 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:17:25.0 - 22:18:44.5 37 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:18:54.0 - 22:20:14.0 38 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:20:24.0 - 22:20:43.5 39 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:21:06.0 - 22:22:13.5 40 0 J0925+0019 38584 9.15 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:25:13.0 - 22:25:13.0 42 2 3C286 924 2.88 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
22:25:23.0 - 22:26:43.0 43 2 3C286 43148 9.6 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
(nVis = Total number of time/baseline visibilities per scan) <br />
Fields: 3<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 D J0925+0019 09:25:07.81503 +00.19.13.9334 J2000 0 230230 <br />
1 NONE SN2010FZ 09:42:04.77000 +00.19.51.0000 J2000 1 1100736<br />
2 K 3C286 13:31:08.28798 +30.30.32.9589 J2000 2 44072 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (14 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 64 TOPO 4488 2000 128000 RR RL LR LL <br />
1 64 TOPO 4616 2000 128000 RR RL LR LL <br />
2 64 TOPO 4744 2000 128000 RR RL LR LL <br />
3 64 TOPO 4872 2000 128000 RR RL LR LL <br />
4 64 TOPO 5000 2000 128000 RR RL LR LL <br />
5 64 TOPO 5128 2000 128000 RR RL LR LL <br />
6 64 TOPO 5256 2000 128000 RR RL LR LL <br />
7 64 TOPO 5384 2000 128000 RR RL LR LL <br />
8 64 TOPO 6744 2000 128000 RR RL LR LL <br />
9 64 TOPO 6872 2000 128000 RR RL LR LL <br />
10 64 TOPO 7000 2000 128000 RR RL LR LL <br />
11 64 TOPO 7128 2000 128000 RR RL LR LL <br />
12 64 TOPO 7256 2000 128000 RR RL LR LL <br />
13 64 TOPO 7384 2000 128000 RR RL LR LL <br />
<snip><br />
</pre><br />
Note that the spectral windows are re-numbered to 0 through 13.<br />
<br />
=== Setting the flux density scale ===<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#x195-1920004 Synthesis Calibration] in the CASA Cookbook and User Reference Manual .<br />
<br />
Before calibrating, we insert a model for flux calibration source 3C286 into the MS. In order to do this, we first have to locate the model image on our system with {{setjy}}, which we will also use to set the flux density scale. The {{setjy}} task (in release 3.3.0 and later) has an option to list possible model images it knows about:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='SN2010FZ_flagged10s.ms', listmodels=True)<br />
</source><br />
which sends output to your terminal (but not the logger). For example, on an NRAO workstation:<br />
<pre><br />
<br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
The relevant image for our purposes is <tt>3C286_C.im</tt>, in the directory <tt>/usr/lib64/casapy/release/data/nrao/VLA/CalModels</tt>. Your system may show a different location (for example <tt>/home/casa/data/nrao/VLA/CalModels/</tt>, or <tt>/Applications/CASA.app/Contents/data/nrao/VLA/CalModels</tt> on a Mac). Since it knows about this image, we only have to give the image name and not the entire path. Otherwise, you will need to give it the entire path. We now run the task using this model:<br />
<br />
<source lang="python"><br />
# In CASA<br />
mysetjy = setjy(vis='SN2010FZ_flagged10s.ms', field='2', scalebychan=True, model='3C286_C.im', usescratch=False)<br />
</source><br />
<br />
* <tt>scalebychan=True</tt>: will fill the model with per-channel values; otherwise, {{setjy}} would use a single value per spectral window.<br />
* <tt>usescratch=False</tt>: put the model in the header instead of creating scratch columns in the MS. This will take up considerably less disk space.<br />
<br />
We have not specified a Flux Density Scale Standard and are thus using the default (<tt>standard='Perley-Butler 2010'</tt>) as that was current when these observations were taken. In particular, there is a more recent "Perley-Butler 2013" scale that most users will want to use! See <tt>help setjy</tt> for more details.<br />
<br />
Inspecting the logger report shows that 3C286 is about 7.7 Jy at lower end of the band to 5.7 Jy at the upper end.<br />
<br />
Note: With release 4.2 {{setjy}} now returns a dictionary to Python, which we have captured in a variable. This can be used in scripts.<br />
<br />
=== Deriving pre-determined calibrations: antenna position corrections, gain-elevation curves, and requantizer gains ===<br />
<br />
Some calibration products are carried along throughout the calibration process and used as priors for subsequent calibration steps. These include the antenna position corrections, gain-elevation curves, and requantizer gains.<br />
<br />
We use {{gencal}} to determine any antenna-position corrections that need to be applied to the data. This is based on a database of corrections with the time they were determined and when they were applied by the observing system, compared to the times in your observations.<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.antpos',caltype='antpos',antenna='')<br />
</source><br />
You should see in the logger:<br />
<pre style="background-color: #fffacd;"><br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea06 : 0.00220 0.00100 0.00590<br />
offsets for antenna ea10 : 0.00080 0.00300 -0.00140<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.00370 -0.00130 0.00000<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
</pre><br />
Note that there are significant position corrections for a number of the antennas. <br />
<br />
In CASA 4.1 and later, we now have the option to use {{gencal}} to create a calibration table containing the gain curves for the antennas. Although you can still use the <tt>gaincurve=True</tt> option in each task, we will make use of this new feature (note that the <tt>gaincurve=True</tt> will be phased out in future CASA releases):<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.gaincurve',caltype='gc')<br />
</source><br />
<br />
Finally, we will use {{gencal}} to create a calibration table containing corrections for the requantizer gains. Although this is only necessary for 3-bit data (and our SN2010FZ is 8-bit), we include it here for completeness. It will not affect the calibration for our 8-bit data, but if one is following this CASA Guide as a template for 3-bit data, this step is needed to account for the small gain changes (~5-10%) that result from resetting the quantizer gains as the correlator changes to a new 3-bit configuration.<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.requantizer',caltype='rq')<br />
</source><br />
<br />
Since we're running {{gencal}} on 3-bit data, it logs that it found "0 TIME/SPW switched power samples."<br />
<br />
The caltables we have generated -- <tt>calSN2010FZ.antpos</tt>, <tt>calSN2010FZ.gaincurve</tt>, and <tt>calSN2010FZ.requantizer</tt> -- will need to be pre-applied in subsequent calibration steps.<br />
<br />
=== Calibrating delays and bandpass ===<br />
<br />
[[Image:plotSN2010FZ_plotcal_G0p1_4.0.png|200px|thumb|right|plotcal G0 phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G0p2_4.0.png|200px|thumb|right|plotcal G0 phase ant 16~26]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_delays_4.2.png|200px|thumb|right|plotcal K0 delay vs. antenna]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_B0a1_4.0.png|200px|thumb|right|plotcal B0 bandpass amp ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_B0a2_4.0.png|200px|thumb|right|plotcal B0 bandpass amp ant 16~26]]<br />
[[Image:plotSN2010FZ_plotcal_B0p1_4.0.png|200px|thumb|right|plotcal B0 bandpass phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_B0p2_4.0.png|200px|thumb|right|plotcal B0 bandpass phase ant 16~26]]<br />
[[Image:plotSN2010FZ_plotcal_B0ea14_4.0.png|200px|thumb|right|plotcal B0 amp and phase vs. freq for ea14]]<br />
<br />
First, we do a phase-only calibration solution on a narrow range of channels in each spw on the bandpass/flux calibrator 3c286 to flatten them before solving for the bandpass. Note where we saw RFI in the higher spw and avoid those channels. The range 23~28 should work. Pick a refant near center - ea04 is a reasonable bet (see above):<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G0',field='2',spw='0~13:23~28', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve'],\<br />
gaintype='G',refant='ea04',calmode='p',solint='int',minsnr=3) <br />
</source><br />
<br />
* <tt>refant='ea04'</tt> : try to use ea04 as the reference antenna<br />
* <tt>solint='int'</tt> : do a per-integration solve (every 10 seconds, since we've time-averaged the data)<br />
* <tt>minsnr=3</tt> : apply a minimum signal-to-noise cutoff. Solutions with less than this value will be flagged<br />
* <tt>gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve']</tt> : pre-apply the antpos and gaincurve caltables<br />
<br />
Plot the phase solutions (using full phase range, -180 to 180, instead of autorange):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Step through the antenna-based solutions. They look good (and fairly flat over the scans).<br />
<br />
NOTE: When you are done plotting and want to use the caltable in another task, use the Quit button on the GUI to dismiss the plotter and free up the lock on the caltable. You should see a message in your terminal window saying "Resetting plotcal" which means you are good to go!<br />
<br />
If you want to make single-page multipanel plots (like those shown to the right), particularly for a<br />
hardcopy (where it only shows the first page), you can do:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase', \<br />
antenna='0~10,12~15',subplot=531,iteration='antenna', \<br />
plotrange=[-1,-1,-180,180],showgui=False,fontsize=6.0, \<br />
figfile='plotSN2010FZ_plotcal_G0p1.png')<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase', \<br />
antenna='16~26',subplot=531,iteration='antenna', \<br />
plotrange=[-1,-1,-180,180],showgui=False,fontsize=6.0, \<br />
figfile='plotSN2010FZ_plotcal_G0p2.png')<br />
</source><br />
<br />
We can now solve for the residual antenna-based delays that we saw in phase vs. frequency.<br />
This uses the new gaintype='K' option in gaincal. Note that this currently does not do a "global fringe-fitting" solution for delays,<br />
but instead does a baseline-based delay solution to all baselines to the refant, treating these<br />
as antenna-based delays. In most cases with high-enough S/N to get baseline-based delay solutions<br />
this will suffice. We avoid the beginning of spw 0 due to the extreme roll-off (with loss of S/N) at the<br />
starting edge.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.K0',\<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.G0'],\<br />
field='2',spw='0:8~59,1~13:4~59',gaintype='K', \<br />
refant='ea04',combine='scan',solint='inf',minsnr=3)<br />
</source><br />
We pre-apply our initial phase table, and produce a new K-type caltable for input to bandpass calibration.<br />
We can plot the delays, in nanoseconds, as a function of antenna index (you will get one for each subband and polarization):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.K0', xaxis='antenna', yaxis='delay')<br />
</source><br />
<br />
The delays range from around -6 to 6 nanoseconds.<br />
<br />
Now solve for the bandpass using the previous tables:<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.B0', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve', \<br />
'calSN2010FZ.G0','calSN2010FZ.K0'], \<br />
field='2',refant='ea04',solnorm=False, \<br />
bandtype='B', combine='scan', solint='inf')<br />
</source><br />
'''WARNING''': You must set <tt>solnorm=False</tt> here or later on you will find some offsets<br />
between spw due to how amplitude scaling adjusts weights internally during solving.<br />
<br />
You will see in the terminal some reports of solutions failing below our default S/N>3 cutoff:<br />
<pre><br />
32 of 50 solutions flagged due to SNR < 3 in spw=0 (chan=1) at 2010/07/11/22:26:05.4<br />
44 of 50 solutions flagged due to SNR < 3 in spw=0 (chan=0) at 2010/07/11/22:26:05.4<br />
</pre><br />
<br />
These are in the first two edge channels of the first spw where the response is low, and not unexpected. <br />
In the logger you will also see reports of reference antennas jumping in those channels, which can be <br />
be safely ignored (we will drop those channels later anyway).<br />
<br />
This is the first amplitude-scaling calibration that we do, so it is important to have used the <tt>calSN2010FZ.gaincurve</tt> caltable (or set <tt>gaincurve=True</tt>). If we were at higher frequency we would also have made an opacity caltable (or set <tt>opacity</tt>).<br />
<br />
Now plot this, in amplitude then phase:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',iteration='antenna')<br />
#<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
or to plot them all together<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',<br />
antenna='0~10,12~15',subplot=531,iteration='antenna',<br />
fontsize=6.0, figfile='plotSN2010FZ_plotcal_B0a1_4.2.png')<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',<br />
antenna='16~26',subplot=531,iteration='antenna',<br />
fontsize=6.0, figfile='plotSN2010FZ_plotcal_B0a2_4.2.png')<br />
#<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',<br />
antenna='0~10,12~15',subplot=531,iteration='antenna',<br />
plotrange=[-1,-1,-180,180],fontsize=6.0, <br />
figfile='plotSN2010FZ_plotcal_B0p1_4.2.png')<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',<br />
antenna='16~26',subplot=531,iteration='antenna',<br />
plotrange=[-1,-1,-180,180],fontsize=6.0, <br />
figfile='plotSN2010FZ_plotcal_B0p2_4.2.png')<br />
</source><br />
(this can take a long time to plot).<br />
<br />
In the bandpass phase you no longer see the residual antenna delays (just residual spw phase offsets from <br />
the delay solution registration) but there are some band edge effects.<br />
Note that some antennas have a little strange bandpasses at upper end of lower baseband in spw 5,6,7<br />
(e.g. ea14,ea16,ea17,ea25).<br />
To plot amp and phase for a single antenna versus frequency (see plots at right):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp', \<br />
antenna='ea14',subplot=211)<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase', \<br />
antenna='ea14',subplot=212,plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Because our flux density calibrator 3C286 is bright enough, we were able to use this as the bandpass calibrator.<br />
Since {{setjy}} put the correct spectrum for 3C286 into the MODEL_DATA column, our bandpass will reflect the<br />
true bandpass of the instrument. However, if for your observation you were unable to use a source of known spectrum <br />
as the bandpass calibrator, then you would need to use the output of {{fluxscale}} later on to bootstrap a {{setjy}} <br />
on your bandpass source using the derived spectral index information.<br />
<br />
=== Final phase and amplitude calibration ===<br />
<br />
[[Image:plotSN2010FZ_plotcal_G1intp1_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G1intp2_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 16~26]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_G1intp_ea01_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G1infp_ea01_4.0.png|200px|thumb|right|plotcal G1inf per-scan phase ant 0~15]]<br />
<br />
Now calibrate phases using the full bandwidth. <br />
First both our calibrators, one at a time - we could do them together, but in general you might need<br />
to do different solution intervals for each, so we keep the runs separate to illustrate how to <br />
do separate solutions and append them.<br />
We exclude RFI channels here, and obtain one solution per integration (these are bright enough):<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1int', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='2',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='int',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1int', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='int',gaintype='G',calmode='p',append=True)<br />
</source><br />
These will get applied when solving for amplitudes, and when calibrating the calibrators themselves.<br />
<br />
The phases look reasonably connected:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G1int',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
To apply phase calibration to the target, we make a second table with one solution on our gain calibrator per scan:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1inf',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',gaintype='G',calmode='p')<br />
</source><br />
These scan phases will get interpolated by {{applycal}} onto our target. These look good also:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G1inf',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Now solve for amplitudes on a per scan interval, after applying the per-integration phases. <br />
Do these separately using <tt>gainfield</tt> so phases don't get<br />
transferred across fields. For field 2 (3C286) we use <tt>combine='scan'</tt> as there are two scans <br />
on this source, with the first one having much less data (and will thus give a noisy solution on its own).<br />
Note that {{gaincal}} uses linear interpolation of the previously determined phases by default, so <br />
set this to "nearest" if you want to override this.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'], \<br />
gainfield=['','','2','2','2'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='2',refant='ea04',solnorm=F,<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'],\<br />
gainfield=['','','2','2','0'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',gaintype='G',calmode='a',append=True)<br />
</source><br />
This is the table we will apply to the data.<br />
<br />
[[Image:plotSN2010FZ_plotcal_G2infa1_4.0.png|200px|thumb|right|plotcal G2 per-scan amp ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G2infa2_4.0.png|200px|thumb|right|plotcal G2 per-scan amp ant 16~26]]<br />
<br />
We do a second version of the amplitude calibration, this time using <tt>combine='scan'</tt> on field 0. This is <br />
to use for input to {{fluxscale}} in the next step.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G3', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'], \<br />
gainfield=['','','2','2','2'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='2',refant='ea04',solnorm=F,<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G3', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'],\<br />
gainfield=['','','2','2','0'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a',append=True)<br />
</source><br />
<br />
Since the flux on the gain calibrator is not scaled to its correct flux (but to 1.0 Jy by default),<br />
use {{fluxscale}} to transfer the amplitude gains from 3c286:<br />
<source lang="python"><br />
# In CASA<br />
myflux = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G3', \<br />
fluxtable='calSN2010FZ.F3inc',reference='2',transfer='0',<br />
incremental=True)<br />
</source><br />
where we have captured the returned dictionary in the Python variable <tt>myflux</tt>. We have use the<br />
<tt>incremental=True</tt> option (new to CASA 4.0) to make this table contain only the scale factors <br />
per-antenna per-spw per-field needed to scale the data (rather than rescaling the input table). Thus it<br />
can be applied in addition to our <tt>G2</tt> table even though it was derived from the <tt>G3</tt> table.<br />
<br />
The logger output gives:<br />
<pre><br />
Found reference field(s): 3C286<br />
Found transfer field(s): J0925+0019<br />
Flux density for J0925+0019 in SpW=0 (freq=4.488e+09 Hz) is: 0.977483 +/- 0.00278572 (SNR = 350.891, N = 50)<br />
Flux density for J0925+0019 in SpW=1 (freq=4.616e+09 Hz) is: 0.975972 +/- 0.00253876 (SNR = 384.429, N = 50)<br />
Flux density for J0925+0019 in SpW=2 (freq=4.744e+09 Hz) is: 0.978538 +/- 0.00242824 (SNR = 402.982, N = 50)<br />
Flux density for J0925+0019 in SpW=3 (freq=4.872e+09 Hz) is: 0.979278 +/- 0.00244155 (SNR = 401.088, N = 50)<br />
Flux density for J0925+0019 in SpW=4 (freq=5e+09 Hz) is: 0.981804 +/- 0.00219239 (SNR = 447.823, N = 50)<br />
Flux density for J0925+0019 in SpW=5 (freq=5.128e+09 Hz) is: 0.981478 +/- 0.00314805 (SNR = 311.773, N = 50)<br />
Flux density for J0925+0019 in SpW=6 (freq=5.256e+09 Hz) is: 0.985493 +/- 0.00343534 (SNR = 286.869, N = 50)<br />
Flux density for J0925+0019 in SpW=7 (freq=5.384e+09 Hz) is: 0.978491 +/- 0.00201807 (SNR = 484.865, N = 50)<br />
Flux density for J0925+0019 in SpW=8 (freq=6.744e+09 Hz) is: 0.959005 +/- 0.00260159 (SNR = 368.623, N = 48)<br />
Flux density for J0925+0019 in SpW=9 (freq=6.872e+09 Hz) is: 0.955123 +/- 0.00262785 (SNR = 363.462, N = 48)<br />
Flux density for J0925+0019 in SpW=10 (freq=7e+09 Hz) is: 0.954202 +/- 0.00281227 (SNR = 339.3, N = 48)<br />
Flux density for J0925+0019 in SpW=11 (freq=7.128e+09 Hz) is: 0.950797 +/- 0.00354085 (SNR = 268.522, N = 48)<br />
Flux density for J0925+0019 in SpW=12 (freq=7.256e+09 Hz) is: 0.94732 +/- 0.00391511 (SNR = 241.965, N = 48)<br />
Flux density for J0925+0019 in SpW=13 (freq=7.384e+09 Hz) is: 0.939356 +/- 0.00383532 (SNR = 244.922, N = 48)<br />
Fitted spectrum for J0925+0019 with fitorder=1: Flux density = 0.968048 +/- 0.00159415 (freq=5.74863 GHz) <br />
spidx=-0.0721976 +/- 0.00943577<br />
...<br />
</pre><br />
You may see slightly different numbers on your machine (and will see more extensive output). Note that "N" here is the number of antennas x the number of polarizations used for the calculations; in this case, there are 24 unflagged antennas and 2 polarizations. As of CASA 4.0, {{fluxscale}} now returns a fitted spectral index (and possibly curvature, e.g. if fitorder>1), which can be input to {{setjy}} if you want to use these derived fluxes for a model. <br />
<br />
As it so happens, the derived flux for J0925+0019 is about 1 Jy (you can plot up the raw amplitudes for fields 0,2 and convince yourself this is indeed true and not a bug). The spectrum rises a bit to peak in spw 6 then falls again. We will not use the fitted spectrum (setjy does not yet take fitorder>1) but will apply a incremental table in subsequent processing.<br />
<br />
== Applying the Calibration and Final Editing ==<br />
<br />
Next we actually apply all our accumulated calibration tables. We apply these to the <br />
calibration fields individually using the appropriate gainfields and interpolation for each:<br />
* For 3C286 (field 2) we did short-timescale phase solutions and a single scan amplitude, so use "linear" and "nearest" interpolation respectively.<br />
* For the nearby gain calibrator (field 0) we did only scan-based phase and amplitude solutions so we use "nearest" interpolation<br />
* For the target source we use field 0 to calibrate field 1, so use "linear" interpolation. This takes a few minutes.<br />
<br />
[[Image:plotSN2010FZ_plotms_applied_fld2.png|200px|thumb|right|plotms of 3C286 with calibration applied]]<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1int','calSN2010FZ.G2'], \<br />
gainfield=['','','','','2','2'],<br />
interp=['','','nearest','nearest','nearest','nearest'], \<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1int','calSN2010FZ.G2',<br />
'calSN2010FZ.F3inc'], \<br />
gainfield=['','','','','0','0','0'],<br />
interp=['','','nearest','nearest','nearest','nearest',''], \<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1inf','calSN2010FZ.G2',<br />
'calSN2010FZ.F3inc'], \<br />
gainfield=['','','','','0','0','0'],<br />
interp=['','','nearest','nearest','linear','linear',''], \<br />
parang=False,calwt=False)<br />
</source><br />
Because we used <tt>usesratch=False</tt> in {{setjy}}, the <tt>CORRECTED_DATA</tt> scratch column will be created the first time you run {{applycal}}. This will store the calibrated data.<br />
<br />
We can examine the corrected data on 3c286 using our RFI mask from above and avoiding band edges<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
See figure above right. There is clearly discrepant data visible spw 5 and 6, in particular for baseline ea17&ea25 (use the '''Mark Regions''' [[Image:MarkRegionsButton.png]] tool on some of it and then use the '''Locate''' [[File:casaplotms-locate-tool.png]] tool), which gives a really strange response. You can plot just this baseline to be sure:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='ea17&ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
You can exclude this through antenna negation:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='!ea17&ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Then use '''Locate''' [[File:casaplotms-locate-tool.png]] for the other bad points, which seem to indicate spw 5,6,7 for ea14,ea16,ea17,ea25.<br />
Exclude these and replot:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='!ea14;!ea16;!ea17;!ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld2.png|200px|thumb|right|plotms cal applied flagged fld2]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld2_phase.png|200px|thumb|right|plotms cal applied flagged fld2 phase]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_amp.png|200px|thumb|right|plotms cal applied flagged fld0 amp]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_phase.png|200px|thumb|right|plotms cal applied flagged fld0 phase]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_amp_exc_4.0.png|200px|thumb|right|plotms cal applied flagged fld0 amp, with new spw selection]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_ampavg_4.0.png|200px|thumb|right|plotms cal applied flagged fld0 amp averaged]]<br />
<br />
This now looks clean except for the RFI in the upper subbands.<br />
<br />
Do flagging based on these:<br />
<source lang="python"><br />
# In CASA<br />
flaglist2 = ['antenna="ea14,ea16,ea17,ea25" spw="5~7"']<br />
flagcmd(vis='SN2010FZ_flagged10s.ms',inpmode='list',inpfile=flaglist2,action='apply')<br />
</source><br />
<br />
Now replot the corrected data (you may have to force reload if you plotted same thing right before this):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Looks pretty good.<br />
<br />
Plot the phase:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
Note the characteristic "bowtie" pattern of the phases about the sub-band centers.<br />
Here we can see the effect of the EVLA "delay clunking", where the delay steps through discrete values such that<br />
the phase goes from -11deg to +11deg across the sub-band as the delay changes due to geometry. This is D-configuration so the delays change slowly, it will change faster in wider configurations. As of Q3 2011 we have not enabled the corrections for this in the EVLA system so you will always have this remaining delay error in your data. In principle, you could solve for delays on short timescales and take this out; in practice, this in not possible for your weaker science target source (where it would matter most for results).<br />
<br />
Now let's plot the corrected data amplitude for the phase calibrator (field 0):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
You can see the bandpass filter roll-off increasing the noise at the baseband edges (about 8-16 channels worth). Also, we can see some RFI we missed:<br />
* <6804 MHz spw 8 below ch 30 lots of bad stuff (a lot from ea18,ea22 but others too)<br />
* 7168 MHz spw 11 ch 20<br />
* pretty much all of spw 12,13<br />
The ch 20 ones are all harmonics of a notorious 128 MHz tone. NOTE: You can get the frequency of a RFI feature by looking at the logger report from using the '''Locate''' [[File:casaplotms-locate-tool.png]] tool.<br />
<br />
We will not flag these, but exclude them in imaging (so that more advanced students can try flagging these in detail or using auto-flagging). A good channel selection string for imaging might be:<br />
<br />
<pre><br />
spw = '0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59'<br />
</pre><br />
<br />
Without further flagging, it may be best to drop spw 12-13 for imaging (we will do so from now on).<br />
<br />
Plot again (including this selection for spw 0-11):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Looks better.<br />
<br />
Now plot amplitudes for the corrected data averaged over baseline to see the source spectrum:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0',<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59',<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
The "custom" plotting parameters show how to control the symbol shape and size from the task.<br />
<br />
The last two sub-bands spw 12-13 give reasonable values, with only a tiny offset from spw 8-11.<br />
There are also strange amplitude excursions, particularly in the low end of the first baseband. These must be coming<br />
from one or more scans. You can iterate over scan to see the strange amplitudes (mostly from scan 7):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0',<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59',<br />
correlation='RR,LL',avgbaseline=True,avgtime='600s',iteraxis='scan',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
<br />
Also, there is an offset with the amplitudes for spw 6, perhaps due to the problem with baseline ea17&ea25 (which we flagged, but didn't recalibrate afterward) and likely affected the {{fluxscale}} solution. This is troubling enough that we will quickly go through a second round of calibration.<br />
<br />
== A Quick Recalibration ==<br />
<br />
We now go back and recalibrate the data. We may as well flag scan 7 first, as well:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='SN2010FZ_flagged10s.ms', scan='7')<br />
#<br />
# Clear the corrected data and model from header<br />
clearcal('SN2010FZ_flagged10s.ms',addmodel=False)<br />
#<br />
chanStr = '0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59'<br />
#<br />
mysetjy2 = setjy(vis='SN2010FZ_flagged10s.ms', field='2', scalebychan=True, modimage='3C286_C.im')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G0.2',field='2',spw='0~11:23~28',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve'],<br />
gaintype='G',refant='ea04',calmode='p',solint='int',minsnr=3)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.K0.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.G0.2'],<br />
field='2', spw=chanStr, gaintype='K',<br />
refant='ea04', combine='scan', solint='inf', minsnr=3)<br />
#<br />
bandpass(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.B0.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.G0.2','calSN2010FZ.K0.2'],<br />
field='2',refant='ea04',solnorm=False,<br />
spw='0~11', <br />
bandtype='B', combine='scan', solint='inf')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2int',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='2',refant='ea04',solnorm=F, <br />
spw=chanStr,<br />
solint='int',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2int',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='int',gaintype='G',calmode='p',append=True)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2inf',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','2'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='2',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','0'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',gaintype='G',calmode='a',append=True)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.3',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','2'],<br />
interp=['','','nearest','nearest','nearest'],<br />
field='2',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.3',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','0'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a',append=True)<br />
#<br />
myflux2 = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G2.3',<br />
fluxtable='calSN2010FZ.F2.3inc',reference='2',transfer='0',<br />
incremental=True)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='2',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2'],<br />
gainfield=['','','','','2','2'],<br />
interp=['','','nearest','nearest','linear','nearest'],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3inc'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','nearest','nearest',''],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2inf','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3inc'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','linear','linear',''],<br />
parang=False,calwt=False)<br />
</source><br />
<br />
Note that we have set the variable <tt>chanStr</tt> for our channel selection; this makes the task commands shorter and easier to read.<br />
<br />
The {{fluxscale}} output this time around is slightly different to the last:<br />
<pre><br />
Found reference field(s): 3C286<br />
Found transfer field(s): J0925+0019<br />
Flux density for J0925+0019 in SpW=0 (freq=4.488e+09 Hz) is: 0.978946 +/- 0.00284837 (SNR = 343.686, N = 50)<br />
Flux density for J0925+0019 in SpW=1 (freq=4.616e+09 Hz) is: 0.978634 +/- 0.00264066 (SNR = 370.602, N = 50)<br />
Flux density for J0925+0019 in SpW=2 (freq=4.744e+09 Hz) is: 0.980438 +/- 0.00251668 (SNR = 389.575, N = 50)<br />
Flux density for J0925+0019 in SpW=3 (freq=4.872e+09 Hz) is: 0.980116 +/- 0.00255481 (SNR = 383.636, N = 50)<br />
Flux density for J0925+0019 in SpW=4 (freq=5e+09 Hz) is: 0.982175 +/- 0.00230804 (SNR = 425.545, N = 50)<br />
Flux density for J0925+0019 in SpW=5 (freq=5.128e+09 Hz) is: 0.979574 +/- 0.00269688 (SNR = 363.225, N = 42)<br />
Flux density for J0925+0019 in SpW=6 (freq=5.256e+09 Hz) is: 0.980193 +/- 0.00271312 (SNR = 361.279, N = 42)<br />
Flux density for J0925+0019 in SpW=7 (freq=5.384e+09 Hz) is: 0.98102 +/- 0.00249166 (SNR = 393.721, N = 42)<br />
Flux density for J0925+0019 in SpW=8 (freq=6.744e+09 Hz) is: 0.962693 +/- 0.00282815 (SNR = 340.397, N = 48)<br />
Flux density for J0925+0019 in SpW=9 (freq=6.872e+09 Hz) is: 0.960313 +/- 0.00285418 (SNR = 336.459, N = 48)<br />
Flux density for J0925+0019 in SpW=10 (freq=7e+09 Hz) is: 0.957056 +/- 0.00303716 (SNR = 315.116, N = 48)<br />
Flux density for J0925+0019 in SpW=11 (freq=7.128e+09 Hz) is: 0.953964 +/- 0.00378326 (SNR = 252.154, N = 48)<br />
Flux density for J0925+0019 in SpW=12 is: INSUFFICIENT DATA <br />
Flux density for J0925+0019 in SpW=13 is: INSUFFICIENT DATA <br />
Fitted spectrum for J0925+0019 with fitorder=1: Flux density = 0.973376 +/- 0.00118872 (freq=5.52174 GHz) <br />
spidx=-0.0573991 +/- 0.00778736201<br />
</pre><br />
<br />
The source spectrum plot now looks somewhat better:<br />
<br />
[[Image:plotSN2010FZ_plotms_reproc_fld0_ampavg_4.0.png|200px|thumb|right|plotms recalibrated applied flagged fld0 amp averaged]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
As you see in the figure to the right, there are still spectral window to window variations that deviate from a smooth spectrum. This is due to noise in the {{fluxscale}} median filter now used in CASA 4.0 (in this well-calibrated case, the old weighted means used by {{fluxscale}} in CASA3.4 behaved better). If we use {{plotcal}} to plot the solutions versus antenna<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G2.3',xaxis='antenna',yaxis='amp',field='0',<br />
subplot=211,plotrange=[-1,-1,0.9,1.1])<br />
plotcal(caltable='calSN2010FZ.G2.3',xaxis='antenna',yaxis='amp',field='2',<br />
subplot=212,plotrange=[-1,-1,0.9,1.1],figfile='plotSN2010FZ_plotcal_G2.3_ampant.png')<br />
</source><br />
we see that there are variations that will enter into the medians. Some antennas are better behaved than others, for example ea12 (index 10) seems better than most.<br />
<br />
[[Image:plotSN2010FZ_plotcal_G2.3_ampant.png|200px|thumb|right|plotcal of G2.3 table, showing variation of solutions per antenna]]<br />
[[Image:screenshotPlotSN2010FZ_plotcal_fluxedit3_ea12.png|200px|thumb|right|plotcal of G2.3.ea12 table, marking all solutions but those for ea12 for flagging]]<br />
[[Image:screenshotPlotSN2010FZ_plotms_recalibrated3_EA12_fld0_amp_4.0.png|200px|thumb|right|plotms for fld 0 after application of F2.3.ea12 table]]<br />
Because we are applying an incremental correction for the flux scale, we have the latitude to change the caltable that goes into {{fluxscale}} to get a better result. For example, we can restrict the antennas that are used to derive the scale. Although there is not yet antenna selection in {{fluxscale}} itself, we can edit the caltable using {{plotcal}}. For example, make a copy of the G2.3 caltable and select only a single antenna:<br />
<source lang="python"><br />
# In CASA<br />
os.system('cp -rf calSN2010FZ.G2.3 calSN2010FZ.G2.3.ea12')<br />
plotcal(caltable='calSN2010FZ.G2.3.ea12',xaxis='antenna',yaxis='amp')<br />
</source><br />
In the plot to the right we show the GUI where we have boxed all but antenna ea12.<br />
Now we carry on with the {{fluxscale}} and {{applycal}}:<br />
<source lang="python"><br />
# In CASA<br />
myfluxEdit3 = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G2.3.ea12',<br />
fluxtable='calSN2010FZ.F2.3.ea12',reference='2',transfer='0',<br />
incremental=True)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3.ea12'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','nearest','nearest',''],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2inf','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3.ea12'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','linear','linear',''],<br />
parang=False,calwt=False)<br />
</source><br />
The results appear better:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
Note that if you choose a different antenna than ea12 to use for this, you will get<br />
different results, usually worse. But this procedure illustrates how to use the<br />
incremental solutions from {{fluxscale}} to your possible advantage.<br />
<br />
We now return to examining our calibration.<br />
<br />
We can also plot the corrected phase - looks good:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
<br />
We can average over baseline and each scan:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='600s',<br />
xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_phaseavg.png|200px|thumb|right|plotms cal applied flagged fld0 phase averaged]]<br />
<br />
In this case, we can see the residual effect of the EVLA "delay clunking" described above, but it is reduced due to the averaging that we applied, but it is still there.<br />
<br />
You can look at the target source field='1', but there are lots of data so you will need to do a lot of averaging.<br />
For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='1',avgtime='300s', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Alas, the upper baseband still has lots of low level RFI.<br />
<br />
Now split off the data for calibrators and target, to avoid later issues that can corrupt the MSs. We don't keep spw 12-15, since they weren't included in the last round of calibration, and we don't plan to image them.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_split10s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_split10s.ms', \<br />
datacolumn='corrected',field='1',spw='0~11')<br />
#<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_3c28610s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_3c28610s.ms', \<br />
datacolumn='corrected',field='2',spw='0~11')<br />
#<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_J092510s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_J092510s.ms', \<br />
datacolumn='corrected',field='0',spw='0~11')<br />
</source><br />
<br />
== Imaging ==<br />
<br />
This is EVLA D-configuration data at C-band. To determine the best parameters for imaging, it helps to start with the relevant information in the [http://evlaguides.nrao.edu/index.php?title=Observational_Status_Summary_-_Current Observational Status Summary]:<br />
<br />
* Synthesized beam should be 12" at 6 GHz with primary beam field of view of 7.5 arcmin (450")<br />
<br />
Our data spans 4.5-7.5 GHz: this is a relatively large fractional bandwidth, resulting in substantial variation of the field of view over the entire frequency range. FOV = 45 arcmin / Frequency (GHz), giving 10 arcmin at 4.5 GHz, and 6 arcmin at 7.5 GHz. Likewise, the synthesized beam ranges from 16" at 4.5 GHz to 9.6" at 7.5 GHz. We want to subsample the synthesized beam by a factor of 3-4, so will use a cellsize of 3". To cover the full FOV (keeping it at the inner part of the image) at the lowest frequencies, we will want an image size of >400 pixels, or >20 arcmin.<br />
<br />
We will also use the Briggs robust (with <tt>robust=0.5</tt>) weighting, which is a compromise between uniform and natural weighting,<br />
and will give reasonable resolution but will allow us to still see larger scale structure.<br />
<br />
Due to the numerology of [http://www.fftw.org/ FFTW's] (which {{clean}} uses under the hood for FFTs) optimal sizes, <br />
<tt>imsize</tt> should be composite number with two and only two prime factors chosen from<br />
2, 3, and 5. Taking into account the x1.2 padding that clean uses internally to the imsize<br />
you give it (and 1.2 = 2*3/5), we choose 640 or 1280 as our imsize (640 = 2^7*5). Other<br />
reasonable sets would be 405, 1215, etc. (405 = 3^4*5) or 432, 648, 1296 (these are 2^n*3^m*5).<br />
In practice, if you give it non-optimal values for imsize, you may find that the transforms<br />
take a bit longer, which is noticeable if you are doing interactive clean.<br />
<br />
WARNING: By default, a single-field nterms=1 clean does NOT use Cotton-Schwab (CS) clean to break<br />
into major cycles going back to data residuals, it just does cleaning in a bunch of minor<br />
cycles in the image plane. This can give much poorer imaging quality in cases with poor<br />
uv coverage (snapshots) or in the case of complex emission structure (like ours) -- clean tends to<br />
diverge in this case. You should explicitly set <tt>imagermode='csclean'</tt> in your<br />
call to clean. Also, in our case the psf is very good using mfs, so by default it will not<br />
take many major cycle breaks. We use the <tt>cyclefactor</tt> parameter to control this, which<br />
sets the break threshold to be cyclefactor times the max psf sidelobe level (outside the main<br />
peak). We start at <tt>cyclefactor=1.5</tt> in a single spw, and ratchet it up to 4.5 when we<br />
clean all the spw. This seems to work ok. Rule of thumb is if it is gobbling up many hundreds of<br />
clean iterations in the minor cycles early on, increase cyclefactor. Conversely, if your psf is poor<br />
but you source structure is simple, you can reduce cyclefactor (e.g. below 1) to stop it from taking<br />
lots of extra major cycles.<br />
<br />
For more information on using {{clean}}, in particular on using the interactive GUI, see<br />
[[EVLA_Continuum_Tutorial_3C391_CASA_4.2#Imaging]]. WARNING: In CASA 4.0 the GUI interface for clean <br />
and the viewer has changed slightly. Some of the screenshots shown below may differ slightly <br />
from what you see.<br />
<br />
NOTE: If you are pressed for time, then you might want to jump ahead to<br />
[[EVLA_6cmWideband_Tutorial_SN2010FZ_CASA_4.2#Cleaning_the_lower_baseband_using_two_MFS_Taylor_terms]] <br />
and while it is cleaning you can read the other Imaging descriptions.<br />
<br />
=== Cleaning a single spectral window ===<br />
<br />
Let us start by interactively cleaning one of the lower baseband spw (spw 5 in this example).<br />
NOTE: this first time will take a few minutes at start to create scratch columns<br />
in the MS in case we want to do self-calibration later.<br />
<br />
'''Note that interrupting {{clean}} by Ctrl+C may corrupt your visibilities -- you may be better off choosing to let {{clean}} finish. We are currently implementing a command that will nicely exit to prevent this from happening, but for the moment try to avoid Ctrl+C.'''<br />
<br />
[[Image:viewSN2010FZ_spw5_clean640_4.0.png|200px|thumb|right|interactive clean spw5 640x640 after around 1000 iterations]]<br />
[[Image:viewSN2010FZ_spw5_clean1280.png|200px|thumb|right|2nd interactive clean spw5 1280x1280 before cleaning]]<br />
[[Image:viewSN2010FZ_spw5_clean1280final_4.0.png|200px|thumb|right|viewer showing clean spw5 1280x1280 restored image]]<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw5_clean640*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='5:4~59', \<br />
imagename='imgSN2010FZ10s_spw5_clean640', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[640,640],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
* Start carefully by boxing the bright source and setting iterations to 10 at first<br />
* Gradually add more boxes and increase the number of iterations<br />
* Since this is not much more than a snapshot you see the six-fold sidelobe pattern<br />
of the extended emission in the center of the map. This decreases as you clean<br />
out this emission.<br />
* Stop cleaning when the residuals look like noise (and you cannot clearly see sources).<br />
* To stop, click the red [[File:clean-stop.png]] button.<br />
<br />
The top figure to the right shows a zoom in on the end state of the clean, where<br />
we have marked a number of boxes and cleaned them out.<br />
<br />
Note that there are some strange sidelobe patterns in lower left, possibly <br />
from a source outside the image area. We can make a bigger image starting from<br />
our current model:<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw5_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='5:4~59', \<br />
imagename='imgSN2010FZ10s_spw5_clean1280', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
modelimage='imgSN2010FZ10s_spw5_clean640.model', \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
Sure enough, there is a bright source near the lower left (see middle panel at right). <br />
Box it, clean it a bit, and look again. There is a second source in the mid-left (track<br />
it down by its sidelobes). Box this one, clean it a bit, and when satisfied stop.<br />
<br />
You can use the CASA {{viewer}} to display the images that {{clean}} creates. If you need more guidance<br />
on using the viewer, see the [http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html CASA Viewer Demo] video<br />
(note that this is for a much earlier version of the viewer, and the interface has changed since then). <br />
<br />
Bring up your restored image directly:<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw5_clean1280.image')<br />
</source><br />
<br />
The restored image is shown in the bottom panel to the right. I have chosen the Grayscale1 instead of default color<br />
map as I prefer "Grayscale" to false color "Rainbow" for assessing image quality. Also, you can change the scaling of the image using the "scaling power cycles" slider under "basic settings".<br />
<br />
Check the rms of the residuals using the {{imstat}} task:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw5_clean1280.residual')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
In this particular case, it's 31.8 uJy; yours will likely be slightly different.<br />
<br />
=== Cleaning the lower baseband ===<br />
<br />
[[Image:viewSN2010FZ_spw0to7_clean1280final.png|200px|thumb|right|clean spw0-7 restored image center]]<br />
Now, image the entire lower baseband (spw 0-7).<br />
Follow same iterative procedure as before, and get the best<br />
residuals you can without "cleaning the noise". <br />
<br />
* Because of the bandwidth and frequency synthesis, the sidelobe pattern is different than before and it is much easier to see fainter emission.<br />
* Be careful cleaning sources that lie near or on sidelobe splotches.<br />
* Clean the central emission region way down first to reduce the sidelobe level before adding components in the sidelobe areas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to7_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='0:16~59,1~6:4~59,7:4~54', \<br />
imagename='imgSN2010FZ10s_spw0to7_clean1280', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to7_clean1280.residual')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this run, the rms is 11.3 uJy (and there is clearly some structure left in the residual). To the right is a zoom-in on the center of the restored image.<br />
<br />
==== Cleaning the lower baseband using two MFS Taylor terms ====<br />
<br />
The mfs nterms=2 option creates two "Taylor Term" images - an average intensity image (with suffix <tt>.image.tt0</tt>) <br />
and a spectral slope image (with suffix <tt>.image.tt1</tt>) which is intensity x alpha (where alpha is spectral index).<br />
For convenience there is a spectral index image (with suffix <tt>.image.alpha</tt>). These Taylor expansions are with respect to the "Reference Frequency" of the image (by default the center frequency of the spw selected, but can be specified using the <tt>reffreq</tt> parameter in {{clean}}). The convention for spectral index alpha is that<br />
<br />
<math><br />
S \propto \nu^\alpha<br />
</math><br />
<br />
so negative spectral indexes indicate a "steep" spectrum (falling with frequency).<br />
<br />
[[Image:viewSN2010FZ_spw0to7_mfs2clean.png|200px|thumb|right|clean spw0-7 mfs nterms=2 in progress]]<br />
Let's try using multi-frequency synthesis with nterms=2 on the lower baseband.<br />
The dirty beam will have lower sidelobes so we turn up <tt>cyclefactor</tt> for <tt>csclean</tt> a bit. Note: if you're feeling a bit lazy, and trust your previous set of clean boxes, you can also set <tt>mask='imgSN2010FZ10s_spw0to7_clean1280.mask'</tt> to use these as a starting point:<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to7_mfs2_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='0:16~59,1~6:4~59,7:4~54', \<br />
imagename='imgSN2010FZ10s_spw0to7_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
weighting='briggs',robust=0.5,interactive=True,mask=[])<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to7_mfs2_clean1280.residual.tt0')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this run, the rms is 10.5 uJy (somewhat better-looking than the nterms=1).<br />
The top screenshot to the right shows an intermediate but early stage of cleaning where we are looking at<br />
the central emission and cleaning it out slowly.<br />
<br />
You can use the {{viewer}} to load the average intensity image:<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0')<br />
</source><br />
<br />
and then use the Open Data panel to load the spectral index image <tt>imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha</tt><br />
which can then be blinked (optionally plotted side-by-side using the Panel Display Options panel to set 2 panels in the x direction). <br />
<br />
[[Image:viewSN2010FZ_spw0to7_mfs2loadalpha_4.0.png|200px|thumb|right|clean spw0-7 mfs nterms=2 load alpha with LEL]]<br />
[[Image:viewSN2010FZ_spw0to7_mfs2panelalpha_4.0.png|200px|thumb|right|clean spw0-7 mfs nterms=2 tt0 and alpha (filtered at 0.1mJy in tt0)]]<br />
<br />
Note there is a lot of noise in alpha in the low-intensity regions, and thus filtering the alpha image based on the values in the tt0 image is desirable. You can use the {{immath}} task to make this filtered alpha image explicitly, using a <br />
Lattice Expression Language (LEL) expression: <br />
<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename=['imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha', <br />
'imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM1>1.0E-4]',<br />
outfile='imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha.filtered')<br />
</source><br />
<br />
This will use 0.1 mJy (or 10 x the sigma we found) as the cutoff.<br />
You can then view or manipulate the filtered alpha image as normal.<br />
<br />
We can also use LEL to filter the alpha image on the intensity on-the-fly when we load this raster in the Open Data panel<br />
by specifying a LEL string in the LEL box instead of selecting the image from the directory <br />
listing. The LEL string:<br />
<br />
<pre><br />
'imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha'['imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0'>1.0E-04]<br />
</pre><br />
<br />
will replicate what we did above. The middle figure to the right shows the Open Data panel<br />
with our LEL string in it. Just click the Raster button to load this.<br />
<br />
The lower panel to the right shows the intensity and LEL-filtered alpha images side-by-side in the viewer, zoomed<br />
in on the galaxy emission. Mousing over the alpha shows spectral indexes ranging from -1 to +1 in the center, with<br />
the brightest emission with alpha -0.7 in the knots in the disk.<br />
<br />
=== Cleaning using both basebands combined ===<br />
<br />
For the ultimate image, use the "clean" part of the upper baseband in addition<br />
to the lower (use spw 0-11). We will use mfs with nterms=2 (if you try nterms=1 <br />
on this wide bandwidth you will get much poorer residuals). Because of the added<br />
work and extra data involved, this will take much longer than our other runs of<br />
clean. Therefore, we will get a head start by doing a non-interactive clean using<br />
the mask left from the previous clean (spw 0-7). We will insert a clean threshold<br />
to limit runaway cleaning too far beneath the noise level. <br />
<br />
This will take a while, especially if there are other processes running on your machine (with nothing else running, expect ~30-40 minutes).<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
imagename='imgSN2010FZ10s_spw0to11_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=3000,gain=0.1,threshold='0.002mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
mask=['imgSN2010FZ10s_spw0to7_mfs2_clean1280.mask'], \<br />
weighting='briggs',robust=0.5,interactive=False)<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.residual.tt0')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this particular run, the rms was 8.9 uJy (noticeably better than the lower baseband only results).<br />
<br />
[[Image:viewSN2010FZ spw0to11_mfs2resid.png|200px|thumb|right|final residual and mask]]<br />
<br />
Let us see if there is more to clean. Bring this up in interactive mode:<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='SN2010FZ_split10s.ms', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
imagename='imgSN2010FZ10s_spw0to11_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=3000,gain=0.1,threshold='0.001mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
mask='imgSN2010FZ10s_spw0to11_mfs2_clean1280.mask', \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
This should start cleaning from where our previous non-interactive clean left off.<br />
<b>Note for 4.2.0:</b> In this case we have specified <tt>mask='imgSN2010FZ10s_spw0to11_mfs2_clean1280.mask'</tt> explicitly due to a bug where it will not otherwise allow you to edit the mask interactively.<br />
<br />
You might find a few more sources revealed in the outer parts of the image, and also more <br />
emission around the galaxy disk in the center. Try drawing new boxes, perhaps extend the box<br />
in the center, and do ~100-1000 more iterations. At the end, what is left should be dominated<br />
by the error patterns from mis-calibration. Only self-calibration will get rid of<br />
these. Stop cleaning for now. See the figure to the right for the interactive display panel<br />
showing final residuals and mask (changing the colormap to <tt>Greyscale 1</tt>).<br />
<br />
Check the residual levels:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.residual.tt0')<br />
sigma = mystat['sigma'][0]<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
The final rms achieved here is 8.7 uJy; slightly better.<br />
<br />
== Analyzing the image ==<br />
<br />
Let's see how close we got to expected noise and dynamic range:<br />
<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0')<br />
peak = mystat['max'][0]<br />
print 'Image max flux = '+str(mystat['max'][0])<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.model.tt0')<br />
total = mystat['sum'][0]<br />
print 'Model total flux = '+str(mystat['sum'][0])<br />
#<br />
snr = peak/sigma<br />
print 'SN2010FZ peak S/N = '+str(snr)<br />
#<br />
snr = total/sigma<br />
print 'SN2010FZ total S/N = '+str(snr)<br />
</source><br />
The output gives:<br />
<pre><br />
Residual standard deviation = 8.74577600158e-06<br />
Image max flux = 0.00993354152888<br />
Model total flux = 0.0341279412654<br />
SN2010FZ peak S/N = 1135.81019307<br />
SN2010FZ total S/N = 3902.2199127<br />
</pre><br />
These are the numbers I got in my run-through. You may get slightly different values depending on how deeply you cleaned.<br />
<br />
What do we expect? If we do {{listobs}} on this MS we see the scans:<br />
<pre><br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) <br />
11-Jul-2010/21:38:44.0 - 21:39:51.0 9 0 SN2010FZ 33696 9.16 <br />
21:40:01.0 - 21:41:20.5 10 0 SN2010FZ 37908 9.89 <br />
21:41:30.0 - 21:42:50.0 11 0 SN2010FZ 37908 10 <br />
21:43:00.0 - 21:44:20.0 12 0 SN2010FZ 37908 10 <br />
21:44:30.0 - 21:45:50.0 13 0 SN2010FZ 37908 10 <br />
21:46:00.0 - 21:47:19.5 14 0 SN2010FZ 37908 9.89 <br />
21:47:29.0 - 21:47:49.0 15 0 SN2010FZ 12636 9.67 <br />
21:49:42.0 - 21:50:49.0 17 0 SN2010FZ 33696 9.17 <br />
21:50:59.0 - 21:52:19.0 18 0 SN2010FZ 37908 10 <br />
21:52:29.0 - 21:53:48.5 19 0 SN2010FZ 37908 9.89 <br />
21:53:58.0 - 21:55:18.0 20 0 SN2010FZ 37908 10 <br />
21:55:28.0 - 21:56:48.0 21 0 SN2010FZ 37908 10 <br />
21:56:58.0 - 21:58:18.0 22 0 SN2010FZ 37908 10 <br />
21:58:28.0 - 21:58:47.5 23 0 SN2010FZ 12636 9.67 <br />
22:00:39.5 - 22:01:47.0 25 0 SN2010FZ 33696 9.18 <br />
22:01:57.0 - 22:03:17.0 26 0 SN2010FZ 37908 10 <br />
22:03:27.0 - 22:04:47.0 27 0 SN2010FZ 37908 10 <br />
22:04:57.0 - 22:06:16.5 28 0 SN2010FZ 37908 9.89 <br />
22:06:26.0 - 22:07:46.0 29 0 SN2010FZ 37908 10 <br />
22:07:56.0 - 22:09:16.0 30 0 SN2010FZ 37908 10 <br />
22:09:26.0 - 22:09:45.5 31 0 SN2010FZ 12636 9.67 <br />
22:11:38.0 - 22:12:45.5 33 0 SN2010FZ 33696 9.19 <br />
22:12:55.0 - 22:14:15.0 34 0 SN2010FZ 37908 10 <br />
22:14:25.0 - 22:15:45.0 35 0 SN2010FZ 37908 10 <br />
22:15:55.0 - 22:17:15.0 36 0 SN2010FZ 37908 10 <br />
22:17:25.0 - 22:18:44.5 37 0 SN2010FZ 37908 9.89 <br />
22:18:54.0 - 22:20:14.0 38 0 SN2010FZ 37908 10 <br />
22:20:24.0 - 22:20:43.5 39 0 SN2010FZ 12636 9.67 <br />
(nVis = Total number of time/baseline visibilities per scan) <br />
</pre><br />
(listing columns truncated) and we estimate about 37 minutes on target. We had about 25 antennas on average, and our spw selection picked out 610 channels (2 MHz each) for a total of 1220 MHz bandwidth. If we plug this<br />
into the<br />
[https://science.nrao.edu/facilities/evla/calibration-and-tools/exposure EVLA exposure calculator], at 5 GHz, we find that we expect a rms thermal noise level of 8.7 uJy, and at 7 GHz, 7.0 uJy. So, our values are within the expected range (a bit higher than theoretical, but that's expected). <br />
<br />
[[Image:plotSN2010FZ_viewerfinal.png|200px|thumb|right|final image]]<br />
Look at this in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0')<br />
</source><br />
Zoom in on the center (see figure to the right).<br />
<br />
[[Image:viewSN2010FZ_spw0to11_mfs2tt1.png|200px|thumb|right|final tt1 image with box]]<br />
In the previous section we demonstrated how to process and display the spectral index image. You can do<br />
the same for this final image. Here, we will do some rough analysis on the spectral index to determine<br />
an intensity-weighted mean spectral index over the core region.<br />
The <tt>.image.tt1</tt> from our mfs is an intensity times alpha image. See the figure to the right.<br />
Let's gate the Taylor-term images on intensity:<br />
<source lang="python"><br />
# In CASA<br />
# Removing any file output from previous runs, so immath will proceed<br />
os.system('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered')<br />
immath(imagename=['imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1',<br />
'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM1>5.0E-5]',<br />
outfile='imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered')<br />
#<br />
# Removing any file output from previous runs, so immath will proceed<br />
os.system('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered')<br />
immath(imagename=['imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM0>5.0E-5]',<br />
outfile='imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered')<br />
</source><br />
<br />
We can identify a box containing the central emission (see figure of tt1 in viewer) and note the corners.<br />
(We could also use the region tools from the viewer, but that is for another exercise.)<br />
Let us compute the intensity-weighted spectral index over this box by averaging<br />
these masked images using {{imstat}} and computing the ratio:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered',<br />
box='503,533,756,762')<br />
avgtt0alpha = mystat['mean'][0]<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered',<br />
box='503,533,756,762')<br />
avgtt0 = mystat['mean'][0]<br />
avgalpha = avgtt0alpha/avgtt0<br />
print 'SN2010FZ I-weighted Alpha = '+str(avgalpha)<br />
</source><br />
We get <br />
<pre><br />
SN2010FZ I-weighted Alpha = -1.38157453384<br />
</pre><br />
<br />
The emission in this source is on the steep side. At this point we do not know how reliable this is or<br />
what we expect (though our calibrators come out with correct spectral indexes if we image them the<br />
same way). But this illustrates a way to extract spectral information from our wideband mfs images.<br />
<br />
== Comparing with the Optical/Infrared ==<br />
<br />
As a final comparison, we turn to the Sloan Digital Sky Survey (SDSS) and a cutout image of our galaxy:<br />
[[Image:NGC_2967_UGC_5180_IRAS_09394+0033_irg.jpg|400px|thumb|center|]]<br />
from their [http://cosmo.nyu.edu/hogg/rc3/NGC_2967_UGC_5180_IRAS_09394+0033_irg.jpg RC3]<br />
album (courtesy D.Hogg, M.Blanton, SDSS collaboration - see [[#Credits]]). This looks like a nice nearby<br />
face-on spiral galaxy. How does our 6cm continuum emission line up with the optical?<br />
<br />
Here is the EVLA 6cm image side by side with a i-band image from the Sloan Digital Sky Survey (SDSS) registered to our image:<br />
<br />
[[Image:plotSN2010FZ viewerfinalandSDSS.png|600px|thumb|center|final and sdss image]]<br />
<br />
You can also find this image, named <tt>NGC_2967_UGC_5180_IRAS_09394+0033-i.fits</tt>, on the web at <tt>http://casa.nrao.edu/Data/EVLA/SN2010FZ/NGC_2967_UGC_5180_IRAS_09394+0033-i.fits</tt> (at the CASA workshop, it's in <tt>/data/casa/evla/</tt> or a similar location that will be given to you in the instructions). Load it into your viewer, and blink against our 6cm image.<br />
<br />
We can also plot one as a raster and the other overlaid as contours. You can load the SDSS image<br />
from the viewer Load Data panel and fiddle with contours. Once you know contour levels, you can<br />
also use the imview task to load a raster and contour image:<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={ 'file' : 'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'},<br />
contour = { 'file' : 'NGC_2967_UGC_5180_IRAS_09394+0033-i.fits',<br />
'levels' : [0.2, 0.5, 1, 1.5, 3],<br />
'base' : 0.0,<br />
'unit' : 1.0 } )<br />
</source><br />
<br />
The figure below shows the SDSS contours overlaid on our 6cm image (after fiddling with the <br />
colormap shift/slope for the EVLA raster image). <br />
<br />
[[Image:viewSN2010FZ_spw0to11_mfs2tt0plusSDSS.png|400px|thumb|center|6cm EVLA raster plus SDSS i-band contours]]<br />
<br />
Likewise, we can plot the SDSS image as a raster and overlay EVLA 6cm contours:<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={ 'file' : 'NGC_2967_UGC_5180_IRAS_09394+0033-i.fits',<br />
'scaling' : -2.0,<br />
'range' : [0,10] },<br />
contour = { 'file' : 'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0',<br />
'levels' : [0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56],<br />
'base' : 0.0,<br />
'unit' : 0.001 },<br />
zoom = { 'blc' : [397,300],<br />
'trc' : [1567,1231] } )<br />
</source><br />
<br />
This is shown in the figure below. Is the compact 6cm emission in upper left associated with a<br />
spiral arm?<br />
<br />
[[Image:viewSN2010FZ_spw0to11_SDSSiplusEVLA6cm.png|400px|thumb|center|SDSS i-band raster plus EVLA 6cm contours]]<br />
<br />
== What to do next: some exercises for the user ==<br />
<br />
Here are a number of things you can try after completing this tutorial:<br />
<br />
# Use self-calibration to improve the data and re-clean to make a better image. See [http://casaguides.nrao.edu/index.php?title=WorkshopSelfcal_(Caltech) this tutorial] for more information on self-calibration.<br />
# Use multi-scale clean by adding non-zero scales to the <tt>multiscale</tt> parameter.<br />
# Image the calibrators. What sort of dynamic range can you get on them? Is self-calibration needed (and if so what dynamic range do you get when you use it)?<br />
# Try the <tt>testautoflag</tt> task (in 3.3.0 and later) to automatically flag RFI from the upper sideband. There is more information on running <tt>testautoflag</tt> in [http://casaguides.nrao.edu/index.php?title=EVLA_Wide-Band_Wide-Field_Imaging:_G55.7_3.4 this tutorial].<br />
<br />
== Credits ==<br />
<br />
The EVLA data was taken by A. Soderberg et al. as part of project AS1015. See <br />
[https://science.nrao.edu/enews/3.8/index.shtml#evlanoise NRAO eNews 3.8] (1-Sep-2010) for more on this result.<br />
<br />
<blockquote><i><br />
The Expanded Very Large Array (EVLA) is a partnership of the United States, Canada, and Mexico. The EVLA is funded in the United States by the National Science Foundation, in Canada by the National Research Council, and in Mexico by the Comisión Nacional de Investigación CientÃfica y Tecnológica (CONICyT).<br />
</i></blockquote><br />
<br />
<blockquote><i><br />
The National Radio Astronomy Observatory is a facility of the National Science Foundation operated under cooperative agreement by Associated Universities, Inc.<br />
</i></blockquote><br />
<br />
SDSS image courtesy David Hogg & Michael Blanton, private communication. Data comes from<br />
SDSS DR7, see [http://adsabs.harvard.edu/abs/2009ApJS..182..543A Abazajian et. al 2009].<br />
<br />
<blockquote><i><br />
Funding for the SDSS and SDSS-II has been provided by the Alfred P. Sloan Foundation, the Participating Institutions, the National Science Foundation, the U.S. Department of Energy, the National Aeronautics and Space Administration, the Japanese Monbukagakusho, the Max Planck Society, and the Higher Education Funding Council for England. The SDSS Web Site is [http://www.sdss.org/].<br />
</i></blockquote><br />
<br />
<blockquote><i><br />
The SDSS is managed by the Astrophysical Research Consortium for the Participating Institutions. The Participating Institutions are the American Museum of Natural History, Astrophysical Institute Potsdam, University of Basel, University of Cambridge, Case Western Reserve University, University of Chicago, Drexel University, Fermilab, the Institute for Advanced Study, the Japan Participation Group, Johns Hopkins University, the Joint Institute for Nuclear Astrophysics, the Kavli Institute for Particle Astrophysics and Cosmology, the Korean Scientist Group, the Chinese Academy of Sciences (LAMOST), Los Alamos National Laboratory, the Max-Planck-Institute for Astronomy (MPIA), the Max-Planck-Institute for Astrophysics (MPA), New Mexico State University, Ohio State University, University of Pittsburgh, University of Portsmouth, Princeton University, the United States Naval Observatory, and the University of Washington.<br />
</i></blockquote><br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_6cmWideband_Tutorial_SN2010FZ_CASA_4.2&diff=15567EVLA 6cmWideband Tutorial SN2010FZ CASA 4.22014-02-06T17:05:07Z<p>Smyers: </p>
<hr />
<div>This is an Advanced EVLA data reduction tutorial that calibrates and images a 6-cm wide-band continuum dataset.<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><br />
== Overview ==<br />
<br />
This article describes the calibration and imaging of a single-pointing 6-cm EVLA wideband continuum dataset of the galaxy NGC2967 (UGC5180) which was the location of the supernova candidate SN2010FZ. No supernova was detected in this observation, but the galactic continuum emission from this face-on spiral is nicely imaged. The data were taken in with 1024 MHz of bandwidth in each of two widely spaced basebands (each comprised of 8 128-MHz spectral windows), spanning 4.5 to 7.5 GHz. We will use wideband imaging techniques in this tutorial.<br />
<br />
This is a more advanced tutorial, and if you are a relative novice (and <em>particularly</em> for EVLA continuum calibration and imaging), it is <em>strongly</em> recommended that you start with the [[EVLA Continuum Tutorial 3C391]] (at least read it through) before tackling this dataset. We will not include basic information on CASA processing in this tutorial.<br />
<br />
From the [http://casaguides.nrao.edu MainPage] of this guide you can find helpful information:<br />
* [[What is CASA?]]<br />
* [[Getting Started in CASA]]<br />
* [[CASA Reference Manuals]]<br />
* [[Hints, Tips, & Tricks]]<br />
* [[AIPS-to-CASA Cheat Sheet]]<br />
<br />
In this tutorial we will be invoking the tasks as function calls. You can cut and paste these to your casapy session. We also recommend that you copy all the commands you use, with any relevant commentary, to a text file. This is good practice when tackling large datasets. If you wish, you can use the [http://casaguides.nrao.edu/index.php?title=Extracting_scripts_from_these_tutorials Script Extractor] to create a file with the tutorial commands, which can subsequently be edited as desired.<br />
<br />
Occasionally we will be setting Python variables (e.g. as lists for flags) outside the function call so make sure you<br />
set those before running the task command. Note that when you call a CASA task as a function the task parameters you<br />
do not set in the function call (assuming there is at least one) will be set to their defaults, and will not use values<br />
you set in previous calls or outside the call. See [[Getting_Started_in_CASA#Task_Execution]] for more <br />
on calling tasks and setting parameters in the scripting interface.<br />
<br />
NOTE: If you find that the figures on the right margin of the browser window overlap the text too much and make reading difficult,<br />
go ahead and widen the browser window.<br />
<br />
== Obtaining the Data ==<br />
<br />
The data for this tutorial were taken with the EVLA under program AS1015 as the scheduling block (SB) <tt>AS1015_sb1658169_1.55388.89474846065</tt>, and was run on 2010-07-11 from 21:28 to 22:28 UT (size 37.74GB). <br />
<br />
The data can be directly downloaded from [http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz] (dataset size: 2.9 GB). For example, in you Linux terminal:<br />
<br />
<source lang="bash"><br />
wget http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz<br />
</source><br />
<br />
Your first step will be to unzip and untar the file in a terminal, before you start CASA:<br />
<br />
<source lang="bash"><br />
tar -xzvf SN2010FZ_10s.ms.tar.gz <br />
</source><br />
<br />
If you are brave enough, you can also get the data straight from the EVLA archive. Go to the [https://archive.nrao.edu/archive/advquery.jsp NRAO Science Data Archive], and search for project **AS1015**. Then select the <tt>AS1015_sb1658169_1.55388.89474846065</tt> dataset and choose to apply the online flags (check box "Apply flags generated during observing") and time-averaging of 10 seconds. (The data were taken in D-configuration [max baselines 1km], so one can safely average to 3s or even 10s to reduce dataset size.) Also select the tar option. This will create a file equivalent to what is used at the workshop.<br />
<br />
== Starting CASA ==<br />
<br />
{{CaltechCASAStartup}}<br />
<br />
== Examining the MS ==<br />
<br />
We use {{listobs}} to summarize our MS:<br />
<source lang="python"><br />
# In CASA<br />
listobs('SN2010FZ_10s.ms')<br />
</source><br />
<br />
In the logger you should see:<br />
<br />
<pre><br />
##########################################<br />
##### Begin Task: listobs #####<br />
<br />
================================================================================<br />
MeasurementSet Name: SN2010FZ_10s.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. Alicia M. Soderberg Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 1570726 Total integration time = 3359 seconds<br />
Observed from 11-Jul-2010/21:30:44.0 to 11-Jul-2010/22:26:43.0 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) SpwIds ScanIntent<br />
11-Jul-2010/21:30:44.0 - 21:30:52.0 2 0 J0925+0019 404 6.43 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:31:02.0 - 21:32:22.0 3 0 J0925+0019 5062 9.68 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:32:32.0 - 21:33:52.0 4 0 J0925+0019 6277 9.91 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:34:02.0 - 21:34:52.0 5 0 J0925+0019 4148 9.96 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:35:02.0 - 21:35:51.5 6 0 J0925+0019 32640 9.44 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:36:01.0 - 21:38:20.5 7 0 J0925+0019 81600 9.93 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:38:44.0 - 21:39:51.0 9 1 SN2010FZ 43520 9.16 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:40:01.0 - 21:41:20.5 10 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:41:30.0 - 21:42:50.0 11 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:43:00.0 - 21:44:20.0 12 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:44:30.0 - 21:45:50.0 13 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:46:00.0 - 21:47:19.5 14 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:47:29.0 - 21:47:49.0 15 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:48:12.0 - 21:49:18.5 16 0 J0925+0019 43520 9 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:49:42.0 - 21:50:49.0 17 1 SN2010FZ 43520 9.17 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:50:59.0 - 21:52:19.0 18 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:52:29.0 - 21:53:48.5 19 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:53:58.0 - 21:55:18.0 20 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:55:28.0 - 21:56:48.0 21 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:56:58.0 - 21:58:18.0 22 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:58:28.0 - 21:58:47.5 23 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:59:10.5 - 22:00:17.0 24 0 J0925+0019 43520 8.99 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:00:39.5 - 22:01:47.0 25 1 SN2010FZ 43520 9.18 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:01:57.0 - 22:03:17.0 26 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:03:27.0 - 22:04:47.0 27 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:04:57.0 - 22:06:16.5 28 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:06:26.0 - 22:07:46.0 29 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:07:56.0 - 22:09:16.0 30 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:09:26.0 - 22:09:45.5 31 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:10:08.0 - 22:11:15.5 32 0 J0925+0019 43520 9.13 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:11:38.0 - 22:12:45.5 33 1 SN2010FZ 43520 9.19 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:12:55.0 - 22:14:15.0 34 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:14:25.0 - 22:15:45.0 35 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:15:55.0 - 22:17:15.0 36 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:17:25.0 - 22:18:44.5 37 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:18:54.0 - 22:20:14.0 38 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:20:24.0 - 22:20:43.5 39 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:21:06.0 - 22:22:13.5 40 0 J0925+0019 42690 9.15 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:25:13.0 - 22:25:13.0 42 2 3C286 1028 2.87 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
22:25:23.0 - 22:26:43.0 43 2 3C286 47757 9.6 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
(nVis = Total number of time/baseline visibilities per scan) <br />
Fields: 3<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 D J0925+0019 09:25:07.81503 +00.19.13.9334 J2000 0 303381 <br />
1 NONE SN2010FZ 09:42:04.77000 +00.19.51.0000 J2000 1 1218560<br />
2 K 3C286 13:31:08.28798 +30.30.32.9589 J2000 2 48785 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (18 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 64 TOPO 7686 2000 128000 RR RL LR LL <br />
1 64 TOPO 7836 2000 128000 RR RL LR LL <br />
2 64 TOPO 4488 2000 128000 RR RL LR LL <br />
3 64 TOPO 4616 2000 128000 RR RL LR LL <br />
4 64 TOPO 4744 2000 128000 RR RL LR LL <br />
5 64 TOPO 4872 2000 128000 RR RL LR LL <br />
6 64 TOPO 5000 2000 128000 RR RL LR LL <br />
7 64 TOPO 5128 2000 128000 RR RL LR LL <br />
8 64 TOPO 5256 2000 128000 RR RL LR LL <br />
9 64 TOPO 5384 2000 128000 RR RL LR LL <br />
10 64 TOPO 6488 2000 128000 RR RL LR LL <br />
11 64 TOPO 6616 2000 128000 RR RL LR LL <br />
12 64 TOPO 6744 2000 128000 RR RL LR LL <br />
13 64 TOPO 6872 2000 128000 RR RL LR LL <br />
14 64 TOPO 7000 2000 128000 RR RL LR LL <br />
15 64 TOPO 7128 2000 128000 RR RL LR LL <br />
16 64 TOPO 7256 2000 128000 RR RL LR LL <br />
17 64 TOPO 7384 2000 128000 RR RL LR LL <br />
Sources: 50<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J0925+0019 0 - - <br />
0 J0925+0019 1 - - <br />
0 J0925+0019 2 - - <br />
0 J0925+0019 3 - - <br />
0 J0925+0019 4 - - <br />
0 J0925+0019 5 - - <br />
0 J0925+0019 6 - - <br />
0 J0925+0019 7 - - <br />
0 J0925+0019 8 - - <br />
0 J0925+0019 9 - - <br />
0 J0925+0019 10 - - <br />
0 J0925+0019 11 - - <br />
0 J0925+0019 12 - - <br />
0 J0925+0019 13 - - <br />
0 J0925+0019 14 - - <br />
0 J0925+0019 15 - - <br />
0 J0925+0019 16 - - <br />
0 J0925+0019 17 - - <br />
1 SN2010FZ 2 - - <br />
1 SN2010FZ 3 - - <br />
1 SN2010FZ 4 - - <br />
1 SN2010FZ 5 - - <br />
1 SN2010FZ 6 - - <br />
1 SN2010FZ 7 - - <br />
1 SN2010FZ 8 - - <br />
1 SN2010FZ 9 - - <br />
1 SN2010FZ 10 - - <br />
1 SN2010FZ 11 - - <br />
1 SN2010FZ 12 - - <br />
1 SN2010FZ 13 - - <br />
1 SN2010FZ 14 - - <br />
1 SN2010FZ 15 - - <br />
1 SN2010FZ 16 - - <br />
1 SN2010FZ 17 - - <br />
2 3C286 2 - - <br />
2 3C286 3 - - <br />
2 3C286 4 - - <br />
2 3C286 5 - - <br />
2 3C286 6 - - <br />
2 3C286 7 - - <br />
2 3C286 8 - - <br />
2 3C286 9 - - <br />
2 3C286 10 - - <br />
2 3C286 11 - - <br />
2 3C286 12 - - <br />
2 3C286 13 - - <br />
2 3C286 14 - - <br />
2 3C286 15 - - <br />
2 3C286 16 - - <br />
2 3C286 17 - - <br />
Antennas: 27:<br />
ID Name Station Diam. Long. Lat. <br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
5 ea06 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
8 ea10 N03 25.0 m -107.37.06.3 +33.54.04.8 <br />
9 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
10 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
11 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
12 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
13 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
14 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
15 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
16 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
17 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
18 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
19 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
20 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
21 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
22 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
23 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
24 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
25 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
26 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
<br />
##### End Task: listobs #####<br />
##########################################<br />
</pre><br />
<br />
This task displays a lot of information about the MS. We can see that the observation was performed with the EVLA, for a total integration of 3359 seconds (1 hour). The number of data records (1570726) is equal to the number of baselines (N_antenna * [N_antenna - 1] / 2) X the number of integrations (observing time / time-average binning) X the number of spectral windows. For this observation, this is roughly 351 baselines (27X26/2) X 360 integrations (3600s total/10s avg) X 16 spectral windows = 2021760. Note that this is high by ~30%; this is because the archive already flagged bad data, and there are some scans which only have two (rather than 16) spectral windows present. Extra exercise: examine the MS using {{browsetable}} to see what a data record looks like (equivalent to a row, as displayed by this task).<br />
<br />
The most useful parts of the {{listobs}} output are the scan, field, and spectral window listings. <br />
<br />
From the spectral window information, we can see that there were a total of 18 (0 through 17) spectral windows in this dataset. The first two of these (0 and 1) were only used to help set up the correlator. <br />
<br />
Looking at the scan listing, we can see that the first four scans which are present used only these spectral windows. These are referred to as "dummy scans". We will not be using these, since they often contain bad data. <br />
<br />
The C-band data of interest is contained in scans 6-44 and spectral windows 2 to 17. Careful examination shows that scan 8 is missing but from the time ranges that the data has been merged into scan 7. This sort of correlator back-end data-capture issue was occasionally seen during 2010. Hopefully, it will not affect our data, but we should keep an eye out for problems with scan 7. <br />
<br />
The field listing shows three sources: <br />
<br />
* J0925+0019 (also referred to by its field ID, 0), which will serve as a calibrator for the visibility phases, <br />
* SN2010FZ (1), our science target field, and <br />
* 3C286 (2), which will serve as a calibrator for the visibility amplitudes, i.e., it is assumed to have a precisely known flux density; as well as the spectral bandpass.<br />
<br />
== Flagging the MS ==<br />
<br />
The online flags, which are a record of known bad data produced by the EVLA online system, have already been applied by the archive as it generated the MS. However, it's good to have a sense of what was deleted in this process. A record of the flags is also stored in a separate table in the MS, called <tt>FLAG_CMD</tt>. (In fact, the information for this table is actually a subdirectory within the MS; you can see this by listing the contents of <tt>SN2010FZ_10s.ms</tt>.)<br />
<br />
[[Image:PlotSN2010FZ_flagcmd_3.4.png|200px|thumb|right|online flags plotted from flagcmd]]<br />
You can examine the commands stored in the <tt>FLAG_CMD</tt> table using {{flagcmd}}.<br />
<source lang="python"><br />
# In CASA<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='table',action='list')<br />
</source><br />
These will go to the logger or terminal (they appear to go to the terminal now in 4.2).<br />
<br />
You can also plot the commands stored in the <tt>FLAG_CMD</tt> table:<br />
<source lang="python"><br />
# In CASA<br />
myrows = range(285)<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='table',action='plot',tablerows=myrows)<br />
</source><br />
<br />
Note that we are only plotting the first 285 rows -- this is because the last few are from flagging zeros in the data (caused by correlator errors) and data which have been flagged due to [http://evlaguides.nrao.edu/index.php?title=Observational_Status_Summary#Shadowing_and_Cross-Talk antenna shadowing]. Note that you can not do the <tt>tablerows</tt> selection and plot those too, you will just get lines at the bottom marked as "All" antennas for these flags.<br />
<br />
This will bring up a <tt>matplotlib</tt> plotter. You can have it plot to a PNG file instead:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagcmd(vis='SN2010FZ_10s.ms', inpmode='table', action='plot', tablerows=myrows, <br />
plotfile='PlotSN2010FZ_flagcmd_4.2.png')<br />
</source><br />
<br />
The flags as plotted in the figure to the above right look normal. <br />
They are color-coded by REASON, and you see ANTENNA_NOT_ON_SOURCE flags between scans, and the occasional SUBREFLECTOR_ERROR flag also between scans (most likely after band changes when the subreflector rotates to <br />
pick up the new feed on the ring, some are slower than others). What you watch for here are long blocks of unexpected flags, which might be false alarms and cause you to flag too much data. In that case, look at the data itself in {{plotms}} (see below for examples) to decide whether or not to apply all flags.<br />
<br />
[[Image:plotSN2010FZ_plotants.png|200px|thumb|right|plotants plotter]]<br />
To plot up the antenna positions in the array:<br />
<source lang="python"><br />
# In CASA<br />
plotants('SN2010FZ_10s.ms')<br />
</source><br />
<br />
NOTE: if after this point (or any other) you get "table locks", which may occur erroneously and are sometimes triggered by plotting tasks, use {{clearstat}} to clear them:<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat<br />
</source><br />
<br />
Now we examine the MS looking for bad data to flag. We will use {{plotms}} to bring up an interactive GUI that will display 2-D Y vs.X style line plots. <b>NOTE: We do not recommend using the editing/flagging features of plotms.</b> It is very easy to mess up your data this way. Also, to improve speed we will be restricting the scope of plotting so most box/flag operations would not get rid of all the bad data. <br />
<br />
We will instead use plotms to identify bad data and then use flagcmd to flag it. This will also allow full scripting of the flagging, which is ultimately the best way to keep track of what's been deleted. Given the large dataset sizes now being generated, reproducibility is extremely important. Imaging spending a day flagging your data, then a disk error corrupts the MS. It's imperative that you have an automated way to regenerate your work. This is also why we encourage you to keep a running file with all the commands you use on a dataset.<br />
<br />
NOTE: If you need an introduction to {{plotms}}, see:<br />
* [[Data flagging with plotms]]<br />
* [[Averaging data in plotms]]<br />
* [[What's the difference between Antenna1 and Antenna2? Axis definitions in plotms]]<br />
<br />
WARNING: The '''Flag''' [[Image:FlagThoseData.png]] button on the plotms GUI is close to other buttons you will be using, in particular the one that gets rid of boxes you have drawn. Be careful and don't hit the '''Flag''' button by mistake!<br />
<br />
As we found above, the useful spectral windows are 2-17. To get an idea of the data layout, plot a single baseline (ea01&ea02) and channel (31, for all spectral windows) versus time:<br />
<br />
[[Image:screenshotPlotSN2010FZ_plotms_ants1_4.0.png|200px|thumb|right|plotms ea01&ea02 amp vs time]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='',spw='2~17:31~31', \<br />
antenna='ea01&ea02',correlation='RR,LL',xaxis='time',yaxis='amp')<br />
</source><br />
<br />
Here, we can see the alternating phase calibration and science target scans, as well as the (brighter) flux calibrator at the end of the observation. Feel free to play with ways to view, or color the data: for example, go to the "Display" left-hand tab, and choose "Colorize by: Field". You can also change the size of the plotted points, if they are too small to see easily, by setting "Unflagged Points Symbol" to "Custom" and increasing the number of pixels under "Style".<br />
<br />
[[Image:screenshotPlotSN2010FZ_plotms_ants2_4.0.png|200px|thumb|right|plotms ea01 for field 2 showing amp versus ANTENNA2]]<br />
Look for bad antennas by picking the last field and plotting baselines versus antenna <tt>ea01</tt>:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17:31~31', \<br />
antenna='ea01',correlation='RR,LL',xaxis='antenna2',yaxis='amp')<br />
</source><br />
<br />
You should be able to see that antenna 11 (= ea13) is bad (very low amplitude, it has no C-band receiver!) and that some of the spectral windows on 15 and 23 (ea17, ea25) are also on the low side. Boxing with the '''Mark Regions''' [[Image:MarkRegionsButton.png]] tool and using the '''Locate''' [[File:casaplotms-locate-tool.png]] tool will show in the logger that spw 10-17 are suspect for these antennas. (Note: you may also leave these in for now if you like; if this were truly a first pass through the data it is unlikely that they would be caught. Since this is a tutorial, and there is limited time for a second pass through the data, it's probably best to trust us and delete them now.)<br />
<br />
[[Image:plotSN2010FZ_plotms_ea02.png|200px|thumb|right|plotms field 2 ea02 amp vs frequency]]<br />
Now look at the bandpass for ea02 - it is in the inner core and a prospective reference antenna. Exclude ea13 using negation (represented by "!") in the selection:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17', \<br />
antenna='ea02;!ea13',correlation='RR,LL',xaxis='frequency',yaxis='amp')<br />
</source><br />
There is clearly less data for spw 11, and use of Locate shows spw 11 data only for ea02,ea03,04,08,09,11,12. We will later delete this incomplete spw. Note also the very strong RFI spike at 6614 MHz (spw 10 ch 63) with clear ringing contaminating both spw 10 and 11. There is also a tremendous roll-off in spw 10. We will drop these spectral window when we process the data.<br />
<br />
[[Image:plotSN2010FZ_plotms_ea02ea20.png|200px|thumb|right|plotms ea02 iteration with baseline stopped at ea02&ea20 showing phase vs frequency]]<br />
We can also step through the baselines to our antenna using iteraxis:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02;!ea13', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',iteraxis='baseline')<br />
</source><br />
and use the '''Next Iteration''' [[Image:NextIterationButton.png]] button to step through the baselines.<br />
This will make it easier to isolate the bad antennas. Now plot the phases, iterating through baselines to ea02:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02;!ea13', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',iteraxis='baseline')<br />
</source><br />
You see the slopes due to residual delays. Mostly a turn or less over a 128MHz subband, but there are some outliers.<br />
Step through to ea20. You see that there is a very large delay in RR (via locate) for<br />
the first baseband (spw 0~7). We will delete this (will also delete LL so there are no orphan polarization products, which would be ignored by {{clean}} in the imaging stage).<br />
Note ea17 and ea25 baselines drop close to zero in the middle of upper baseband (e.g. plot 'ea17&ea25') so we will delete these.<br />
<br />
To carry out flagging, we again use {{flagcmd}} in the mode where it takes a list of command strings:<br />
<source lang="python"><br />
# In CASA<br />
flaglist = ['antenna="ea13"',<br />
'antenna="ea17" spw="10~17"',<br />
'antenna="ea25" spw="10~17"',<br />
'antenna="ea20" spw="2~9"']<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='list',inpfile=flaglist,action='apply',flagbackup=True)<br />
</source><br />
These commands will be carried out as well as being added to the FLAG_CMD table (marked as applied).<br />
<br />
Plot the data again, now that is has been flagged:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='',spw='5:30~33',avgchannel='64', \<br />
antenna='ea01&ea02',correlation='RR,LL',xaxis='time',yaxis='amp')<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
<br />
[[Image:plotSN2010FZ_plotms_ea02fld0.png|200px|thumb|right|plotms field 0 ea02 amp vs frequency]]<br />
Now our phase calibrator - it is weaker, and we now start to really see the RFI:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='0',spw='2~17',antenna='ea02', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
Use the Zoom feature, Mark rectangles and use Locate to identify the frequency/channel of RFI. In particular, we note in our analysis:<br />
* 6614MHz (spw 10 ch 63) super strong<br />
* 6772-6778MHz (spw 12 ch 14-17)<br />
* 7260-7264MHz (spw 16 ch 2-4)<br />
* 7314-7340MHz (spw 16 ch 29-42)<br />
* 7402-7418MHz (spw 17 ch 9-17)<br />
* 7458-7466MHz (spw 17 ch 37-41)<br />
* 7488MHz (spw 17 ch 52)<br />
<br />
If you plot all antennas and avoid the band edges you see spw 16 and 17 are pretty wiped out:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='0',spw='2~17:4~59',antenna='', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
<br />
For now we will not flag these spectral windows, but note the bad channels, which we will mask out when creating continuum calibration tables and images.<br />
<br />
Finally, split off the good scans and spw, this will allow us to work on the data without having to start completely over (if we mess something up badly) as well as letting us do simpler data selections. Note that we do not include spw 10, because of the bad RFI, or spw 11, because of the many missing antennas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_flagged10s.ms')<br />
split(vis='SN2010FZ_10s.ms',outputvis='SN2010FZ_flagged10s.ms',datacolumn='data',spw='2~9,12~17',scan='7~43')<br />
</source><br />
<br />
You now have a MS called <tt>SN2010FZ_flagged10s.ms</tt> in your working area. This should be 2.8GB in size, which you can see while still at the CASA command prompt by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('du -sh SN2010FZ_flagged10s.ms')<br />
</source><br />
<br />
Note that the built-in <tt>system</tt> function allows one to execute UNIX shell commands within a CASA session. (Some, like <tt>ls</tt>, don't need this extra wrapper, but most are not automatically understood.)<br />
<br />
[[Image:PlotSN2010FZ_plotms_datastream_zoomed.png|200px|thumb|right|plotms antenna2 vs. time "datastream" plot, zoomed in on last scan]]<br />
At this point it is useful to plot a "datastream" view of the dataset to show what antennas are present at what time. You can do this using<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
This shows the times where data is present on baselines TO a given Antenna2 (which means there is no line for ea01 which is antenna 0). You can pick up ea01 (and drop ea28) by setting <tt>yaxis='antenna1'</tt>. To the right we show this plot, having zoomed in on the last scan on 3C286. You see here that some antennas are present in this scan earlier than others (e.g. ea02 comes in one 10s integration later than ea04).<br />
<br />
== Calibration ==<br />
<br />
Summarize the split flagged MS:<br />
<source lang="python"><br />
# In CASA<br />
listobs('SN2010FZ_flagged10s.ms')<br />
</source><br />
In the logger we see:<br />
<pre><br />
##########################################<br />
##### Begin Task: listobs #####<br />
<br />
================================================================================<br />
MeasurementSet Name: SN2010FZ_flagged10s.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. Alicia M. Soderberg Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 1375038 Total integration time = 3042 seconds<br />
Observed from 11-Jul-2010/21:36:01.0 to 11-Jul-2010/22:26:43.0 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) SpwIds ScanIntent<br />
11-Jul-2010/21:36:01.0 - 21:38:20.5 7 0 J0925+0019 73710 9.93 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
21:38:44.0 - 21:39:51.0 9 1 SN2010FZ 39312 9.16 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:40:01.0 - 21:41:20.5 10 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:41:30.0 - 21:42:50.0 11 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:43:00.0 - 21:44:20.0 12 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:44:30.0 - 21:45:50.0 13 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:46:00.0 - 21:47:19.5 14 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:47:29.0 - 21:47:49.0 15 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:48:12.0 - 21:49:18.5 16 0 J0925+0019 39312 9 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
21:49:42.0 - 21:50:49.0 17 1 SN2010FZ 39312 9.17 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:50:59.0 - 21:52:19.0 18 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:52:29.0 - 21:53:48.5 19 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:53:58.0 - 21:55:18.0 20 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:55:28.0 - 21:56:48.0 21 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:56:58.0 - 21:58:18.0 22 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:58:28.0 - 21:58:47.5 23 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:59:10.5 - 22:00:17.0 24 0 J0925+0019 39312 8.99 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:00:39.5 - 22:01:47.0 25 1 SN2010FZ 39312 9.18 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:01:57.0 - 22:03:17.0 26 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:03:27.0 - 22:04:47.0 27 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:04:57.0 - 22:06:16.5 28 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:06:26.0 - 22:07:46.0 29 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:07:56.0 - 22:09:16.0 30 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:09:26.0 - 22:09:45.5 31 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:10:08.0 - 22:11:15.5 32 0 J0925+0019 39312 9.13 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:11:38.0 - 22:12:45.5 33 1 SN2010FZ 39312 9.19 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:12:55.0 - 22:14:15.0 34 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:14:25.0 - 22:15:45.0 35 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:15:55.0 - 22:17:15.0 36 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:17:25.0 - 22:18:44.5 37 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:18:54.0 - 22:20:14.0 38 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:20:24.0 - 22:20:43.5 39 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:21:06.0 - 22:22:13.5 40 0 J0925+0019 38584 9.15 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:25:13.0 - 22:25:13.0 42 2 3C286 924 2.88 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
22:25:23.0 - 22:26:43.0 43 2 3C286 43148 9.6 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
(nVis = Total number of time/baseline visibilities per scan) <br />
Fields: 3<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 D J0925+0019 09:25:07.81503 +00.19.13.9334 J2000 0 230230 <br />
1 NONE SN2010FZ 09:42:04.77000 +00.19.51.0000 J2000 1 1100736<br />
2 K 3C286 13:31:08.28798 +30.30.32.9589 J2000 2 44072 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (14 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 64 TOPO 4488 2000 128000 RR RL LR LL <br />
1 64 TOPO 4616 2000 128000 RR RL LR LL <br />
2 64 TOPO 4744 2000 128000 RR RL LR LL <br />
3 64 TOPO 4872 2000 128000 RR RL LR LL <br />
4 64 TOPO 5000 2000 128000 RR RL LR LL <br />
5 64 TOPO 5128 2000 128000 RR RL LR LL <br />
6 64 TOPO 5256 2000 128000 RR RL LR LL <br />
7 64 TOPO 5384 2000 128000 RR RL LR LL <br />
8 64 TOPO 6744 2000 128000 RR RL LR LL <br />
9 64 TOPO 6872 2000 128000 RR RL LR LL <br />
10 64 TOPO 7000 2000 128000 RR RL LR LL <br />
11 64 TOPO 7128 2000 128000 RR RL LR LL <br />
12 64 TOPO 7256 2000 128000 RR RL LR LL <br />
13 64 TOPO 7384 2000 128000 RR RL LR LL <br />
<snip><br />
</pre><br />
Note that the spectral windows are re-numbered to 0 through 13.<br />
<br />
=== Setting the flux density scale ===<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#x195-1920004 Synthesis Calibration] in the CASA Cookbook and User Reference Manual .<br />
<br />
Before calibrating, we insert a model for flux calibration source 3C286 into the MS. In order to do this, we first have to locate the model image on our system with {{setjy}}, which we will also use to set the flux density scale. The {{setjy}} task (in release 3.3.0 and later) has an option to list possible model images it knows about:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='SN2010FZ_flagged10s.ms', listmodels=True)<br />
</source><br />
which sends output to your terminal (but not the logger). For example, on an NRAO workstation:<br />
<pre><br />
<br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
The relevant image for our purposes is <tt>3C286_C.im</tt>, in the directory <tt>/usr/lib64/casapy/release/data/nrao/VLA/CalModels</tt>. Your system may show a different location (for example <tt>/home/casa/data/nrao/VLA/CalModels/</tt>, or <tt>/Applications/CASA.app/Contents/data/nrao/VLA/CalModels</tt> on a Mac). Since it knows about this image, we only have to give the image name and not the entire path. Otherwise, you will need to give it the entire path. We now run the task using this model:<br />
<br />
<source lang="python"><br />
# In CASA<br />
mysetjy = setjy(vis='SN2010FZ_flagged10s.ms', field='2', scalebychan=True, model='3C286_C.im', usescratch=False)<br />
</source><br />
<br />
* <tt>scalebychan=True</tt>: will fill the model with per-channel values; otherwise, {{setjy}} would use a single value per spectral window.<br />
* <tt>usescratch=False</tt>: put the model in the header instead of creating scratch columns in the MS. This will take up considerably less disk space.<br />
<br />
We have not specified a Flux Density Scale Standard and are thus using the default (<tt>standard='Perley-Butler 2010'</tt>) as that was current when these observations were taken. In particular, there is a more recent "Perley-Butler 2013" scale that most users will want to use! See <tt>help setjy</tt> for more details.<br />
<br />
Inspecting the logger report shows that 3C286 is about 7.7 Jy at lower end of the band to 5.7 Jy at the upper end.<br />
<br />
Note: With release 4.2 {{setjy}} now returns a dictionary to Python, which we have captured in a variable. This can be used in scripts.<br />
<br />
=== Deriving pre-determined calibrations: antenna position corrections, gain-elevation curves, and requantizer gains ===<br />
<br />
Some calibration products are carried along throughout the calibration process and used as priors for subsequent calibration steps. These include the antenna position corrections, gain-elevation curves, and requantizer gains.<br />
<br />
We use {{gencal}} to determine any antenna-position corrections that need to be applied to the data. This is based on a database of corrections with the time they were determined and when they were applied by the observing system, compared to the times in your observations.<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.antpos',caltype='antpos',antenna='')<br />
</source><br />
You should see in the logger:<br />
<pre style="background-color: #fffacd;"><br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea06 : 0.00220 0.00100 0.00590<br />
offsets for antenna ea10 : 0.00080 0.00300 -0.00140<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.00370 -0.00130 0.00000<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
</pre><br />
Note that there are significant position corrections for a number of the antennas. <br />
<br />
In CASA 4.1 and later, we now have the option to use {{gencal}} to create a calibration table containing the gain curves for the antennas. Although you can still use the <tt>gaincurve=True</tt> option in each task, we will make use of this new feature (note that the <tt>gaincurve=True</tt> will be phased out in future CASA releases):<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.gaincurve',caltype='gc')<br />
</source><br />
<br />
Finally, we will use {{gencal}} to create a calibration table containing corrections for the requantizer gains. Although this is only necessary for 3-bit data (and our SN2010FZ is 8-bit), we include it here for completeness. It will not affect the calibration for our 8-bit data, but if one is following this CASA Guide as a template for 3-bit data, this step is needed to account for the small gain changes (~5-10%) that result from resetting the quantizer gains as the correlator changes to a new 3-bit configuration.<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.requantizer',caltype='rq')<br />
</source><br />
<br />
Since we're running {{gencal}} on 3-bit data, it logs that it found "0 TIME/SPW switched power samples."<br />
<br />
The caltables we have generated -- <tt>calSN2010FZ.antpos</tt>, <tt>calSN2010FZ.gaincurve</tt>, and <tt>calSN2010FZ.requantizer</tt> -- will need to be pre-applied in subsequent calibration steps.<br />
<br />
=== Calibrating delays and bandpass ===<br />
<br />
[[Image:plotSN2010FZ_plotcal_G0p1_4.0.png|200px|thumb|right|plotcal G0 phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G0p2_4.0.png|200px|thumb|right|plotcal G0 phase ant 16~26]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_delays_4.2.png|200px|thumb|right|plotcal K0 delay vs. antenna]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_B0a1_4.0.png|200px|thumb|right|plotcal B0 bandpass amp ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_B0a2_4.0.png|200px|thumb|right|plotcal B0 bandpass amp ant 16~26]]<br />
[[Image:plotSN2010FZ_plotcal_B0p1_4.0.png|200px|thumb|right|plotcal B0 bandpass phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_B0p2_4.0.png|200px|thumb|right|plotcal B0 bandpass phase ant 16~26]]<br />
[[Image:plotSN2010FZ_plotcal_B0ea14_4.0.png|200px|thumb|right|plotcal B0 amp and phase vs. freq for ea14]]<br />
<br />
First, we do a phase-only calibration solution on a narrow range of channels in each spw on the bandpass/flux calibrator 3c286 to flatten them before solving for the bandpass. Note where we saw RFI in the higher spw and avoid those channels. The range 23~28 should work. Pick a refant near center - ea04 is a reasonable bet (see above):<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G0',field='2',spw='0~13:23~28', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve'],\<br />
gaintype='G',refant='ea04',calmode='p',solint='int',minsnr=3) <br />
</source><br />
<br />
* <tt>refant='ea04'</tt> : try to use ea04 as the reference antenna<br />
* <tt>solint='int'</tt> : do a per-integration solve (every 10 seconds, since we've time-averaged the data)<br />
* <tt>minsnr=3</tt> : apply a minimum signal-to-noise cutoff. Solutions with less than this value will be flagged<br />
* <tt>gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve']</tt> : pre-apply the antpos and gaincurve caltables<br />
<br />
Plot the phase solutions (using full phase range, -180 to 180, instead of autorange):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Step through the antenna-based solutions. They look good (and fairly flat over the scans).<br />
<br />
NOTE: When you are done plotting and want to use the caltable in another task, use the Quit button on the GUI to dismiss the plotter and free up the lock on the caltable. You should see a message in your terminal window saying "Resetting plotcal" which means you are good to go!<br />
<br />
If you want to make single-page multipanel plots (like those shown to the right), particularly for a<br />
hardcopy (where it only shows the first page), you can do:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase', \<br />
antenna='0~10,12~15',subplot=531,iteration='antenna', \<br />
plotrange=[-1,-1,-180,180],showgui=False,fontsize=6.0, \<br />
figfile='plotSN2010FZ_plotcal_G0p1.png')<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase', \<br />
antenna='16~26',subplot=531,iteration='antenna', \<br />
plotrange=[-1,-1,-180,180],showgui=False,fontsize=6.0, \<br />
figfile='plotSN2010FZ_plotcal_G0p2.png')<br />
</source><br />
<br />
We can now solve for the residual antenna-based delays that we saw in phase vs. frequency.<br />
This uses the new gaintype='K' option in gaincal. Note that this currently does not do a "global fringe-fitting" solution for delays,<br />
but instead does a baseline-based delay solution to all baselines to the refant, treating these<br />
as antenna-based delays. In most cases with high-enough S/N to get baseline-based delay solutions<br />
this will suffice. We avoid the beginning of spw 0 due to the extreme roll-off (with loss of S/N) at the<br />
starting edge.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.K0',\<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.G0'],\<br />
field='2',spw='0:8~59,1~13:4~59',gaintype='K', \<br />
refant='ea04',combine='scan',solint='inf',minsnr=3)<br />
</source><br />
We pre-apply our initial phase table, and produce a new K-type caltable for input to bandpass calibration.<br />
We can plot the delays, in nanoseconds, as a function of antenna index (you will get one for each subband and polarization):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.K0', xaxis='antenna', yaxis='delay')<br />
</source><br />
<br />
The delays range from around -6 to 6 nanoseconds.<br />
<br />
Now solve for the bandpass using the previous tables:<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.B0', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve', \<br />
'calSN2010FZ.G0','calSN2010FZ.K0'], \<br />
field='2',refant='ea04',solnorm=False, \<br />
bandtype='B', combine='scan', solint='inf')<br />
</source><br />
'''WARNING''': You must set <tt>solnorm=False</tt> here or later on you will find some offsets<br />
between spw due to how amplitude scaling adjusts weights internally during solving.<br />
<br />
You will see in the terminal some reports of solutions failing below our default S/N>3 cutoff:<br />
<pre><br />
32 of 50 solutions flagged due to SNR < 3 in spw=0 (chan=1) at 2010/07/11/22:26:05.4<br />
44 of 50 solutions flagged due to SNR < 3 in spw=0 (chan=0) at 2010/07/11/22:26:05.4<br />
</pre><br />
<br />
These are in the first two edge channels of the first spw where the response is low, and not unexpected. <br />
In the logger you will also see reports of reference antennas jumping in those channels, which can be <br />
be safely ignored (we will drop those channels later anyway).<br />
<br />
This is the first amplitude-scaling calibration that we do, so it is important to have used the <tt>calSN2010FZ.gaincurve</tt> caltable (or set <tt>gaincurve=True</tt>). If we were at higher frequency we would also have made an opacity caltable (or set <tt>opacity</tt>).<br />
<br />
Now plot this, in amplitude then phase:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',iteration='antenna')<br />
#<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
or to plot them all together<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',<br />
antenna='0~10,12~15',subplot=531,iteration='antenna',<br />
fontsize=6.0, figfile='plotSN2010FZ_plotcal_B0a1_4.2.png')<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',<br />
antenna='16~26',subplot=531,iteration='antenna',<br />
fontsize=6.0, figfile='plotSN2010FZ_plotcal_B0a2_4.2.png')<br />
#<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',<br />
antenna='0~10,12~15',subplot=531,iteration='antenna',<br />
plotrange=[-1,-1,-180,180],fontsize=6.0, <br />
figfile='plotSN2010FZ_plotcal_B0p1_4.2.png')<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',<br />
antenna='16~26',subplot=531,iteration='antenna',<br />
plotrange=[-1,-1,-180,180],fontsize=6.0, <br />
figfile='plotSN2010FZ_plotcal_B0p2_4.2.png')<br />
</source><br />
(this can take a long time to plot).<br />
<br />
In the bandpass phase you no longer see the residual antenna delays (just residual spw phase offsets from <br />
the delay solution registration) but there are some band edge effects.<br />
Note that some antennas have a little strange bandpasses at upper end of lower baseband in spw 5,6,7<br />
(e.g. ea14,ea16,ea17,ea25).<br />
To plot amp and phase for a single antenna versus frequency (see plots at right):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp', \<br />
antenna='ea14',subplot=211)<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase', \<br />
antenna='ea14',subplot=212,plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Because our flux density calibrator 3C286 is bright enough, we were able to use this as the bandpass calibrator.<br />
Since {{setjy}} put the correct spectrum for 3C286 into the MODEL_DATA column, our bandpass will reflect the<br />
true bandpass of the instrument. However, if for your observation you were unable to use a source of known spectrum <br />
as the bandpass calibrator, then you would need to use the output of {{fluxscale}} later on to bootstrap a {{setjy}} <br />
on your bandpass source using the derived spectral index information.<br />
<br />
=== Final phase and amplitude calibration ===<br />
<br />
[[Image:plotSN2010FZ_plotcal_G1intp1_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G1intp2_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 16~26]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_G1intp_ea01_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G1infp_ea01_4.0.png|200px|thumb|right|plotcal G1inf per-scan phase ant 0~15]]<br />
<br />
Now calibrate phases using the full bandwidth. <br />
First both our calibrators, one at a time - we could do them together, but in general you might need<br />
to do different solution intervals for each, so we keep the runs separate to illustrate how to <br />
do separate solutions and append them.<br />
We exclude RFI channels here, and obtain one solution per integration (these are bright enough):<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1int', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='2',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='int',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1int', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='int',gaintype='G',calmode='p',append=True)<br />
</source><br />
These will get applied when solving for amplitudes, and when calibrating the calibrators themselves.<br />
<br />
The phases look reasonably connected:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G1int',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
To apply phase calibration to the target, we make a second table with one solution on our gain calibrator per scan:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1inf',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',gaintype='G',calmode='p')<br />
</source><br />
These scan phases will get interpolated by {{applycal}} onto our target. These look good also:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G1inf',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Now solve for amplitudes on a per scan interval, after applying the per-integration phases. <br />
Do these separately using <tt>gainfield</tt> so phases don't get<br />
transferred across fields. For field 2 (3C286) we use <tt>combine='scan'</tt> as there are two scans <br />
on this source, with the first one having much less data (and will thus give a noisy solution on its own).<br />
Note that {{gaincal}} uses linear interpolation of the previously determined phases by default, so <br />
set this to "nearest" if you want to override this.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'], \<br />
gainfield=['','','2','2','2'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='2',refant='ea04',solnorm=F,<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'],\<br />
gainfield=['','','2','2','0'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',gaintype='G',calmode='a',append=True)<br />
</source><br />
This is the table we will apply to the data.<br />
<br />
[[Image:plotSN2010FZ_plotcal_G2infa1_4.0.png|200px|thumb|right|plotcal G2 per-scan amp ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G2infa2_4.0.png|200px|thumb|right|plotcal G2 per-scan amp ant 16~26]]<br />
<br />
We do a second version of the amplitude calibration, this time using <tt>combine='scan'</tt> on field 0. This is <br />
to use for input to {{fluxscale}} in the next step.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G3', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'], \<br />
gainfield=['','','2','2','2'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='2',refant='ea04',solnorm=F,<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G3', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'],\<br />
gainfield=['','','2','2','0'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a',append=True)<br />
</source><br />
<br />
Since the flux on the gain calibrator is not scaled to its correct flux (but to 1.0 Jy by default),<br />
use {{fluxscale}} to transfer the amplitude gains from 3c286:<br />
<source lang="python"><br />
# In CASA<br />
myflux = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G3', \<br />
fluxtable='calSN2010FZ.F3inc',reference='2',transfer='0',<br />
incremental=True)<br />
</source><br />
where we have captured the returned dictionary in the Python variable <tt>myflux</tt>. We have use the<br />
<tt>incremental=True</tt> option (new to CASA 4.0) to make this table contain only the scale factors <br />
per-antenna per-spw per-field needed to scale the data (rather than rescaling the input table). Thus it<br />
can be applied in addition to our <tt>G2</tt> table even though it was derived from the <tt>G3</tt> table.<br />
<br />
The logger output gives:<br />
<pre><br />
Found reference field(s): 3C286<br />
Found transfer field(s): J0925+0019<br />
Flux density for J0925+0019 in SpW=0 (freq=4.488e+09 Hz) is: 0.977483 +/- 0.00278572 (SNR = 350.891, N = 50)<br />
Flux density for J0925+0019 in SpW=1 (freq=4.616e+09 Hz) is: 0.975972 +/- 0.00253876 (SNR = 384.429, N = 50)<br />
Flux density for J0925+0019 in SpW=2 (freq=4.744e+09 Hz) is: 0.978538 +/- 0.00242824 (SNR = 402.982, N = 50)<br />
Flux density for J0925+0019 in SpW=3 (freq=4.872e+09 Hz) is: 0.979278 +/- 0.00244155 (SNR = 401.088, N = 50)<br />
Flux density for J0925+0019 in SpW=4 (freq=5e+09 Hz) is: 0.981804 +/- 0.00219239 (SNR = 447.823, N = 50)<br />
Flux density for J0925+0019 in SpW=5 (freq=5.128e+09 Hz) is: 0.981478 +/- 0.00314805 (SNR = 311.773, N = 50)<br />
Flux density for J0925+0019 in SpW=6 (freq=5.256e+09 Hz) is: 0.985493 +/- 0.00343534 (SNR = 286.869, N = 50)<br />
Flux density for J0925+0019 in SpW=7 (freq=5.384e+09 Hz) is: 0.978491 +/- 0.00201807 (SNR = 484.865, N = 50)<br />
Flux density for J0925+0019 in SpW=8 (freq=6.744e+09 Hz) is: 0.959005 +/- 0.00260159 (SNR = 368.623, N = 48)<br />
Flux density for J0925+0019 in SpW=9 (freq=6.872e+09 Hz) is: 0.955123 +/- 0.00262785 (SNR = 363.462, N = 48)<br />
Flux density for J0925+0019 in SpW=10 (freq=7e+09 Hz) is: 0.954202 +/- 0.00281227 (SNR = 339.3, N = 48)<br />
Flux density for J0925+0019 in SpW=11 (freq=7.128e+09 Hz) is: 0.950797 +/- 0.00354085 (SNR = 268.522, N = 48)<br />
Flux density for J0925+0019 in SpW=12 (freq=7.256e+09 Hz) is: 0.94732 +/- 0.00391511 (SNR = 241.965, N = 48)<br />
Flux density for J0925+0019 in SpW=13 (freq=7.384e+09 Hz) is: 0.939356 +/- 0.00383532 (SNR = 244.922, N = 48)<br />
Fitted spectrum for J0925+0019 with fitorder=1: Flux density = 0.968048 +/- 0.00159415 (freq=5.74863 GHz) <br />
spidx=-0.0721976 +/- 0.00943577<br />
...<br />
</pre><br />
You may see slightly different numbers on your machine (and will see more extensive output). Note that "N" here is the number of antennas x the number of polarizations used for the calculations; in this case, there are 24 unflagged antennas and 2 polarizations. As of CASA 4.0, {{fluxscale}} now returns a fitted spectral index (and possibly curvature, e.g. if fitorder>1), which can be input to {{setjy}} if you want to use these derived fluxes for a model. <br />
<br />
As it so happens, the derived flux for J0925+0019 is about 1 Jy (you can plot up the raw amplitudes for fields 0,2 and convince yourself this is indeed true and not a bug). The spectrum rises a bit to peak in spw 6 then falls again. We will not use the fitted spectrum (setjy does not yet take fitorder>1) but will apply a incremental table in subsequent processing.<br />
<br />
== Applying the Calibration and Final Editing ==<br />
<br />
Next we actually apply all our accumulated calibration tables. We apply these to the <br />
calibration fields individually using the appropriate gainfields and interpolation for each:<br />
* For 3C286 (field 2) we did short-timescale phase solutions and a single scan amplitude, so use "linear" and "nearest" interpolation respectively.<br />
* For the nearby gain calibrator (field 0) we did only scan-based phase and amplitude solutions so we use "nearest" interpolation<br />
* For the target source we use field 0 to calibrate field 1, so use "linear" interpolation. This takes a few minutes.<br />
<br />
[[Image:plotSN2010FZ_plotms_applied_fld2.png|200px|thumb|right|plotms of 3C286 with calibration applied]]<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1int','calSN2010FZ.G2'], \<br />
gainfield=['','','','','2','2'],<br />
interp=['','','nearest','nearest','nearest','nearest'], \<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1int','calSN2010FZ.G2',<br />
'calSN2010FZ.F3inc'], \<br />
gainfield=['','','','','0','0','0'],<br />
interp=['','','nearest','nearest','nearest','nearest',''], \<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1inf','calSN2010FZ.G2',<br />
'calSN2010FZ.F3inc'], \<br />
gainfield=['','','','','0','0','0'],<br />
interp=['','','nearest','nearest','linear','linear',''], \<br />
parang=False,calwt=False)<br />
</source><br />
Because we used <tt>usesratch=False</tt> in {{setjy}}, the <tt>CORRECTED_DATA</tt> scratch column will be created the first time you run {{applycal}}. This will store the calibrated data.<br />
<br />
We can examine the corrected data on 3c286 using our RFI mask from above and avoiding band edges<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
See figure above right. There is clearly discrepant data visible spw 5 and 6, in particular for baseline ea17&ea25 (use the '''Mark Regions''' [[Image:MarkRegionsButton.png]] tool on some of it and then use the '''Locate''' [[File:casaplotms-locate-tool.png]] tool), which gives a really strange response. You can plot just this baseline to be sure:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='ea17&ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
You can exclude this through antenna negation:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='!ea17&ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Then use '''Locate''' [[File:casaplotms-locate-tool.png]] for the other bad points, which seem to indicate spw 5,6,7 for ea14,ea16,ea17,ea25.<br />
Exclude these and replot:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='!ea14;!ea16;!ea17;!ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld2.png|200px|thumb|right|plotms cal applied flagged fld2]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld2_phase.png|200px|thumb|right|plotms cal applied flagged fld2 phase]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_amp.png|200px|thumb|right|plotms cal applied flagged fld0 amp]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_phase.png|200px|thumb|right|plotms cal applied flagged fld0 phase]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_amp_exc_4.0.png|200px|thumb|right|plotms cal applied flagged fld0 amp, with new spw selection]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_ampavg_4.0.png|200px|thumb|right|plotms cal applied flagged fld0 amp averaged]]<br />
<br />
This now looks clean except for the RFI in the upper subbands.<br />
<br />
Do flagging based on these:<br />
<source lang="python"><br />
# In CASA<br />
flaglist2 = ['antenna="ea14,ea16,ea17,ea25" spw="5~7"']<br />
flagcmd(vis='SN2010FZ_flagged10s.ms',inpmode='list',inpfile=flaglist2,action='apply')<br />
</source><br />
<br />
Now replot the corrected data (you may have to force reload if you plotted same thing right before this):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Looks pretty good.<br />
<br />
Plot the phase:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
Note the characteristic "bowtie" pattern of the phases about the sub-band centers.<br />
Here we can see the effect of the EVLA "delay clunking", where the delay steps through discrete values such that<br />
the phase goes from -11deg to +11deg across the sub-band as the delay changes due to geometry. This is D-configuration so the delays change slowly, it will change faster in wider configurations. As of Q3 2011 we have not enabled the corrections for this in the EVLA system so you will always have this remaining delay error in your data. In principle, you could solve for delays on short timescales and take this out; in practice, this in not possible for your weaker science target source (where it would matter most for results).<br />
<br />
Now let's plot the corrected data amplitude for the phase calibrator (field 0):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
You can see the bandpass filter roll-off increasing the noise at the baseband edges (about 8-16 channels worth). Also, we can see some RFI we missed:<br />
* <6804 MHz spw 8 below ch 30 lots of bad stuff (a lot from ea18,ea22 but others too)<br />
* 7168 MHz spw 11 ch 20<br />
* pretty much all of spw 12,13<br />
The ch 20 ones are all harmonics of a notorious 128 MHz tone. NOTE: You can get the frequency of a RFI feature by looking at the logger report from using the '''Locate''' [[File:casaplotms-locate-tool.png]] tool.<br />
<br />
We will not flag these, but exclude them in imaging (so that more advanced students can try flagging these in detail or using auto-flagging). A good channel selection string for imaging might be:<br />
<br />
<pre><br />
spw = '0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59'<br />
</pre><br />
<br />
Without further flagging, it may be best to drop spw 12-13 for imaging (we will do so from now on).<br />
<br />
Plot again (including this selection for spw 0-11):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Looks better.<br />
<br />
Now plot amplitudes for the corrected data averaged over baseline to see the source spectrum:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0',<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59',<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
The "custom" plotting parameters show how to control the symbol shape and size from the task.<br />
<br />
The last two sub-bands spw 12-13 give reasonable values, with only a tiny offset from spw 8-11.<br />
There are also strange amplitude excursions, particularly in the low end of the first baseband. These must be coming<br />
from one or more scans. You can iterate over scan to see the strange amplitudes (mostly from scan 7):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0',<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59',<br />
correlation='RR,LL',avgbaseline=True,avgtime='600s',iteraxis='scan',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
<br />
Also, there is an offset with the amplitudes for spw 6, perhaps due to the problem with baseline ea17&ea25 (which we flagged, but didn't recalibrate afterward) and likely affected the {{fluxscale}} solution. This is troubling enough that we will quickly go through a second round of calibration.<br />
<br />
== A Quick Recalibration ==<br />
<br />
We now go back and recalibrate the data. We may as well flag scan 7 first, as well:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='SN2010FZ_flagged10s.ms', scan='7')<br />
#<br />
# Clear the corrected data and model from header<br />
clearcal('SN2010FZ_flagged10s.ms',addmodel=False)<br />
#<br />
chanStr = '0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59'<br />
#<br />
mysetjy2 = setjy(vis='SN2010FZ_flagged10s.ms', field='2', scalebychan=True, modimage='3C286_C.im')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G0.2',field='2',spw='0~11:23~28',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve'],<br />
gaintype='G',refant='ea04',calmode='p',solint='int',minsnr=3)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.K0.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.G0.2'],<br />
field='2', spw=chanStr, gaintype='K',<br />
refant='ea04', combine='scan', solint='inf', minsnr=3)<br />
#<br />
bandpass(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.B0.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.G0.2','calSN2010FZ.K0.2'],<br />
field='2',refant='ea04',solnorm=False,<br />
spw='0~11', <br />
bandtype='B', combine='scan', solint='inf')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2int',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='2',refant='ea04',solnorm=F, <br />
spw=chanStr,<br />
solint='int',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2int',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='int',gaintype='G',calmode='p',append=True)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2inf',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','2'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='2',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','0'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',gaintype='G',calmode='a',append=True)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.3',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','2'],<br />
interp=['','','nearest','nearest','nearest'],<br />
field='2',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.3',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','0'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a',append=True)<br />
#<br />
myflux2 = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G2.3',<br />
fluxtable='calSN2010FZ.F2.3inc',reference='2',transfer='0',<br />
incremental=True)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='2',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2'],<br />
gainfield=['','','','','2','2'],<br />
interp=['','','nearest','nearest','linear','nearest'],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3inc'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','nearest','nearest',''],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2inf','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3inc'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','linear','linear',''],<br />
parang=False,calwt=False)<br />
</source><br />
<br />
Note that we have set the variable <tt>chanStr</tt> for our channel selection; this makes the task commands shorter and easier to read.<br />
<br />
The {{fluxscale}} output this time around is slightly different to the last:<br />
<pre><br />
Found reference field(s): 3C286<br />
Found transfer field(s): J0925+0019<br />
Flux density for J0925+0019 in SpW=0 (freq=4.488e+09 Hz) is: 0.978946 +/- 0.00284837 (SNR = 343.686, N = 50)<br />
Flux density for J0925+0019 in SpW=1 (freq=4.616e+09 Hz) is: 0.978634 +/- 0.00264066 (SNR = 370.602, N = 50)<br />
Flux density for J0925+0019 in SpW=2 (freq=4.744e+09 Hz) is: 0.980438 +/- 0.00251668 (SNR = 389.575, N = 50)<br />
Flux density for J0925+0019 in SpW=3 (freq=4.872e+09 Hz) is: 0.980116 +/- 0.00255481 (SNR = 383.636, N = 50)<br />
Flux density for J0925+0019 in SpW=4 (freq=5e+09 Hz) is: 0.982175 +/- 0.00230804 (SNR = 425.545, N = 50)<br />
Flux density for J0925+0019 in SpW=5 (freq=5.128e+09 Hz) is: 0.979574 +/- 0.00269688 (SNR = 363.225, N = 42)<br />
Flux density for J0925+0019 in SpW=6 (freq=5.256e+09 Hz) is: 0.980193 +/- 0.00271312 (SNR = 361.279, N = 42)<br />
Flux density for J0925+0019 in SpW=7 (freq=5.384e+09 Hz) is: 0.98102 +/- 0.00249166 (SNR = 393.721, N = 42)<br />
Flux density for J0925+0019 in SpW=8 (freq=6.744e+09 Hz) is: 0.962693 +/- 0.00282815 (SNR = 340.397, N = 48)<br />
Flux density for J0925+0019 in SpW=9 (freq=6.872e+09 Hz) is: 0.960313 +/- 0.00285418 (SNR = 336.459, N = 48)<br />
Flux density for J0925+0019 in SpW=10 (freq=7e+09 Hz) is: 0.957056 +/- 0.00303716 (SNR = 315.116, N = 48)<br />
Flux density for J0925+0019 in SpW=11 (freq=7.128e+09 Hz) is: 0.953964 +/- 0.00378326 (SNR = 252.154, N = 48)<br />
Flux density for J0925+0019 in SpW=12 is: INSUFFICIENT DATA <br />
Flux density for J0925+0019 in SpW=13 is: INSUFFICIENT DATA <br />
Fitted spectrum for J0925+0019 with fitorder=1: Flux density = 0.973376 +/- 0.00118872 (freq=5.52174 GHz) <br />
spidx=-0.0573991 +/- 0.00778736201<br />
</pre><br />
<br />
The source spectrum plot now looks somewhat better:<br />
<br />
[[Image:plotSN2010FZ_plotms_reproc_fld0_ampavg_4.0.png|200px|thumb|right|plotms recalibrated applied flagged fld0 amp averaged]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
As you see in the figure to the right, there are still spectral window to window variations that deviate from a smooth spectrum. This is due to noise in the {{fluxscale}} median filter now used in CASA 4.0 (in this well-calibrated case, the old weighted means used by {{fluxscale}} in CASA3.4 behaved better). If we use {{plotcal}} to plot the solutions versus antenna<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G2.3',xaxis='antenna',yaxis='amp',field='0',<br />
subplot=211,plotrange=[-1,-1,0.9,1.1])<br />
plotcal(caltable='calSN2010FZ.G2.3',xaxis='antenna',yaxis='amp',field='2',<br />
subplot=212,plotrange=[-1,-1,0.9,1.1],figfile='plotSN2010FZ_plotcal_G2.3_ampant.png')<br />
</source><br />
we see that there are variations that will enter into the medians. Some antennas are better behaved than others, for example ea12 (index 10) seems better than most.<br />
<br />
[[Image:plotSN2010FZ_plotcal_G2.3_ampant.png|200px|thumb|right|plotcal of G2.3 table, showing variation of solutions per antenna]]<br />
[[Image:screenshotPlotSN2010FZ_plotcal_fluxedit3_ea12.png|200px|thumb|right|plotcal of G2.3.ea12 table, marking all solutions but those for ea12 for flagging]]<br />
[[Image:screenshotPlotSN2010FZ_plotms_recalibrated3_EA12_fld0_amp_4.0.png|200px|thumb|right|plotms for fld 0 after application of F2.3.ea12 table]]<br />
Because we are applying an incremental correction for the flux scale, we have the latitude to change the caltable that goes into {{fluxscale}} to get a better result. For example, we can restrict the antennas that are used to derive the scale. Although there is not yet antenna selection in {{fluxscale}} itself, we can edit the caltable using {{plotcal}}. For example, make a copy of the G2.3 caltable and select only a single antenna:<br />
<source lang="python"><br />
# In CASA<br />
os.system('cp -rf calSN2010FZ.G2.3 calSN2010FZ.G2.3.ea12')<br />
plotcal(caltable='calSN2010FZ.G2.3.ea12',xaxis='antenna',yaxis='amp')<br />
</source><br />
In the plot to the right we show the GUI where we have boxed all but antenna ea12.<br />
Now we carry on with the {{fluxscale}} and {{applycal}}:<br />
<source lang="python"><br />
# In CASA<br />
myfluxEdit3 = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G2.3.ea12',<br />
fluxtable='calSN2010FZ.F2.3.ea12',reference='2',transfer='0',<br />
incremental=True)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3.ea12'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','nearest','nearest',''],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2inf','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3.ea12'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','linear','linear',''],<br />
parang=False,calwt=False)<br />
</source><br />
The results appear better:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
Note that if you choose a different antenna than ea12 to use for this, you will get<br />
different results, usually worse. But this procedure illustrates how to use the<br />
incremental solutions from {{fluxscale}} to your possible advantage.<br />
<br />
We now return to examining our calibration.<br />
<br />
We can also plot the corrected phase - looks good:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
<br />
We can average over baseline and each scan:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='600s',<br />
xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_phaseavg.png|200px|thumb|right|plotms cal applied flagged fld0 phase averaged]]<br />
<br />
In this case, we can see the residual effect of the EVLA "delay clunking" described above, but it is reduced due to the averaging that we applied, but it is still there.<br />
<br />
You can look at the target source field='1', but there are lots of data so you will need to do a lot of averaging.<br />
For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='1',avgtime='300s', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Alas, the upper baseband still has lots of low level RFI.<br />
<br />
Now split off the data for calibrators and target, to avoid later issues that can corrupt the MSs. We don't keep spw 12-15, since they weren't included in the last round of calibration, and we don't plan to image them.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_split10s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_split10s.ms', \<br />
datacolumn='corrected',field='1',spw='0~11')<br />
#<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_3c28610s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_3c28610s.ms', \<br />
datacolumn='corrected',field='2',spw='0~11')<br />
#<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_J092510s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_J092510s.ms', \<br />
datacolumn='corrected',field='0',spw='0~11')<br />
</source><br />
<br />
== Imaging ==<br />
<br />
This is EVLA D-configuration data at C-band. To determine the best parameters for imaging, it helps to start with the relevant information in the [http://evlaguides.nrao.edu/index.php?title=Observational_Status_Summary_-_Current Observational Status Summary]:<br />
<br />
* Synthesized beam should be 12" at 6 GHz with primary beam field of view of 7.5 arcmin (450")<br />
<br />
Our data spans 4.5-7.5 GHz: this is a relatively large fractional bandwidth, resulting in substantial variation of the field of view over the entire frequency range. FOV = 45 arcmin / Frequency (GHz), giving 10 arcmin at 4.5 GHz, and 6 arcmin at 7.5 GHz. Likewise, the synthesized beam ranges from 16" at 4.5 GHz to 9.6" at 7.5 GHz. We want to subsample the synthesized beam by a factor of 3-4, so will use a cellsize of 3". To cover the full FOV (keeping it at the inner part of the image) at the lowest frequencies, we will want an image size of >400 pixels, or >20 arcmin.<br />
<br />
We will also use the Briggs robust (with <tt>robust=0.5</tt>) weighting, which is a compromise between uniform and natural weighting,<br />
and will give reasonable resolution but will allow us to still see larger scale structure.<br />
<br />
Due to the numerology of [http://www.fftw.org/ FFTW's] (which {{clean}} uses under the hood for FFTs) optimal sizes, <br />
<tt>imsize</tt> should be composite number with two and only two prime factors chosen from<br />
2, 3, and 5. Taking into account the x1.2 padding that clean uses internally to the imsize<br />
you give it (and 1.2 = 2*3/5), we choose 640 or 1280 as our imsize (640 = 2^7*5). Other<br />
reasonable sets would be 405, 1215, etc. (405 = 3^4*5) or 432, 648, 1296 (these are 2^n*3^m*5).<br />
In practice, if you give it non-optimal values for imsize, you may find that the transforms<br />
take a bit longer, which is noticeable if you are doing interactive clean.<br />
<br />
WARNING: By default, a single-field nterms=1 clean does NOT use Cotton-Schwab (CS) clean to break<br />
into major cycles going back to data residuals, it just does cleaning in a bunch of minor<br />
cycles in the image plane. This can give much poorer imaging quality in cases with poor<br />
uv coverage (snapshots) or in the case of complex emission structure (like ours) -- clean tends to<br />
diverge in this case. You should explicitly set <tt>imagermode='csclean'</tt> in your<br />
call to clean. Also, in our case the psf is very good using mfs, so by default it will not<br />
take many major cycle breaks. We use the <tt>cyclefactor</tt> parameter to control this, which<br />
sets the break threshold to be cyclefactor times the max psf sidelobe level (outside the main<br />
peak). We start at <tt>cyclefactor=1.5</tt> in a single spw, and ratchet it up to 4.5 when we<br />
clean all the spw. This seems to work ok. Rule of thumb is if it is gobbling up many hundreds of<br />
clean iterations in the minor cycles early on, increase cyclefactor. Conversely, if your psf is poor<br />
but you source structure is simple, you can reduce cyclefactor (e.g. below 1) to stop it from taking<br />
lots of extra major cycles.<br />
<br />
For more information on using {{clean}}, in particular on using the interactive GUI, see<br />
[[EVLA_Continuum_Tutorial_3C391#Imaging]]. WARNING: In CASA 4.0 the GUI interface for clean <br />
and the viewer has changed slightly. Some of the screenshots shown below may differ slightly <br />
from what you see.<br />
<br />
NOTE: If you are pressed for time, then you might want to jump ahead to<br />
[[EVLA_6-cm_Wideband_Tutorial_SN2010FZ_CASA_4.2#Cleaning_the_lower_baseband_using_two_MFS_Taylor_terms]] <br />
and while it is cleaning you can read the other Imaging descriptions.<br />
<br />
=== Cleaning a single spectral window ===<br />
<br />
Let us start by interactively cleaning one of the lower baseband spw (spw 5 in this example).<br />
NOTE: this first time will take a few minutes at start to create scratch columns<br />
in the MS in case we want to do self-calibration later.<br />
<br />
'''Note that interrupting {{clean}} by Ctrl+C may corrupt your visibilities -- you may be better off choosing to let {{clean}} finish. We are currently implementing a command that will nicely exit to prevent this from happening, but for the moment try to avoid Ctrl+C.'''<br />
<br />
[[Image:viewSN2010FZ_spw5_clean640_4.0.png|200px|thumb|right|interactive clean spw5 640x640 after around 1000 iterations]]<br />
[[Image:viewSN2010FZ_spw5_clean1280.png|200px|thumb|right|2nd interactive clean spw5 1280x1280 before cleaning]]<br />
[[Image:viewSN2010FZ_spw5_clean1280final_4.0.png|200px|thumb|right|viewer showing clean spw5 1280x1280 restored image]]<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw5_clean640*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='5:4~59', \<br />
imagename='imgSN2010FZ10s_spw5_clean640', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[640,640],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
* Start carefully by boxing the bright source and setting iterations to 10 at first<br />
* Gradually add more boxes and increase the number of iterations<br />
* Since this is not much more than a snapshot you see the six-fold sidelobe pattern<br />
of the extended emission in the center of the map. This decreases as you clean<br />
out this emission.<br />
* Stop cleaning when the residuals look like noise (and you cannot clearly see sources).<br />
* To stop, click the red [[File:clean-stop.png]] button.<br />
<br />
The top figure to the right shows a zoom in on the end state of the clean, where<br />
we have marked a number of boxes and cleaned them out.<br />
<br />
Note that there are some strange sidelobe patterns in lower left, possibly <br />
from a source outside the image area. We can make a bigger image starting from<br />
our current model:<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw5_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='5:4~59', \<br />
imagename='imgSN2010FZ10s_spw5_clean1280', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
modelimage='imgSN2010FZ10s_spw5_clean640.model', \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
Sure enough, there is a bright source near the lower left (see middle panel at right). <br />
Box it, clean it a bit, and look again. There is a second source in the mid-left (track<br />
it down by its sidelobes). Box this one, clean it a bit, and when satisfied stop.<br />
<br />
You can use the CASA {{viewer}} to display the images that {{clean}} creates. If you need more guidance<br />
on using the viewer, see the [http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html CASA Viewer Demo] video<br />
(note that this is for a much earlier version of the viewer, and the interface has changed since then). <br />
<br />
Bring up your restored image directly:<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw5_clean1280.image')<br />
</source><br />
<br />
The restored image is shown in the bottom panel to the right. I have chosen the Grayscale1 instead of default color<br />
map as I prefer "Grayscale" to false color "Rainbow" for assessing image quality. Also, you can change the scaling of the image using the "scaling power cycles" slider under "basic settings".<br />
<br />
Check the rms of the residuals using the {{imstat}} task:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw5_clean1280.residual')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
In this particular case, it's 31.8 uJy; yours will likely be slightly different.<br />
<br />
=== Cleaning the lower baseband ===<br />
<br />
[[Image:viewSN2010FZ_spw0to7_clean1280final.png|200px|thumb|right|clean spw0-7 restored image center]]<br />
Now, image the entire lower baseband (spw 0-7).<br />
Follow same iterative procedure as before, and get the best<br />
residuals you can without "cleaning the noise". <br />
<br />
* Because of the bandwidth and frequency synthesis, the sidelobe pattern is different than before and it is much easier to see fainter emission.<br />
* Be careful cleaning sources that lie near or on sidelobe splotches.<br />
* Clean the central emission region way down first to reduce the sidelobe level before adding components in the sidelobe areas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to7_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='0:16~59,1~6:4~59,7:4~54', \<br />
imagename='imgSN2010FZ10s_spw0to7_clean1280', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to7_clean1280.residual')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this run, the rms is 11.3 uJy (and there is clearly some structure left in the residual). To the right is a zoom-in on the center of the restored image.<br />
<br />
==== Cleaning the lower baseband using two MFS Taylor terms ====<br />
<br />
The mfs nterms=2 option creates two "Taylor Term" images - an average intensity image (with suffix <tt>.image.tt0</tt>) <br />
and a spectral slope image (with suffix <tt>.image.tt1</tt>) which is intensity x alpha (where alpha is spectral index).<br />
For convenience there is a spectral index image (with suffix <tt>.image.alpha</tt>). These Taylor expansions are with respect to the "Reference Frequency" of the image (by default the center frequency of the spw selected, but can be specified using the <tt>reffreq</tt> parameter in {{clean}}). The convention for spectral index alpha is that<br />
<br />
<math><br />
S \propto \nu^\alpha<br />
</math><br />
<br />
so negative spectral indexes indicate a "steep" spectrum (falling with frequency).<br />
<br />
[[Image:viewSN2010FZ_spw0to7_mfs2clean.png|200px|thumb|right|clean spw0-7 mfs nterms=2 in progress]]<br />
Let's try using multi-frequency synthesis with nterms=2 on the lower baseband.<br />
The dirty beam will have lower sidelobes so we turn up <tt>cyclefactor</tt> for <tt>csclean</tt> a bit. Note: if you're feeling a bit lazy, and trust your previous set of clean boxes, you can also set <tt>mask='imgSN2010FZ10s_spw0to7_clean1280.mask'</tt> to use these as a starting point:<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to7_mfs2_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='0:16~59,1~6:4~59,7:4~54', \<br />
imagename='imgSN2010FZ10s_spw0to7_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
weighting='briggs',robust=0.5,interactive=True,mask=[])<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to7_mfs2_clean1280.residual.tt0')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this run, the rms is 10.5 uJy (somewhat better-looking than the nterms=1).<br />
The top screenshot to the right shows an intermediate but early stage of cleaning where we are looking at<br />
the central emission and cleaning it out slowly.<br />
<br />
You can use the {{viewer}} to load the average intensity image:<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0')<br />
</source><br />
<br />
and then use the Open Data panel to load the spectral index image <tt>imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha</tt><br />
which can then be blinked (optionally plotted side-by-side using the Panel Display Options panel to set 2 panels in the x direction). <br />
<br />
[[Image:viewSN2010FZ_spw0to7_mfs2loadalpha_4.0.png|200px|thumb|right|clean spw0-7 mfs nterms=2 load alpha with LEL]]<br />
[[Image:viewSN2010FZ_spw0to7_mfs2panelalpha_4.0.png|200px|thumb|right|clean spw0-7 mfs nterms=2 tt0 and alpha (filtered at 0.1mJy in tt0)]]<br />
<br />
Note there is a lot of noise in alpha in the low-intensity regions, and thus filtering the alpha image based on the values in the tt0 image is desirable. You can use the {{immath}} task to make this filtered alpha image explicitly, using a <br />
Lattice Expression Language (LEL) expression: <br />
<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename=['imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha', <br />
'imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM1>1.0E-4]',<br />
outfile='imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha.filtered')<br />
</source><br />
<br />
This will use 0.1 mJy (or 10 x the sigma we found) as the cutoff.<br />
You can then view or manipulate the filtered alpha image as normal.<br />
<br />
We can also use LEL to filter the alpha image on the intensity on-the-fly when we load this raster in the Open Data panel<br />
by specifying a LEL string in the LEL box instead of selecting the image from the directory <br />
listing. The LEL string:<br />
<br />
<pre><br />
'imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha'['imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0'>1.0E-04]<br />
</pre><br />
<br />
will replicate what we did above. The middle figure to the right shows the Open Data panel<br />
with our LEL string in it. Just click the Raster button to load this.<br />
<br />
The lower panel to the right shows the intensity and LEL-filtered alpha images side-by-side in the viewer, zoomed<br />
in on the galaxy emission. Mousing over the alpha shows spectral indexes ranging from -1 to +1 in the center, with<br />
the brightest emission with alpha -0.7 in the knots in the disk.<br />
<br />
=== Cleaning using both basebands combined ===<br />
<br />
For the ultimate image, use the "clean" part of the upper baseband in addition<br />
to the lower (use spw 0-11). We will use mfs with nterms=2 (if you try nterms=1 <br />
on this wide bandwidth you will get much poorer residuals). Because of the added<br />
work and extra data involved, this will take much longer than our other runs of<br />
clean. Therefore, we will get a head start by doing a non-interactive clean using<br />
the mask left from the previous clean (spw 0-7). We will insert a clean threshold<br />
to limit runaway cleaning too far beneath the noise level. <br />
<br />
This will take a while, especially if there are other processes running on your machine (with nothing else running, expect ~30-40 minutes).<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
imagename='imgSN2010FZ10s_spw0to11_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=3000,gain=0.1,threshold='0.002mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
mask=['imgSN2010FZ10s_spw0to7_mfs2_clean1280.mask'], \<br />
weighting='briggs',robust=0.5,interactive=False)<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.residual.tt0')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this particular run, the rms was 8.9 uJy (noticeably better than the lower baseband only results).<br />
<br />
[[Image:viewSN2010FZ spw0to11_mfs2resid.png|200px|thumb|right|final residual and mask]]<br />
<br />
Let us see if there is more to clean. Bring this up in interactive mode:<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='SN2010FZ_split10s.ms', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
imagename='imgSN2010FZ10s_spw0to11_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=3000,gain=0.1,threshold='0.001mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
mask='imgSN2010FZ10s_spw0to11_mfs2_clean1280.mask', \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
This should start cleaning from where our previous non-interactive clean left off.<br />
<b>Note for 4.2.0:</b> In this case we have specified <tt>mask='imgSN2010FZ10s_spw0to11_mfs2_clean1280.mask'</tt> explicitly due to a bug where it will not otherwise allow you to edit the mask interactively.<br />
<br />
You might find a few more sources revealed in the outer parts of the image, and also more <br />
emission around the galaxy disk in the center. Try drawing new boxes, perhaps extend the box<br />
in the center, and do ~100-1000 more iterations. At the end, what is left should be dominated<br />
by the error patterns from mis-calibration. Only self-calibration will get rid of<br />
these. Stop cleaning for now. See the figure to the right for the interactive display panel<br />
showing final residuals and mask (changing the colormap to <tt>Greyscale 1</tt>).<br />
<br />
Check the residual levels:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.residual.tt0')<br />
sigma = mystat['sigma'][0]<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
The final rms achieved here is 8.7 uJy; slightly better.<br />
<br />
== Analyzing the image ==<br />
<br />
Let's see how close we got to expected noise and dynamic range:<br />
<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0')<br />
peak = mystat['max'][0]<br />
print 'Image max flux = '+str(mystat['max'][0])<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.model.tt0')<br />
total = mystat['sum'][0]<br />
print 'Model total flux = '+str(mystat['sum'][0])<br />
#<br />
snr = peak/sigma<br />
print 'SN2010FZ peak S/N = '+str(snr)<br />
#<br />
snr = total/sigma<br />
print 'SN2010FZ total S/N = '+str(snr)<br />
</source><br />
The output gives:<br />
<pre><br />
Residual standard deviation = 8.74577600158e-06<br />
Image max flux = 0.00993354152888<br />
Model total flux = 0.0341279412654<br />
SN2010FZ peak S/N = 1135.81019307<br />
SN2010FZ total S/N = 3902.2199127<br />
</pre><br />
These are the numbers I got in my run-through. You may get slightly different values depending on how deeply you cleaned.<br />
<br />
What do we expect? If we do {{listobs}} on this MS we see the scans:<br />
<pre><br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) <br />
11-Jul-2010/21:38:44.0 - 21:39:51.0 9 0 SN2010FZ 33696 9.16 <br />
21:40:01.0 - 21:41:20.5 10 0 SN2010FZ 37908 9.89 <br />
21:41:30.0 - 21:42:50.0 11 0 SN2010FZ 37908 10 <br />
21:43:00.0 - 21:44:20.0 12 0 SN2010FZ 37908 10 <br />
21:44:30.0 - 21:45:50.0 13 0 SN2010FZ 37908 10 <br />
21:46:00.0 - 21:47:19.5 14 0 SN2010FZ 37908 9.89 <br />
21:47:29.0 - 21:47:49.0 15 0 SN2010FZ 12636 9.67 <br />
21:49:42.0 - 21:50:49.0 17 0 SN2010FZ 33696 9.17 <br />
21:50:59.0 - 21:52:19.0 18 0 SN2010FZ 37908 10 <br />
21:52:29.0 - 21:53:48.5 19 0 SN2010FZ 37908 9.89 <br />
21:53:58.0 - 21:55:18.0 20 0 SN2010FZ 37908 10 <br />
21:55:28.0 - 21:56:48.0 21 0 SN2010FZ 37908 10 <br />
21:56:58.0 - 21:58:18.0 22 0 SN2010FZ 37908 10 <br />
21:58:28.0 - 21:58:47.5 23 0 SN2010FZ 12636 9.67 <br />
22:00:39.5 - 22:01:47.0 25 0 SN2010FZ 33696 9.18 <br />
22:01:57.0 - 22:03:17.0 26 0 SN2010FZ 37908 10 <br />
22:03:27.0 - 22:04:47.0 27 0 SN2010FZ 37908 10 <br />
22:04:57.0 - 22:06:16.5 28 0 SN2010FZ 37908 9.89 <br />
22:06:26.0 - 22:07:46.0 29 0 SN2010FZ 37908 10 <br />
22:07:56.0 - 22:09:16.0 30 0 SN2010FZ 37908 10 <br />
22:09:26.0 - 22:09:45.5 31 0 SN2010FZ 12636 9.67 <br />
22:11:38.0 - 22:12:45.5 33 0 SN2010FZ 33696 9.19 <br />
22:12:55.0 - 22:14:15.0 34 0 SN2010FZ 37908 10 <br />
22:14:25.0 - 22:15:45.0 35 0 SN2010FZ 37908 10 <br />
22:15:55.0 - 22:17:15.0 36 0 SN2010FZ 37908 10 <br />
22:17:25.0 - 22:18:44.5 37 0 SN2010FZ 37908 9.89 <br />
22:18:54.0 - 22:20:14.0 38 0 SN2010FZ 37908 10 <br />
22:20:24.0 - 22:20:43.5 39 0 SN2010FZ 12636 9.67 <br />
(nVis = Total number of time/baseline visibilities per scan) <br />
</pre><br />
(listing columns truncated) and we estimate about 37 minutes on target. We had about 25 antennas on average, and our spw selection picked out 610 channels (2 MHz each) for a total of 1220 MHz bandwidth. If we plug this<br />
into the<br />
[https://science.nrao.edu/facilities/evla/calibration-and-tools/exposure EVLA exposure calculator], at 5 GHz, we find that we expect a rms thermal noise level of 8.7 uJy, and at 7 GHz, 7.0 uJy. So, our values are within the expected range (a bit higher than theoretical, but that's expected). <br />
<br />
[[Image:plotSN2010FZ_viewerfinal.png|200px|thumb|right|final image]]<br />
Look at this in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0')<br />
</source><br />
Zoom in on the center (see figure to the right).<br />
<br />
[[Image:viewSN2010FZ_spw0to11_mfs2tt1.png|200px|thumb|right|final tt1 image with box]]<br />
In the previous section we demonstrated how to process and display the spectral index image. You can do<br />
the same for this final image. Here, we will do some rough analysis on the spectral index to determine<br />
an intensity-weighted mean spectral index over the core region.<br />
The <tt>.image.tt1</tt> from our mfs is an intensity times alpha image. See the figure to the right.<br />
Let's gate the Taylor-term images on intensity:<br />
<source lang="python"><br />
# In CASA<br />
# Removing any file output from previous runs, so immath will proceed<br />
os.system('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered')<br />
immath(imagename=['imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1',<br />
'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM1>5.0E-5]',<br />
outfile='imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered')<br />
#<br />
# Removing any file output from previous runs, so immath will proceed<br />
os.system('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered')<br />
immath(imagename=['imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM0>5.0E-5]',<br />
outfile='imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered')<br />
</source><br />
<br />
We can identify a box containing the central emission (see figure of tt1 in viewer) and note the corners.<br />
(We could also use the region tools from the viewer, but that is for another exercise.)<br />
Let us compute the intensity-weighted spectral index over this box by averaging<br />
these masked images using {{imstat}} and computing the ratio:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered',<br />
box='503,533,756,762')<br />
avgtt0alpha = mystat['mean'][0]<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered',<br />
box='503,533,756,762')<br />
avgtt0 = mystat['mean'][0]<br />
avgalpha = avgtt0alpha/avgtt0<br />
print 'SN2010FZ I-weighted Alpha = '+str(avgalpha)<br />
</source><br />
We get <br />
<pre><br />
SN2010FZ I-weighted Alpha = -1.38157453384<br />
</pre><br />
<br />
The emission in this source is on the steep side. At this point we do not know how reliable this is or<br />
what we expect (though our calibrators come out with correct spectral indexes if we image them the<br />
same way). But this illustrates a way to extract spectral information from our wideband mfs images.<br />
<br />
== Comparing with the Optical/Infrared ==<br />
<br />
As a final comparison, we turn to the Sloan Digital Sky Survey (SDSS) and a cutout image of our galaxy:<br />
[[Image:NGC_2967_UGC_5180_IRAS_09394+0033_irg.jpg|400px|thumb|center|]]<br />
from their [http://cosmo.nyu.edu/hogg/rc3/NGC_2967_UGC_5180_IRAS_09394+0033_irg.jpg RC3]<br />
album (courtesy D.Hogg, M.Blanton, SDSS collaboration - see [[#Credits]]). This looks like a nice nearby<br />
face-on spiral galaxy. How does our 6cm continuum emission line up with the optical?<br />
<br />
Here is the EVLA 6cm image side by side with a i-band image from the Sloan Digital Sky Survey (SDSS) registered to our image:<br />
<br />
[[Image:plotSN2010FZ viewerfinalandSDSS.png|600px|thumb|center|final and sdss image]]<br />
<br />
You can also find this image, named <tt>NGC_2967_UGC_5180_IRAS_09394+0033-i.fits</tt>, on the web at <tt>http://casa.nrao.edu/Data/EVLA/SN2010FZ/NGC_2967_UGC_5180_IRAS_09394+0033-i.fits</tt> (at the CASA workshop, it's in <tt>/data/casa/evla/</tt> or a similar location that will be given to you in the instructions). Load it into your viewer, and blink against our 6cm image.<br />
<br />
We can also plot one as a raster and the other overlaid as contours. You can load the SDSS image<br />
from the viewer Load Data panel and fiddle with contours. Once you know contour levels, you can<br />
also use the imview task to load a raster and contour image:<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={ 'file' : 'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'},<br />
contour = { 'file' : 'NGC_2967_UGC_5180_IRAS_09394+0033-i.fits',<br />
'levels' : [0.2, 0.5, 1, 1.5, 3],<br />
'base' : 0.0,<br />
'unit' : 1.0 } )<br />
</source><br />
<br />
The figure below shows the SDSS contours overlaid on our 6cm image (after fiddling with the <br />
colormap shift/slope for the EVLA raster image). <br />
<br />
[[Image:viewSN2010FZ_spw0to11_mfs2tt0plusSDSS.png|400px|thumb|center|6cm EVLA raster plus SDSS i-band contours]]<br />
<br />
Likewise, we can plot the SDSS image as a raster and overlay EVLA 6cm contours:<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={ 'file' : 'NGC_2967_UGC_5180_IRAS_09394+0033-i.fits',<br />
'scaling' : -2.0,<br />
'range' : [0,10] },<br />
contour = { 'file' : 'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0',<br />
'levels' : [0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56],<br />
'base' : 0.0,<br />
'unit' : 0.001 },<br />
zoom = { 'blc' : [397,300],<br />
'trc' : [1567,1231] } )<br />
</source><br />
<br />
This is shown in the figure below. Is the compact 6cm emission in upper left associated with a<br />
spiral arm?<br />
<br />
[[Image:viewSN2010FZ_spw0to11_SDSSiplusEVLA6cm.png|400px|thumb|center|SDSS i-band raster plus EVLA 6cm contours]]<br />
<br />
== What to do next: some exercises for the user ==<br />
<br />
Here are a number of things you can try after completing this tutorial:<br />
<br />
# Use self-calibration to improve the data and re-clean to make a better image. See [http://casaguides.nrao.edu/index.php?title=WorkshopSelfcal_(Caltech) this tutorial] for more information on self-calibration.<br />
# Use multi-scale clean by adding non-zero scales to the <tt>multiscale</tt> parameter.<br />
# Image the calibrators. What sort of dynamic range can you get on them? Is self-calibration needed (and if so what dynamic range do you get when you use it)?<br />
# Try the <tt>testautoflag</tt> task (in 3.3.0 and later) to automatically flag RFI from the upper sideband. There is more information on running <tt>testautoflag</tt> in [http://casaguides.nrao.edu/index.php?title=EVLA_Wide-Band_Wide-Field_Imaging:_G55.7_3.4 this tutorial].<br />
<br />
== Credits ==<br />
<br />
The EVLA data was taken by A. Soderberg et al. as part of project AS1015. See <br />
[https://science.nrao.edu/enews/3.8/index.shtml#evlanoise NRAO eNews 3.8] (1-Sep-2010) for more on this result.<br />
<br />
<blockquote><i><br />
The Expanded Very Large Array (EVLA) is a partnership of the United States, Canada, and Mexico. The EVLA is funded in the United States by the National Science Foundation, in Canada by the National Research Council, and in Mexico by the Comisión Nacional de Investigación CientÃfica y Tecnológica (CONICyT).<br />
</i></blockquote><br />
<br />
<blockquote><i><br />
The National Radio Astronomy Observatory is a facility of the National Science Foundation operated under cooperative agreement by Associated Universities, Inc.<br />
</i></blockquote><br />
<br />
SDSS image courtesy David Hogg & Michael Blanton, private communication. Data comes from<br />
SDSS DR7, see [http://adsabs.harvard.edu/abs/2009ApJS..182..543A Abazajian et. al 2009].<br />
<br />
<blockquote><i><br />
Funding for the SDSS and SDSS-II has been provided by the Alfred P. Sloan Foundation, the Participating Institutions, the National Science Foundation, the U.S. Department of Energy, the National Aeronautics and Space Administration, the Japanese Monbukagakusho, the Max Planck Society, and the Higher Education Funding Council for England. The SDSS Web Site is [http://www.sdss.org/].<br />
</i></blockquote><br />
<br />
<blockquote><i><br />
The SDSS is managed by the Astrophysical Research Consortium for the Participating Institutions. The Participating Institutions are the American Museum of Natural History, Astrophysical Institute Potsdam, University of Basel, University of Cambridge, Case Western Reserve University, University of Chicago, Drexel University, Fermilab, the Institute for Advanced Study, the Japan Participation Group, Johns Hopkins University, the Joint Institute for Nuclear Astrophysics, the Kavli Institute for Particle Astrophysics and Cosmology, the Korean Scientist Group, the Chinese Academy of Sciences (LAMOST), Los Alamos National Laboratory, the Max-Planck-Institute for Astronomy (MPIA), the Max-Planck-Institute for Astrophysics (MPA), New Mexico State University, Ohio State University, University of Pittsburgh, University of Portsmouth, Princeton University, the United States Naval Observatory, and the University of Washington.<br />
</i></blockquote><br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2&diff=15566EVLA Continuum Tutorial 3C391 CASA 4.22014-02-06T16:54:29Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]][[Category:Calibration]]<br />
This is the first part of the EVLA 3C391 data reduction tutorial. The second is [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] which follows on from this one.<br />
<br />
<b>This CASA Guide is for Version 4.2.0 of CASA.</b><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 EVLA early science 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) CASA Guides have 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 CASA Guide, 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. (note 5/6/13: tested and this no longer seems to be an issue [MK]) --><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. If you are running this Guide outside of a workshop (in which case the data are probably already on your machine), you may obtain it from here:<br />
[http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz http://casa.nrao.edu/Data/EVLA/3C391/3c391_ctm_mosaic_10s_spw0.ms.tgz] (dataset size: 3.1GB)<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). 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 />
<br />
* The initial Science Data Model (SDM) file was converted 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 />
All of these steps can be done directly from the NRAO Archive's Download page, by selecting "CASA MS" as the download format (it's a good idea to also check the "Create MS or SDM tar file" box), checking the "Apply flags generated during observing" box, and setting "Time Averaging" to 10s.<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. 5/6/13: removed this b/c the page is outdated. All steps can now be done directly from the Archive download page (added note). MK --><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')<br />
</source><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 />
##########################################<br />
##### Begin Task: listobs #####<br />
listobs(vis="3c391_ctm_mosaic_10s_spw0.ms",selectdata=True,spw="",field="",<br />
antenna="",uvrange="",timerange="",correlation="",scan="",<br />
intent="",feed="",array="",observation="",verbose=True,<br />
listfile="",listunfl=False,cachesize=50)<br />
================================================================================<br />
MeasurementSet Name: 3c391_ctm_mosaic_10s_spw0.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. James Miller-Jones Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 845379 Total integration time = 28671.5 seconds<br />
Observed from 24-Apr-2010/08:02:15.0 to 24-Apr-2010/16:00:06.5 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
24-Apr-2010/08:02:10.4 - 08:02:29.5 1 0 J1331+3030 650 [0] [10] <br />
08:02:24.5 - 08:09:29.1 2 0 J1331+3030 13975 [0] [10] <br />
08:09:24.0 - 08:16:28.0 3 0 J1331+3030 13975 [0] [10] <br />
08:19:38.0 - 08:24:26.5 4 1 J1822-0938 7035 [0] [10] <br />
08:24:48.0 - 08:29:46.5 5 2 3C391 C1 7590 [0] [10] <br />
08:29:41.5 - 08:34:46.0 6 3 3C391 C2 7821 [0] [10] <br />
08:34:41.0 - 08:39:45.5 7 4 3C391 C3 7821 [0] [10] <br />
08:39:39.0 - 08:44:45.0 8 5 3C391 C4 7821 [0] [10] <br />
08:44:40.0 - 08:49:44.5 9 6 3C391 C5 7843 [0] [10] <br />
08:49:39.4 - 08:54:44.5 10 7 3C391 C6 7843 [0] [10] <br />
08:54:39.5 - 08:59:43.5 11 8 3C391 C7 7843 [0] [10] <br />
09:00:03.0 - 09:01:31.0 12 1 J1822-0938 2925 [0] [10] <br />
09:01:52.0 - 09:06:50.5 13 2 3C391 C1 7941 [0] [10] <br />
09:06:45.5 - 09:11:50.0 14 3 3C391 C2 9801 [0] [10] <br />
09:11:45.0 - 09:16:49.5 15 4 3C391 C3 10075 [0] [10] <br />
09:16:44.5 - 09:21:49.0 16 5 3C391 C4 10050 [0] [10] <br />
09:21:44.0 - 09:26:48.5 17 6 3C391 C5 10075 [0] [10] <br />
09:26:43.5 - 09:31:48.5 18 7 3C391 C6 10075 [0] [10] <br />
09:31:43.5 - 09:36:47.5 19 8 3C391 C7 10075 [0] [10] <br />
09:37:07.0 - 09:38:35.0 20 1 J1822-0938 2900 [0] [10] <br />
09:38:57.0 - 09:43:55.0 21 2 3C391 C1 9700 [0] [10] <br />
09:43:50.0 - 09:48:54.5 22 3 3C391 C2 10050 [0] [10] <br />
09:48:49.5 - 09:53:54.0 23 4 3C391 C3 10075 [0] [10] <br />
09:53:49.0 - 09:58:53.5 24 5 3C391 C4 10075 [0] [10] <br />
09:58:48.5 - 10:03:53.0 25 6 3C391 C5 10075 [0] [10] <br />
10:03:48.0 - 10:08:52.5 26 7 3C391 C6 10075 [0] [10] <br />
10:08:47.5 - 10:13:47.0 27 8 3C391 C7 9750 [0] [10] <br />
10:14:12.0 - 10:15:39.5 28 1 J1822-0938 2925 [0] [10] <br />
10:16:01.0 - 10:20:58.5 29 2 3C391 C1 9000 [0] [10] <br />
10:20:53.5 - 10:25:58.6 30 3 3C391 C2 10050 [0] [10] <br />
10:25:53.5 - 10:30:58.0 31 4 3C391 C3 10075 [0] [10] <br />
10:30:53.0 - 10:35:57.5 32 5 3C391 C4 10075 [0] [10] <br />
10:35:52.5 - 10:40:57.0 33 6 3C391 C5 10075 [0] [10] <br />
10:40:52.0 - 10:45:56.5 34 7 3C391 C6 10075 [0] [10] <br />
10:45:51.5 - 10:50:51.0 35 8 3C391 C7 9750 [0] [10] <br />
10:51:15.0 - 10:52:42.5 36 1 J1822-0938 2925 [0] [10] <br />
10:55:14.0 - 10:57:42.0 37 0 J1331+3030 3364 [0] [10] <br />
11:00:13.0 - 11:02:41.0 38 1 J1822-0938 3883 [0] [10] <br />
11:03:03.0 - 11:08:01.0 39 2 3C391 C1 9750 [0] [10] <br />
11:07:56.0 - 11:12:50.5 40 3 3C391 C2 9725 [0] [10] <br />
11:12:45.5 - 11:17:40.1 41 4 3C391 C3 9750 [0] [10] <br />
11:17:35.0 - 11:22:29.5 42 5 3C391 C4 9750 [0] [10] <br />
11:22:24.5 - 11:27:19.5 43 6 3C391 C5 9750 [0] [10] <br />
11:27:14.5 - 11:32:09.0 44 7 3C391 C6 9750 [0] [10] <br />
11:32:04.0 - 11:36:53.0 45 8 3C391 C7 9425 [0] [10] <br />
11:37:21.0 - 11:38:47.0 46 1 J1822-0938 2700 [0] [10] <br />
11:39:11.0 - 11:44:07.0 47 2 3C391 C1 9750 [0] [10] <br />
11:44:02.0 - 11:48:56.5 48 3 3C391 C2 9700 [0] [10] <br />
11:48:51.5 - 11:53:41.0 49 4 3C391 C3 8355 [0] [10] <br />
11:53:41.0 - 11:58:30.5 50 5 3C391 C4 9425 [0] [10] <br />
11:58:25.5 - 12:03:20.5 51 6 3C391 C5 9725 [0] [10] <br />
12:03:15.5 - 12:08:10.0 52 7 3C391 C6 9701 [0] [10] <br />
12:08:05.0 - 12:12:59.0 53 8 3C391 C7 9725 [0] [10] <br />
12:13:29.0 - 12:14:48.0 54 1 J1822-0938 2600 [0] [10] <br />
12:15:18.0 - 12:20:07.5 55 2 3C391 C1 9425 [0] [10] <br />
12:20:02.5 - 12:24:57.0 56 3 3C391 C2 9750 [0] [10] <br />
12:24:51.5 - 12:29:46.5 57 4 3C391 C3 9750 [0] [10] <br />
12:29:41.5 - 12:34:36.5 58 5 3C391 C4 9725 [0] [10] <br />
12:34:31.5 - 12:39:26.0 59 6 3C391 C5 9725 [0] [10] <br />
12:39:19.5 - 12:44:15.5 60 7 3C391 C6 9750 [0] [10] <br />
12:44:10.5 - 12:49:04.5 61 8 3C391 C7 9750 [0] [10] <br />
12:49:34.9 - 12:50:53.0 62 1 J1822-0938 2600 [0] [10] <br />
12:51:24.0 - 12:56:12.5 63 2 3C391 C1 9425 [0] [10] <br />
12:56:07.5 - 13:01:02.0 64 3 3C391 C2 9000 [0] [10] <br />
13:00:57.0 - 13:05:51.5 65 4 3C391 C3 9750 [0] [10] <br />
13:05:46.5 - 13:10:41.5 66 5 3C391 C4 9750 [0] [10] <br />
13:10:36.5 - 13:15:31.0 67 6 3C391 C5 9725 [0] [10] <br />
13:15:25.9 - 13:20:20.5 68 7 3C391 C6 9750 [0] [10] <br />
13:20:15.5 - 13:25:10.0 69 8 3C391 C7 9000 [0] [10] <br />
13:25:40.0 - 13:26:57.5 70 1 J1822-0938 2600 [0] [10] <br />
13:27:28.0 - 13:32:16.5 71 2 3C391 C1 9425 [0] [10] <br />
13:32:10.5 - 13:37:06.0 72 3 3C391 C2 9750 [0] [10] <br />
13:37:01.0 - 13:41:55.5 73 4 3C391 C3 9750 [0] [10] <br />
13:41:50.5 - 13:46:45.5 74 5 3C391 C4 9750 [0] [10] <br />
13:46:40.5 - 13:51:35.0 75 6 3C391 C5 9725 [0] [10] <br />
13:51:30.0 - 13:56:24.5 76 7 3C391 C6 9750 [0] [10] <br />
13:56:19.5 - 14:01:14.0 77 8 3C391 C7 9750 [0] [10] <br />
14:01:44.0 - 14:03:01.5 78 1 J1822-0938 2024 [0] [10] <br />
14:03:33.0 - 14:08:21.0 79 2 3C391 C1 8900 [0] [10] <br />
14:08:14.5 - 14:13:10.5 80 3 3C391 C2 9750 [0] [10] <br />
14:13:05.3 - 14:18:00.5 81 4 3C391 C3 9750 [0] [10] <br />
14:17:55.5 - 14:22:50.0 82 5 3C391 C4 9350 [0] [10] <br />
14:22:45.0 - 14:27:39.5 83 6 3C391 C5 9000 [0] [10] <br />
14:27:34.5 - 14:32:29.0 84 7 3C391 C6 8595 [0] [10] <br />
14:32:24.0 - 14:37:18.5 85 8 3C391 C7 7590 [0] [10] <br />
14:37:48.0 - 14:39:05.5 86 1 J1822-0938 1848 [0] [10] <br />
14:39:36.0 - 14:44:24.5 87 2 3C391 C1 7337 [0] [10] <br />
14:44:18.5 - 14:49:14.0 88 3 3C391 C2 7568 [0] [10] <br />
14:49:09.0 - 14:54:04.0 89 4 3C391 C3 7590 [0] [10] <br />
14:53:59.0 - 14:58:54.5 90 5 3C391 C4 7527 [0] [10] <br />
14:58:48.5 - 15:03:43.0 91 6 3C391 C5 7568 [0] [10] <br />
15:03:38.0 - 15:08:32.5 92 7 3C391 C6 7590 [0] [10] <br />
15:08:27.5 - 15:13:22.0 93 8 3C391 C7 7590 [0] [10] <br />
15:13:51.0 - 15:15:09.0 94 1 J1822-0938 1680 [0] [10] <br />
15:15:40.0 - 15:20:28.5 95 2 3C391 C1 7337 [0] [10] <br />
15:20:22.5 - 15:25:18.0 96 3 3C391 C2 7568 [0] [10] <br />
15:25:12.0 - 15:30:08.0 97 4 3C391 C3 7590 [0] [10] <br />
15:30:01.5 - 15:34:57.5 98 5 3C391 C4 7564 [0] [10] <br />
15:34:52.5 - 15:39:47.0 99 6 3C391 C5 7260 [0] [10] <br />
15:39:42.0 - 15:44:36.5 100 7 3C391 C6 6930 [0] [10] <br />
15:44:31.5 - 15:49:26.0 101 8 3C391 C7 6930 [0] [10] <br />
15:49:55.0 - 15:51:13.5 102 1 J1822-0938 1088 [0] [10] <br />
15:54:52.0 - 16:00:11.5 103 9 J0319+4130 8768 [0] [10] <br />
(nRows = Total number of rows per scan) <br />
Fields: 10<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 N J1331+3030 13:31:08.287984 +30.30.32.95886 J2000 0 31964<br />
1 J J1822-0938 18:22:28.704200 -09.38.56.83501 J2000 1 39733<br />
2 NONE 3C391 C1 18:49:24.244000 -00.55.40.58001 J2000 2 105580<br />
3 NONE 3C391 C2 18:49:29.149001 -00.57.48.00001 J2000 3 110533<br />
4 NONE 3C391 C3 18:49:19.339000 -00.57.48.00001 J2000 4 110331<br />
5 NONE 3C391 C4 18:49:14.434001 -00.55.40.58001 J2000 5 110862<br />
6 NONE 3C391 C5 18:49:19.339000 -00.53.33.16000 J2000 6 110546<br />
7 NONE 3C391 C6 18:49:29.149001 -00.53.33.16000 J2000 7 109884<br />
8 NONE 3C391 C7 18:49:34.054000 -00.55.40.58001 J2000 8 107178<br />
9 Z J0319+4130 03:19:48.160102 +41.30.42.10305 J2000 9 8768<br />
Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 Subband:0 64 TOPO 4536.000 2000.000 128000.0 RR RL LR LL<br />
Sources: 10<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1331+3030 0 - - <br />
1 J1822-0938 0 - - <br />
2 3C391 C1 0 - - <br />
3 3C391 C2 0 - - <br />
4 3C391 C3 0 - - <br />
5 3C391 C4 0 - - <br />
6 3C391 C5 0 - - <br />
7 3C391 C6 0 - - <br />
8 3C391 C7 0 - - <br />
9 J0319+4130 0 - - <br />
Antennas: 26:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 -521.9407 -332.7782 -1.1977 -1601710.017000 -5042006.928200 3554602.355600<br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 9.8247 -20.4292 -2.7808 -1601150.059500 -5042000.619800 3554860.729400<br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 506.0591 -251.8666 -3.5832 -1600715.948000 -5042273.187000 3554668.184500<br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 -27.3562 -41.3030 -2.7418 -1601189.030140 -5042000.493300 3554843.425700<br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 -432.1158 -272.1493 -1.5032 -1601614.091000 -5042001.655700 3554652.509300<br />
5 ea07 N06 25.0 m -107.37.06.9 +33.54.10.3 -54.0667 263.8720 -4.2292 -1601162.593200 -5041829.000000 3555095.890500<br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 -30.8810 -1.4664 -2.8597 -1601185.634945 -5041978.156586 3554876.424700<br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 236.9058 -126.3369 -2.4443 -1600951.588000 -5042125.911000 3554773.012300<br />
8 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 102.8046 -63.7684 -2.6412 -1601068.791200 -5042051.910200 3554824.835300<br />
9 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 407.8394 -206.0057 -3.2252 -1600801.916000 -5042219.371000 3554706.449900<br />
10 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 -61.1040 344.2335 -4.6144 -1601155.635800 -5041783.843000 3555162.374100<br />
11 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 164.9788 -92.8032 -2.5268 -1601014.462000 -5042086.252000 3554800.799800<br />
12 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 -275.8288 -166.7451 -2.0590 -1601447.198000 -5041992.502500 3554739.687600<br />
13 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 -67.9687 -26.5614 -2.7175 -1601225.255200 -5041980.383590 3554855.675000<br />
14 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 -349.9866 -216.7507 -1.7978 -1601526.386100 -5041996.840100 3554698.327400<br />
15 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 -77.4352 530.6274 -5.5867 -1601139.485500 -5041679.036000 3555316.532800<br />
16 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 -152.8599 -83.8054 -2.4614 -1601315.893000 -5041985.320170 3554808.304600<br />
17 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 -47.8454 192.6015 -3.8723 -1601168.786100 -5041869.054000 3555036.936000<br />
18 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 -23.8638 -81.1510 -2.5851 -1601192.467800 -5042022.856800 3554810.438800<br />
19 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 -42.5986 132.8623 -3.5431 -1601173.953700 -5041902.660400 3554987.536500<br />
20 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 318.0523 -164.1848 -2.6960 -1600880.570000 -5042170.388000 3554741.457400<br />
21 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 -210.0944 -122.3885 -2.2581 -1601377.008000 -5041988.665500 3554776.393400<br />
22 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 -35.6245 53.1806 -3.1345 -1601180.861480 -5041947.453400 3554921.628700<br />
23 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 -105.3429 -51.7191 -2.6054 -1601265.151700 -5041982.533050 3554834.856300<br />
24 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 50.6647 -39.4832 -2.7249 -1601114.365500 -5042023.153700 3554844.945600<br />
25 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 -68.9057 433.1889 -5.0602 -1601147.940400 -5041733.837000 3555235.956000<br />
##### End Task: listobs #####<br />
##########################################<br />
<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='plotants_3c391_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, <br />
mode='manual', scan='1')<br />
</source><br />
<br />
[[Image:screenshot_3C391_flagdata.png|200px|thumb|right|flagdata inputs]]<br />
<br />
* <tt>flagbackup=T</tt> : 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 />
* <tt>mode='manualflag'</tt> : Specific data are going to be selected to be edited. <br />
<!--* <tt>selectdata=T</tt> : 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, --><br />
* 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(vis="3c391_ctm_mosaic_10s_spw0.ms",mode="manual",autocorr=False,inpfile="",<br />
reason="any",spw="",field="",antenna="",uvrange="",<br />
timerange="",correlation="",scan="1",intent="",array="",<br />
observation="",feed="",clipminmax=[],datacolumn="DATA",clipoutside=True,<br />
channelavg=False,clipzeros=False,quackinterval=1.0,quackmode="beg",quackincrement=False,<br />
tolerance=0.0,addantenna="",lowerlimit=0.0,upperlimit=90.0,ntime="scan",<br />
combinescans=False,timecutoff=4.0,freqcutoff=3.0,timefit="line",freqfit="poly",<br />
maxnpieces=7,flagdimension="freqtime",usewindowstats="none",halfwin=1,winsize=3,<br />
timedev="",freqdev="",timedevscale=5.0,freqdevscale=5.0,spectralmax=1000000.0,<br />
spectralmin=0.0,extendpols=True,growtime=50.0,growfreq=50.0,growaround=False,<br />
flagneartime=False,flagnearfreq=False,minrel=0.0,maxrel=1.0,minabs=0,<br />
maxabs=-1,spwchan=False,spwcorr=False,basecnt=False,action="apply",<br />
display="",flagbackup=True,savepars=False,cmdreason="",outfile="")<br />
Backup original flags before applying new flags<br />
Table type is Measurement Set<br />
Creating new backup flag file called flagdata_1<br />
Table type is Measurement Set<br />
Manual mode is active<br />
Parsing the parameters for the manual mode<br />
Initializing the agents<br />
Manual autocorr is 0<br />
There are 1 valid agents in list<br />
Running the agentflagger tool<br />
------------------------------------------------------------------------------------ <br />
Chunk = 1 [progress: 100%], Observation = 0, Array = 0, Scan = 1, Field = 0 (J1331+3030), Spw = 0, Channels = 64, Corrs = [ RR RL LR LL ], Total Rows = 650<br />
Manual => Data flagged so far 100%<br />
==================================================================================== <br />
=> Percentage of data flagged in table selection: 100%<br />
=> Writing flags to the MS<br />
##### End Task: flagdata #####<br />
##########################################<br />
</pre><br />
<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 <tt>flagdata_1</tt>. Should one ever desire to revert to the data prior to this run, the task {{flagmanager}} could be used. Also note<br />
that the values of all the task parameters (explicit or hidden) are given at the start of the task listing.<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='manual', <br />
antenna='ea13,ea15')<br />
</source><br />
* <tt>antenna='ea13,ea15'</tt> : 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 />
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', <br />
quackinterval=10.0, quackmode='beg')<br />
</source><br />
* <tt>mode='quack'</tt> : Quack is another mode in which the same edit will be applied to all scans for all baselines.<br />
* <tt>quackmode='beg'</tt> : 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 />
* <tt>quackinterval=10</tt> : 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 />
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', selectdata=True, field='0')<br />
</source><br />
<br />
[[Image:3C391_plotms.png|200px|thumb|right|plotms inputs]]<br />
* <tt>selectdata=T</tt> : One can choose to plot only subsets of the data.<br />
* <tt>field='0'</tt> : 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, but it is possible to select them from within the {{plotms}} GUI. <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 discussed above (using ''field=' ' '').<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 ''UVwave'' as the x-axis in the {{plotms}} GUI.)<br />
<br />
[[Image:plotms-3C286-UVDist_vs_Amp.png|200px|left|thumb|plotms view vs. uvdist of 3C 286]]<br />
[[Image:plotms-3C391-UVDist_vs_Amp.png|200px|center|thumb|plotms view vs. uvdist of 3C 391]]<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 />
[[Image:plotms_3c391-datastream.png|200px|right|thumb|datastream view of MS]]<br />
One final useful plot we will make is a "datastream" plot of the antenna2 in a baseline for the data versus ea01. This shows (assuming ea01 is there the entire run) when various antennas drop out.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='ea01',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
<br />
See the plot to right (after fiddling with the symbol sizes to improve visibility). From this display you can see that antenna 3 (ea04) is missing the last scan on 3C84 (which will have some implications later on), antennas 1,6,13 (ea02,ea08,ea16) have some missing blocks of time in the middle of the run, and 23 (ea26) is missing a scan or two near the end.<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 />
=== <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 />
The calculations are inserted via [[gencal]] which (for CASA 3.4 and later) allows automated lookup of the corrections. To see how to calculate corrections manually, go to the [http://www.vla.nrao.edu/astro/archive/baselines/ EVLA/VLA Baseline Corrections] site.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.antpos',caltype='antpos')<br />
</source><br />
<br />
In the logger you can see the corrections reported:<br />
<pre style="background-color: #ffe4b5;"><br />
##########################################<br />
##### Begin Task: gencal #####<br />
gencal(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.antpos",caltype="antpos",spw="",<br />
antenna="",pol="",parameter=[])<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.01000 0.00450 -0.00170<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.02570 0.00270 -0.01900<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
Beginning specifycal-----------------------<br />
Creating KAntPos Jones table from specified parameters.<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.antpos<br />
##### End Task: gencal #####<br />
##########################################<br />
</pre><br />
<br />
This corresponds to what is found in the database for 2010:<br />
<pre style="background-color: #E0FFFF;"><br />
; 2010 BASELINE CORRECTIONS IN METERS<br />
;ANT<br />
;MOVED OBSDATE Put_In_ MC(IAT) ANT PAD Bx By Bz<br />
;<br />
JAN27 FEB12 FEB21 01:57 11 E04 0.0000 0.0000 0.0000<br />
JAN27 FEB12 FEB21 01:57 26 W03 -0.0170 0.0204 0.0041<br />
MAR24 MAR25 MAR26 18:28 17 W07 -0.0061 -0.0069 -0.0055<br />
APR21 MAY02 MAY04 23:25 12 E08 -0.0072 0.0045 -0.0017<br />
MAR09 MAY02 MAY04 23:25 22 N04 -0.0220 0.0040 -0.0190<br />
JUN08 JUN20 JUN22 03:00 10 N03 0.0046 -0.0196 0.0090<br />
JUL17 JUL18 21:44 1 W09 0.0000 0.0030 0.0000<br />
JUL17 JUL18 21:44 2 E02 -0.0008 0.0000 0.0000<br />
JUL17 JUL18 21:44 3 E09 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 5 W08 0.0000 0.0028 0.0000<br />
JUL01 JUL17 JUL18 21:44 6 N06 0.0022 0.0010 0.0059<br />
JUL17 JUL18 21:44 10 N03 0.0008 0.0030 -0.0014<br />
JUL17 JUL18 21:44 11 E04 0.0009 0.0000 0.0000<br />
JUL17 JUL18 21:44 12 E08 -0.0028 0.0000 0.0000<br />
JUL17 JUL18 21:44 13 N07 0.0000 -0.0008 0.0000<br />
JUL17 JUL18 21:44 17 W07 -0.0012 0.0000 0.0000 <br />
JUL17 JUL18 21:44 18 N09 0.0004 -0.0008 0.0004<br />
JUL17 JUL18 21:44 22 N04 -0.0037 -0.0013 0.0000<br />
JUL17 JUL18 21:44 23 E07 -0.0014 0.0000 0.0000<br />
JUL17 JUL18 21:44 24 W05 -0.0015 0.0000 0.0000<br />
JUL17 JUL18 21:44 26 W03 -0.0019 0.0000 0.0021<br />
JUL17 JUL18 21:44 27 E03 0.0000 0.0019 -0.0016<br />
AUG05 SEP15 SEP16 00:11 07 E05 0.0087 0.0137 0.0000<br />
SEP13 SEP15 SEP16 00:11 08 N10 0.0098 -0.0063 0.0059<br />
SEP13 SEP15 SEP16 00:11 10 N14 0.0124 -0.0050 0.0110<br />
SEP14 SEP15 SEP16 00:11 13 N12 0.0020 -0.0060 -0.0077<br />
SEP13 SEP15 SEP16 00:11 18 N16 -0.0035 0.0000 -0.0027<br />
SEP13 SEP15 SEP16 00:11 20 N18 0.0044 -0.0020 0.0000 <br />
OCT04 OCT06 OCT11 05:03 1 W18 -0.0087 0.0077 -0.0041<br />
OCT05 OCT06 OCT11 05:03 3 E18 -0.0131 -0.0143 0.0099<br />
OCT04 OCT06 OCT11 05:03 4 W10 0.0041 0.0032 0.0005<br />
OCT04 OCT06 OCT11 05:03 7 E14 0.0027 0.0154 0.0049<br />
OCT05 OCT06 OCT11 05:03 17 W14 -0.0141 0.0095 -0.0046<br />
OCT04 OCT06 OCT11 05:03 23 E16 0.0044 0.0045 -0.0076<br />
OCT05 OCT06 OCT11 05:03 24 W16 -0.0017 0.0004 0.0038<br />
OCT05 OCT06 OCT11 05:03 27 E10 0.0039 0.0188 -0.0060<br />
OCT06 OCT07 OCT12 20:12 21 E12 -0.0125 -0.0140 -0.0100<br />
OCT20 OCT22 OCT23 19:54 14 W12 0.0191 -0.0126 0.0032<br />
OCT22 OCT23 19:54 21 E12 0.0196 -0.0062 0.0051 <br />
DEC01 DEC04 DEC08 20:28 26 W02 -0.0130 0.0265 0.0187 <br />
</pre><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 />
To start, let's find the available calibrator models with {{setjy}} and the option <i>listmodels=True</i>:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms', listmodels=T)<br />
</source><br />
<br />
This command will show all available calibrator models:<br />
<pre style="background-color: #ffe4b5;"><br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
Since any image could be a potential calibrator model {{setjy}} will list all <i>*.im</i> and <i>*.mod</i> images in the working directory. In addition, it will list all models that are provided by NRAO with the CASA package, and they will be picked by their names. We will be using the C-band EVLA standard model for 3C286 which is aptly named '3C286_C.im':<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='Perley-Butler 2010',<br />
model='3C286_C.im',usescratch=False,scalebychan=True,spw='')<br />
</source><br />
<br />
<!--[[Image:3C391_setjy.png|200px|thumb|right|setjy inputs]]--><br />
* <tt>field='J1331+3030'</tt> : 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 />
* <tt>standard='Perley-Butler 2010'</tt> : 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 B. Butler in 2010); 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. The most recent standard, that users will want to use by default, is 'Perley-Butler 2013' - we use the 2010 standard for historical reasons. See <tt>help setjy</tt> for more details.<br />
* <tt>model='3C286_C.im'</tt> : Although above, from plotms, it was estimated that 3C 286 is roughly a point source, depending upon the frequency and configuration, the source may be slightly resolved. Fiducial model images have been determined from a painstaking set of observations, and, if one is available, it should be used to compensate for slight resolution effects. In this case, spectral window 0 (at 4.536 GHz) is in the C band, so the C-band model image is used. <br />
* <tt>usescratch=False</tt> : We will NOT force the writing of the model visibilities to the MODEL_DATA scratch column, to save disk space.<br />
* <tt>scalebychan=True</tt> : In order to take out the intrinsic spectral index of our flux density calibrator 3C286 when we use it as our bandpass calibrator, we let it calculate a flux density value per channel.<br />
* <tt>spw=' ' </tt>: The original data contained two spectral windows. Having split off spectral window 0, it is not necessary to specify spw. 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 />
##########################################<br />
##### Begin Task: setjy #####<br />
setjy::::casa setjy(vis="3c391_ctm_mosaic_10s_spw0.ms",field="J1331+3030",spw="",selectdata=False,<br />
setjy::::casa+ timerange="",scan="",intent="",observation="",scalebychan=True,<br />
setjy::::casa+ standard="Perley-Butler 2010",model="3C286_C.im",modimage="",listmodels=False,fluxdensity=-1,<br />
setjy::::casa+ spix=0.0,reffreq="1GHz",fluxdict={},useephemdir=False,interpolation="nearest",<br />
setjy::::casa+ usescratch=False)<br />
setjy::::casa standard=Perley-Butler 2010<br />
Imager::open() Opening MeasurementSet /lustre/smyers/Tutorials/3C391/4.2_Part1/3c391_ctm_mosaic_10s_spw0.ms<br />
setjy::::casa Using /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels/3C286_C.im for modimage.<br />
imager::setjy() Using channel dependent flux densities<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
imager::setjy() J1331+3030 (fld ind 0) spw 0 [I=7.8169, Q=0, U=0, V=0] Jy, (Perley-Butler 2010)<br />
imager::setjy() Using model image /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels/3C286_C.im<br />
imager::setjy() Scaling spw 0's model image by channel to I = [7.81908, 7.81688, 7.81468, 7.81248, 7.81028, 7.80808, 7.80588, 7.80369, 7.80149, 7.7993, 7.79711, 7.79492, 7.79273, 7.79055, 7.78836, 7.78618, 7.784, 7.78182, 7.77964, 7.77746, 7.77528, 7.77311, 7.77093, 7.76876, 7.76659, 7.76442, 7.76225, 7.76009, 7.75792, 7.75576, 7.7536, 7.75143, 7.74927, 7.74712, 7.74496, 7.7428, 7.74065, 7.7385, 7.73635, 7.7342, 7.73205, 7.7299, 7.72776, 7.72561, 7.72347, 7.72133, 7.71919, 7.71705, 7.71491, 7.71277, 7.71064, 7.70851, 7.70637, 7.70424, 7.70211, 7.69999, 7.69786, 7.69574, 7.69361, 7.69149, 7.68937, 7.68725, 7.68513, 7.68301] Jy (ch 0) for visibility prediction.<br />
imager::setjy() The model image's reference pixel is 0.00302169 arcsec from J1331+3030's phase center.<br />
imager::setjy() Will clear any existing model with matching field=J1331+3030 and spw=*<br />
Clearing model records in MS header for selected fields.<br />
J1331+3030 (id = 0) deleted.<br />
imager::data selection Selected 31964 out of 845379 rows.<br />
setjy::::casa ##### End Task: setjy #####<br />
##########################################<br />
</pre><br />
<br />
As set, the flux density scale is being calculated only for spectral window 0 (''spw='0' ''), as its the only one in the dataset. The flux density in each Stokes (IQUV) for the reference channel 0 is reported, followed by the I flux density in each channel of the spectral window that will be used to scale the data. 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 />
=== Initial Phase Calibration ===<br />
<br />
Before solving for the bandpass, we will do an initial phase calibration. 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 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 />
<br />
We solve for phase versus time for the central channels on our three calibrators:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0all', <br />
field='0,1,9', refant='ea21', spw='0:27~36',<br />
gaintype='G',calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G0all'</tt> : The gain solutions will be stored in an external table.<br />
* <tt>field='0,1,9'</tt> : Specify the calibrators. We will use this opportunity to inspect solutions for all calibrators to weed out bad data.<br />
* <tt>refant='ea21'</tt> : 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 />
* <tt>spw='0:27~36'</tt> : 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 />
* <tt>gaintype='G'</tt> : Compute G solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>calmode='p'</tt> : Solve for only the phase portion of the gain.<br />
* <tt>solint='int'</tt> : 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 />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable=['3c391_ctm_mosaic_10s_spw0.antpos']</tt> : Having produced antenna position corrections, they should now be applied.<br />
<br />
[[Image:plotcal-3C286-G0all-phase-R-ea05.png|200px|thumb|right|Initial gain phases, R polarization, Stepped through to show ea05]]<br />
To really see what is going on, we use {{plotcal}} to inspect the solutions for a single antenna at a time, iterating through each antenna in sequence, starting with the R polarization:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
You use the <b>Next</b> button on the GUI to advance the displayed antenna. In the Figure at the right we have stepped through to antenna <tt>ea05</tt>.<br />
<br />
<b>NOTE:</b> Sometimes plotcal will "lock" a table and/or keep it in the table cache beyond the end of plotting. This can hang up further use of that table, or cause errors if you delete the table (outside of CASA) and want to re-create it. To deal with that issue, simply close the plotcal GUI using the Quit button when you are done looking at the plot.<br />
<br />
Antennas that have been flagged will show a blank plot, as there are no solutions for these antennas. For most antennas, we see a fairly smooth variation with time, so we expect to be able to calibrate our data nicely. However, when you get top ea05, ote the phase jumps where it appears to be bouncing between two states. We can plot this antenna separately (see the figure to the right):<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',xaxis='time',yaxis='phase',antenna='ea05',<br />
poln='R',iteration='antenna',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G0all-phase-R-ea05.png')<br />
</source><br />
We see the same thing for the L polarization solutions:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G0all',<br />
xaxis='time', yaxis='phase', poln='L', <br />
iteration='antenna', plotrange=[-1,-1,-180,180])<br />
</source><br />
Antennas other than ea05 look OK.<br />
<br />
We will not be able to transfer calibration for antenna ea05 so we will delete it from the data:<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
flagbackup=T, mode='manual', antenna='ea05')<br />
</source><br />
<br />
For the following bandpass solution we need only solve for our bandpass calibrator, and we will do so now after flagging:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.G0', <br />
field='J1331+3030', refant='ea21', spw='0:27~36', calmode='p', solint='int', <br />
minsnr=5, gaintable=['3c391_ctm_mosaic_10s_spw0.antpos'])<br />
</source><br />
You can inspect this with {{plotcal}} as we did above. For example, plot R for the first block of 3C286 data only<br />
<source lang="python"><br />
# In CASA<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 />
You can do the same for L if you like.<br />
<br />
=== Delay Calibration ===<br />
<br />
The first stage of bandpass calibration involves solving for the antenna-based delays which put a phase ramp versus frequency channel in each spectral window. The K gain type in {{gaincal}} solves for the relative delays of each antenna relative to the <tt>refant</tt> (so be sure you pick one that is there for this entire scan and good). This is not a full global delay, but gives one value per spw per polarization.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.K0', <br />
field='J1331+3030',refant='ea21',spw='0:5~58',gaintype='K', <br />
solint='inf',combine='scan',minsnr=5,<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0'])<br />
</source><br />
<br />
* <tt>field='J1331+3030'</tt> : For the bandpass calibrator<br />
* <tt>refant='ea21'</tt> : Delays will be relative to this antenna, make sure it is there!<br />
* <tt>spw='0:5~58'</tt> : Widest possible frequency range in the spw, avoiding edge channels<br />
* <tt>gaintype='K'</tt> : Compute K solutions, one per antenna per spw per polarization per solution interval<br />
* <tt>solint='inf',combine='scan'</tt> : Only need one solution averaged over all times and scans<br />
* <tt>minsnr=5</tt> : 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 />
* <tt>gaintable</tt> : Use the antpos and G0 tables.<br />
<br />
[[Image:plotcal_3c391-K0-delay.png|200px|thumb|right|delay solutions]]<br />
We can plot these solutions (in nanoseconds) as a function of antenna:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.K0',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-K0-delay.png')<br />
</source><br />
These are within about 4 nanoseconds, as expected for the EVLA early science observations.<br />
<br />
=== Bandpass Calibration ===<br />
<br />
In this step one solves for the complex bandpass, <math>B_i</math>. <br />
[[Image:plotms-3C286-RRbandpass2.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 />
Now form the bandpass, 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', <br />
solint='inf',bandtype='B',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.G0',<br />
'3c391_ctm_mosaic_10s_spw0.K0'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.B0'</tt> : Specify where to store the bandpass corrections.<br />
* <tt>solnorm=T</tt> : Make sure that the average of the amplitudes of the bandpass corrections are normalized to unity (across the spw)<br />
* <tt>solint='inf', combine='scan'</tt> : 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 />
* <tt>bandtype='B'</tt> : 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 />
* <tt>gaintable</tt> : Pre-apply antenna positions, phase solutions, and delays.<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', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-R-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='amp',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',figfile='plotcal_3c391-3C286-B0-L-amp.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='R', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-R-phase.png')<br />
#<br />
plotcal(caltable= '3c391_ctm_mosaic_10s_spw0.B0',poln='L', <br />
xaxis='chan',yaxis='phase',field= 'J1331+3030',subplot=221, <br />
iteration='antenna',plotrange=[-1,-1,-180,180],<br />
figfile='plotcal_3c391-3C286-B0-L-phase.png')<br />
</source><br />
As expected, the bandpass phases (rightmost plots below) are relatively flat, with the slopes removed by the delay calibration. Residual excursions are on the order of a few degrees.<br />
<br />
{|<br />
| [[Image:plotcal_3c391-3C286-B0-R-amp.png|200px|thumb|left|bandpass amp for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-amp.png|200px|thumb|center|bandpass amp for 3C 286 L]]<br />
| [[Image:plotcal_3c391-3C286-B0-R-phase.png|200px|thumb|center|bandpass phase for 3C 286 R]]<br />
| [[Image:plotcal_3c391-3C286-B0-L-phase.png|200px|thumb|right|bandpass phase for 3C 286 L]]<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',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'])<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : 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 />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>gaintype='G', calmode='ap', solnorm=F</tt> : 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 />
* <tt>solint='inf'</tt> : Produce a solution for each scan. Phase coherence for these observations is good.<br />
* <tt>gaintable</tt>: Use the antenna position corrections, delays, and bandpass solutions determined earlier before solving for the gain amplitudes.<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. These will be solved separately, but in practice could be solved together as there are no gaintables that are time dependent at this point (and thus would risk having cross-source interpolation issues) nor are we doing different solution intervals per source.<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',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
#<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.G1',<br />
field='J0319+4130',<br />
spw='0:5~58',solint='inf',refant='ea21',gaintype='G',calmode='ap',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0'],<br />
append=True)<br />
</source><br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1', append=True</tt>: 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 />
<br />
If one checks the gain phase solutions using {{plotcal}}, one should see smooth solutions for each antenna as a function of time. <br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='R',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='phase',<br />
poln='L',plotrange=[-1,-1,-180,180],figfile='plotcal_3c391-G1-phase-L.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-G1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-G1-amp-L.png')<br />
</source><br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-R.png|200px|thumb|left|gain phase solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-phase-L.png|200px|thumb|center|gain phase solutions, L polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-R.png|200px|thumb|left|gain amp solutions, R polarization]]<br />
| [[Image:plotcal_3c391-G1-amp-L.png|200px|thumb|center|gain amp solutions, L polarization]]<br />
|}<br />
<br />
This is also a good time to check that our chosen reference antenna (ea21) has good phase stability (i.e., the phase difference between the right and left polarizations is stable with time). This is a prerequisite for accurate polarization calibration. To do this, we plot the complex polarization ratio:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.G1', xaxis='time', yaxis='phase',<br />
poln='/', plotrange=[-1,-1,-180,180], figfile='plotcal_3c391-G1-phase-rat.png')<br />
</source><br />
<br />
As can be seen in the plot, there is a bit of drift (a few degrees here and there), but no phase jumps. This means that ea21 is, indeed, a good choice for reference antenna.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-G1-phase-rat.png|200px|thumb|center|complex polarization ratio]]<br />
|}<br />
<br />
=== Polarization Calibration ===<br />
<br />
<strong>[If time is running short, skip this step and proceed to <br />
[[http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391#Applying_the_calibration Applying the Calibration]].]</strong> ("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 (measured to be 11.2% in C-band around the time of the observations), and a polarization position angle of 66 degrees (at most frequencies). For information on polarization calibrators suitable for VLA observations, see the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/pol VLA Observing Guide to Polarimetry]. The most recently determined values (given in a table at the bottom of the Polarimetry guide page) give 11.3% at 4.5GHz, but below we use the old value of 11.2% for consistency with the rest of the guide.<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.81694 Jy in channel 0 of spw 0, at 4536 MHz according to the {{listobs}} output. We therefore use python to find the polarized flux, P, and the values of Stokes Q and U at this reference channel:<br />
<source lang="python"><br />
# In CASA<br />
i0=7.81694 # Stokes I value for spw 0 ch 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 />
Furthermore, in CASA 3.4, we can introduce a spectral index to the flux densities. We do this by noting that our printout from {{setjy}} gave 7.68506 Jy in the last channel 127 (at 4663 MHz). Therefore we use python again to compute a spectral index<br />
<source lang="python"><br />
# In CASA<br />
alpha = log(7.68506/7.81694)/log(4663.0/4536.0)<br />
</source><br />
which gives <tt>alpha = -0.61618</tt>.<br />
<br />
We now set the values of Stokes I, Q and U for 3C 286, using {{setjy}} using these values. First, because we still have the old I-only model in the header, we will delete this:<br />
<source lang="python"><br />
# In CASA<br />
delmod('3c391_ctm_mosaic_10s_spw0.ms')<br />
</source><br />
NOTE: In CASA 4.0 if you do not do this <tt>delmod</tt> both the old and new models will be in the header and will be used, doubling the fluxes and confusing other tasks. In future releases we will have the second <tt>setjy</tt> properly replace the old model.<br />
<br />
Now we generate the polarization model:<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='3c391_ctm_mosaic_10s_spw0.ms',field='J1331+3030',standard='manual',<br />
spw='0',fluxdensity=[i0,q0,u0,0],spix=alpha,reffreq='4536.0MHz',<br />
scalebychan=True,usescratch=False)<br />
</source><br />
* <tt>standard='manual'</tt> : The user is going to supply the flux densities rather than giving a model<br />
* <tt>fluxdensity=[i0,q0,u0,0]</tt> : use the IQUV values for channel 0 calculated above<br />
* <tt>spix=alpha</tt> : Set the spectral index using the formula above (this will also apply to QU)<br />
* <tt>reffreq='4536.0MHz'</tt> : The frequency of channel 0 from listobs<br />
* <tt>scalebychan=True</tt> : let it compute a value per channel<br />
* <tt>usescratch=False</tt> : DO NOT create/use the MODEL_DATA column explicitly<br />
<br />
The Stokes V flux value has been set to zero, corresponding to no circular polarization. <br />
<br />
<b>Note:</b> In CASA 4.2 the <tt>setjy</tt> task parameters have changed, in particular the use of <tt>standard='manual'</tt> to specify flux densities. Beware when following this guide with earlier versions.<br />
<br />
We can see the results in the model column in {{plotms}}<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RR',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RR.png')<br />
</source><br />
showing our model source spectrum. We can see this translates to the spectrum in QU<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='amp',ydatacolumn='model',<br />
plotfile='plotms_3c391-model-amp-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
Finally, our R-L phase difference is constant at 66 degrees as desired:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='RL',<br />
timerange='08:02:00~08:17:00',antenna='ea01&ea02',<br />
xaxis='channel',yaxis='phase',ydatacolumn='model',<br />
plotrange=[-1,-1,-180,180],plotfile='plotms_3c391-model-phase-RL.png')<br />
</source><br />
<!-- *as of r24160, this crashes on MacOS X* --><br />
<br />
{| <br />
| [[Image:plotms_3c391-model-amp-RR.png|200px|thumb|left|model RR amplitudes]]<br />
| [[Image:plotms_3c391-model-amp-RL.png|200px|thumb|center|model RL amplitudes]]<br />
| [[Image:plotms_3c391-model-phase-RL.png|200px|thumb|right|model RL phases]]<br />
|}<br />
<br />
==== Solving for the Cross-Hand delays ====<br />
<br />
Just as we did for the parallel-hand (RR,LL) delays before bandpass calibration, we solve for the cross-hand (RL,LR) delays due to the residual delay difference between the R and L on the reference antenna (ea21) used for the original delay calibration. In our case we simply use 3C286 which has a strong polarized signal in the RL,LR correlations.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='3c391_ctm_mosaic_10s_spw0.ms', caltable='3c391_ctm_mosaic_10s_spw0.Kcross',<br />
field='J1331+3030', spw='0:5~58',<br />
gaintype='KCROSS', solint='inf', combine='scan', refant='ea21',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1'],<br />
gainfield=['','','','J1331+3030'],<br />
interp=['linear','nearest','nearest','linear'], parang=T)<br />
</source><br />
<br />
[[Image:plotcal_3c391-Kcross-delay.png|200px|thumb|right|cross-hand delay solutions]]<br />
We can plot these:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.Kcross',xaxis='antenna',yaxis='delay',<br />
figfile='plotcal_3c391-Kcross-delay.png')<br />
</source><br />
As expected there is a single value for R versus L (with L delay set to zero) across all antennas. The solution is reported in the logger, and is 7.149 ns. <!-- was 7.157 ns for parang=F --><br />
<br />
Note that if we did not solve for this delay, it would be absorbed into the phases per channel of the following Df and Xf solutions. This would not cause us problems, as we are not solving for the Q+iU polarization of our D-term calibrator (we are using unpolarized 3C84 for that) but if we were (e.g. using our gain calibrator J1822-0938 with <tt>poltype='Df+QU'</tt>) then this step would be essential.<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',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J0319+4130',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.D1'</tt> : {{polcal}} will create a new calibration table containing the leakage solutions, which we specify with the <tt>caltable</tt> argument.<br />
* <tt>field='J0319+4130'</tt> : The unpolarized source J0319+4130 (a.k.a. 3C 84) is used to solve for the leakage terms.<br />
* <tt>spw='0:5~58'</tt> : 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 />
* <tt>poltype='Df'</tt> : We will solve for the leakages (''D'') on a per-channel basis (''f'') assuming zero source polarization.<br />
* <tt>solint='inf'</tt> : One solution over the entire run (the default)<br />
* <tt>combine='scan'</tt> : Combine all scans together (the default)<br />
* <tt>gaintable</tt> : All of the previous corrections---antenna positions, K-delay, bandpass, Kcross-delay, and complex gain---are to be applied <br />
* <tt>gainfield</tt> : 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 />
* <tt>interp</tt> : The interpolation to be used for each gaintable.<br />
<br />
After polcal has finished running, you are strongly advised to examine the solutions with {{plotcal}}, to ensure that everything looks good.<br />
[[Image:plotcal_3c391-D1-ea01.png|thumb|Df amp vs. channel for ea01]]<br />
[[Image:plotcal_3c391-D1-phase-ea01.png|thumb|Df phase vs. channel for ea01]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='amp', <br />
spw='',field='',iteration='antenna')<br />
#<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='chan',yaxis='phase', <br />
spw='',field='',iteration='antenna',plotrange=[-1,-1,-180,180])<br />
</source><br />
This will produce plots similar to those 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. We can also display these in a single plot versus antenna index:<br />
[[Image:plotcal_3c391-D1.png|thumb|Df solutions for J0319+4130 versus antenna index]]<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D1',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D1.png')<br />
</source><br />
Note that there are no solutions for antenna ea04 - a bit of sleuthing will turn up that ea04 was missing for the scans on 3C84.<br />
<br />
If we want to rescue ea04 (which otherwise seems ok) then we turn to our gain calibrator. If we plot data for field 1 versus ParAngle in {{plotms}} then we see that it has sufficient range (>60 deg) in parallactic angle so should be useable as a calibrator with unknown polarization. We can make a new set of solutions:<br />
<source lang="python"><br />
# In CASA<br />
polcal(vis='3c391_ctm_mosaic_10s_spw0.ms',caltable='3c391_ctm_mosaic_10s_spw0.D2',<br />
field='J1822-0938',spw='0:5~58',<br />
refant='ea21',poltype='Df+QU',solint='inf',combine='scan',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross'],<br />
gainfield=['','','','J1822-0938',''],<br />
interp=['linear','nearest','nearest','linear','nearest'])<br />
</source><br />
<br />
* <tt>field='J1822-0938'</tt> : Our gain calibrator observed throughout the schedule block<br />
* <tt>poltype='Df+QU'</tt> : Solve for the leakages using a calibrator with unknown polarization but with good parallactic angle coverage, and simultaneously for the source polarization (averaged over frequency)<br />
* <tt>gainfield</tt> : For <tt>3c391_ctm_mosaic_10s_spw0.G1</tt> use only the solutions from J1822-0938 itself.<br />
<br />
[[Image:plotcal_3c391-D2.png|thumb|Df solutions for J1822-0938 versus antenna index]]<br />
We now plot this as we did before:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.D2',xaxis='antenna',yaxis='amp', <br />
figfile='plotcal_3c391-D2.png')<br />
</source><br />
Comparison of this plot with that for the D1 caltable shows that we get nearly identical results, but now ea04 (index 3) is present! That should give us some confidence in our leakage calibration as well.<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.D2</tt>) to the gain tables that are applied on-the-fly. Note that we are using the second D table we made as it included ea04.<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',combine='scan',<br />
poltype='Xf',solint='inf',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.G1',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross',<br />
'3c391_ctm_mosaic_10s_spw0.D2'],<br />
gainfield=['','','','J1331+3030','',''],<br />
interp=['linear','nearest','nearest','linear','nearest','nearest'])<br />
</source><br />
<br />
[[Image:plotcal_3c391-X1.png|thumb|Xf solutions versus channel.]]<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.<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.X1',xaxis='chan',yaxis='phase',<br />
figfile='plotcal_3c391-X1.png')<br />
</source><br />
Because the Xf term captures the residual R-L phase on the reference antenna over the array, there is one value for all antennas. Also, as we took out the RL delays using the Kcross solution, these Xf variations only span about 6 degress across the spectral window.<br />
<br />
At this point, you have all the necessary polarization calibration tables.<br />
<br />
=== Scaling the Amplitude Gains ===<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 />
myscale = fluxscale(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
caltable='3c391_ctm_mosaic_10s_spw0.G1', <br />
fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1', <br />
reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],<br />
incremental=False)<br />
</source><br />
* <tt>myscale = fluxscale()</tt> : fluxscale returns a dictionary of results, which we capture in the variable myscale<br />
* <tt>caltable='3c391_ctm_mosaic_10s_spw0.G1'</tt> : We provide {{fluxscale}} with the calibration table containing the amplitude gain solutions derived earlier.<br />
* <tt>fluxtable='3c391_ctm_mosaic_10s_spw0.fluxscale1'</tt> : We specify the name of the new output table to be written, which will contain the properly-scaled amplitude gains.<br />
* <tt>reference='J1331+3030'</tt> : We specify the source with the known flux density.<br />
* <tt>transfer=['J1822-0938,J0319+4130']</tt> : We specify the sources whose amplitude gains are to be rescaled.<br />
* <tt>incremental=False : Make a new output fluxtable replacing caltable with rescaled transfer gains. If <tt>True</tt> then the new table would be used in addition to caltable in subsequent applications.<br />
<br />
{{fluxscale}} will print to the CASA logger the derived flux densities of all calibrator sources specified with the ''transfer'' argument. These are also captured in the return variable from the task. 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 and spectral indexes for the secondary calibrators. Example output would be<br />
<pre style="background-color: #fffacd;"><br />
CASA <99>: myscale['1']<br />
Out[99]: <br />
{'0': {'fluxd': array([ 2.34086385, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.00638754, 0., 0., 0.]),<br />
'numSol': array([ 46., 0., 0., 0.])},<br />
'fieldName': 'J1822-0938',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
<br />
CASA <100>: myscale['9']<br />
Out[100]: <br />
{'0': {'fluxd': array([ 13.93360237, 0., 0., 0.]),<br />
'fluxdErr': array([ 0.03865676, 0., 0., 0.]),<br />
'numSol': array([ 44., 0., 0., 0.])},<br />
'fieldName': 'J0319+4130',<br />
'fitFluxd': 0.0,<br />
'fitFluxdErr': 0.0,<br />
'fitRefFreq': 0.0,<br />
'spidx': array([ 0., 0., 0.]),<br />
'spidxerr': array([ 0., 0., 0.])}<br />
</pre><br />
or in the logger<br />
<pre style="background-color: #fffacd;"><br />
##########################################<br />
##### Begin Task: fluxscale #####<br />
fluxscale(vis="3c391_ctm_mosaic_10s_spw0.ms",caltable="3c391_ctm_mosaic_10s_spw0.G1",fluxtable="3c391_ctm_mosaic_10s_spw0.fluxscale1",reference=['J1331+3030'],<br />
transfer=['J1822-0938,J0319+4130'],listfile="",append=False,refspwmap=[-1],incremental=False,<br />
fitorder=1)<br />
Opening MS: 3c391_ctm_mosaic_10s_spw0.ms for calibration.<br />
Initializing nominal selection to the whole MS.<br />
Beginning fluxscale--(MSSelection version)-------<br />
Found reference field(s): J1331+3030<br />
Found transfer field(s): J1822-0938 J0319+4130<br />
Flux density for J1822-0938 in SpW=0 is: 2.34086 +/- 0.00638755 (SNR = 366.473, N = 46)<br />
Flux density for J0319+4130 in SpW=0 is: 13.9336 +/- 0.0386569 (SNR = 360.442, N = 44)<br />
Storing result in 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
Writing solutions to table: 3c391_ctm_mosaic_10s_spw0.fluxscale1<br />
##### End Task: fluxscale #####<br />
##########################################<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 />
We plot the rescaled amplitudes from this table:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='R',figfile='plotcal_3c391-fluxscale1-amp-R.png')<br />
plotcal(caltable='3c391_ctm_mosaic_10s_spw0.fluxscale1',xaxis='time',yaxis='amp',<br />
poln='L',figfile='plotcal_3c391-fluxscale1-amp-L.png')<br />
</source><br />
You can see (in the plots shown below) that the amplitude gain factors are now similar across sources, compared to the raw factors in the G1 table.<br />
<br />
{| <br />
| [[Image:plotcal_3c391-fluxscale1-amp-R.png|200px|thumb|left|post-fluxscale amp solutions, R pol]]<br />
| [[Image:plotcal_3c391-fluxscale1-amp-L.png|200px|thumb|center|post-fluxscale amp solutions, L pol]]<br />
|}<br />
<br />
== Applying the Calibration ==<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 DATA column contains the original data. 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. If the dataset does not already have a <tt>CORRECTED_DATA</tt> scratch column, then one will be created in the first <tt>applycal</tt> run.<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 />
field='J1331+3030',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1331+3030','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J0319+4130',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J0319+4130','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
#<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='J1822-0938',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','nearest','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>gaintable</tt> : We provide a Python list of the calibration tables to be applied. This list must contain the antenna position corrections (in .antpos), the properly-scaled gain calibration for the amplitudes and phases (in .fluxscale1) which were just made using {{fluxscale}}, the parallel-hand delays (in .K0), the bandpass solutions (in .B0), the cross-hand delays (in .Kcross), the leakage calibration (in .D2 derived by our second solution), and the R-L phase corrections (in .X1).<br />
* <tt>gainfield, interp</tt> : 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 />
* <tt>calwt=[False]</tt> : At the time of writing, we are not yet using system calibration data to compute real (1/Jy<sup>2</sup>) 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. You can specify <tt>calwt</tt> on a per-table basis, here is set all to <tt>False</tt>.<br />
* <tt>parang</tt> : 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 .Kcross, .D2 and .X1 will not exist. In this case, you should leave out these tables from the ''gaintable'' list, and the corresponding sets of elements in the ''gainfield'' list each time you run {{applycal}} above. You should also set ''parang=False''.<br />
<br />
Finally, we apply the calibration to the target fields in the mosaic, linearly interpolating the gain solutions from the secondary calibrator, J1822-0938. In this case however, we want to apply the amplitude and phase gains derived from the secondary calibrator, J1822-0938, since that is close to the target source on the sky, and we assume that the gains applicable to the target source are very similar to those derived in the direction of the secondary calibrator. Of course, this is not strictly true, since the gains on J1822-0938 were derived at a different time and in a different position on the sky from the target. However, assuming that the calibrator was sufficiently close to the target, and the weather was sufficiently well-behaved, then this is a reasonable approximation, and should get us a sufficiently good calibration that we can later use self-calibration to correct for the small inaccuracies thus introduced.<br />
<br />
The procedure for applying the calibration to the target source is very similar to what we just did for the calibrator sources.<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='3c391_ctm_mosaic_10s_spw0.ms',<br />
field='2~8',<br />
gaintable=['3c391_ctm_mosaic_10s_spw0.antpos', <br />
'3c391_ctm_mosaic_10s_spw0.fluxscale1',<br />
'3c391_ctm_mosaic_10s_spw0.K0',<br />
'3c391_ctm_mosaic_10s_spw0.B0',<br />
'3c391_ctm_mosaic_10s_spw0.Kcross', <br />
'3c391_ctm_mosaic_10s_spw0.D2',<br />
'3c391_ctm_mosaic_10s_spw0.X1'],<br />
gainfield=['','J1822-0938','','','','',''], <br />
interp=['','linear','','','','',''],<br />
calwt=[False],<br />
parang=True)<br />
</source><br />
<br />
* <tt>field</tt> : We can calibrate all seven target fields at once by setting ''field='2~8' ''. <br />
* <tt>gainfield</tt> : In this case, we wish to use the gains derived on the secondary calibrator, for the reasons explained in the previous paragraph.<br />
* <tt>interp</tt> : This time, we linearly interpolate between adjacent calibrator scans, to compute the appropriate gains for the intervening observations of the target.<br />
<br />
{|<br />
| [[Image:plotms_3c391-fld0-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld0-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,RL,LR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-amp.png|thumb|amp vs channel for J1822-0938 RR,LL]]<br />
| [[Image:plotms_3c391-fld1-corrected-phase.png|thumb|phase vs channel for J1822-0938 RR,LL]]<br />
|}<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. We make some standard plots (see above):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld0-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='0',correlation='',<br />
timerange='08:02:00~08:17:00',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld0-corrected-phase.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='amp',ydatacolumn='corrected',<br />
plotfile='plotms_3c391-fld1-corrected-amp.png')<br />
#<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='channel',yaxis='phase',ydatacolumn='corrected',<br />
plotrange=[-1,-1,-180,180],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-phase.png')<br />
</source><br />
For 3C286 (leftmost plots) we see the polarized signal in the cross-hands. There is no sign of bad data remaining.<br />
<br />
[[Image:plotms_3c391-fld1-corrected-ampvsphase.png|thumb|corrected amplitude vs phase for J1822-0938]]<br />
Another nice display 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 />
<source lang="python"><br />
# In CASA<br />
plotms(vis='3c391_ctm_mosaic_10s_spw0.ms',field='1',correlation='RR,LL',<br />
timerange='',antenna='',avgtime='60s',<br />
xaxis='phase',xdatacolumn='corrected',yaxis='amp',ydatacolumn='corrected',<br />
plotrange=[-180,180,0,3],coloraxis='corr',<br />
plotfile='plotms_3c391-fld1-corrected-ampvsphase.png')<br />
</source><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 />
* <tt>outputvis</tt> : We give the name of the new measurement set to be written, which will contain the calibrated data on the science targets.<br />
* <tt>datacolumn</tt> : We use the CORRECTED_DATA column, containing the calibrated data which we just wrote using {{applycal}}.<br />
* <tt>field</tt> : We wish to put all the mosaic pointings into a single measurement set, for imaging and joint deconvolution.<br />
<br />
== Initial 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:plotms_3c391-mosaic0-uvwave.png|thumb|{{plotms}} plot showing Amplitude vs UV Distance in wavelengths for 3C 391 at 4600 MHz]]<br />
CASA has a single task, {{clean}} which both Fourier transforms the data and deconvolves the resulting image. For the purposes of this tutorial Part 1, we will make a simple mosaic clean image in Stokes I only. In Part 2 we will proceed to make multiscale mosaic images in IQUV and to analyze them.<br />
<br />
Setting the appropriate pixel size for imaging 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='uvwave',yaxis='amp',<br />
ydatacolumn='data', field='0',avgtime='30s',correlation='RR',<br />
plotfile='plotms_3c391-mosaic0-uvwave.png',overwrite=True)<br />
</source><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. For example, a cell size of 2.5 arcseconds will give just under 5 pixels per beam. <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. For the choice of <tt>ftmachine='mosaic'</tt> (our main mosaicing algorithm), you do not have to fit the mosaic inside the inner quarter of the total image in order to prevent image artifacts arising from aliasing, we just want to have a bit of padding around the outside. Although CASA has the feature that its Fourier transform engine (FFTW) does <em>not</em> require a strict power of 2 for the number of linear pixels in a given image axis, it is somewhat more efficient if the number of pixels on a side is a composite number divisible by <em>any pair of</em> 2 and 3 and/or 5. Because {{clean}} internally applies a padding of 1.2 (=3x2/5) choose 480, which is 2<sup>5</sup> x 3 x 5 (so 480 x 1.2 = 576 = 2<sup>6</sup> x 3<sup>2</sup>). We therefore set <tt>imsize=[480,480]</tt> and our mosaic fits comfortably inside the image.<br />
<br />
To make this simple clean image interactively:<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',<br />
imagename='3c391_ctm_spw0_noms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=5000,<br />
gain=0.1, threshold='1.0mJy',<br />
psfmode='clark',<br />
imagermode='mosaic', ftmachine='mosaic',<br />
multiscale=[0], <br />
interactive=True,<br />
imsize=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{{clean}} is a powerful task, with many inputs, and a certain amount of experimentation may be (likely is) required.<br />
* <tt>vis='3c391_ctm_mosaic_spw0.ms'</tt> : this split MS contains our 7-pt mosaic fields, now indexed as 0-6. Field 0 is the central field of the mosaic (you can use <tt>listobs</tt> to verify this).<br />
* <tt>imagename='3c391_ctm_spw0_noms_I'</tt> : our output images will all start with this, e.g. 3c391_ctm_spw0_noms_I.image<br />
* <tt>mode='mfs'</tt> : 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 />
* <tt>niter=25000,gain=0.1,threshold='1.0mJy'</tt> : 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 />
* <tt>interactive=True</tt> : 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. <br />
* <tt>imsize=[480,480],cell=['2.5arcsec']</tt> : See the discussion above regarding the setting of the image size and cell size. If only one value is specified, the same value is used in both directions.<br />
* <tt>stokes='I',psfmode='clark'</tt> : A single image will be made for total intensity I.<br />
* <tt>weighting='briggs',robust=0.5</tt> : 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.5 (which corresponds to something between natural and uniform weighting).<br />
* <tt>imagermode='mosaic', ftmachine='mosaic'</tt> : 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 />
* <tt>multiscale=[0]</tt> : For now, we will clean with a single scale of size 0 (a classic clean delta-function)<br />
* <tt>usescratch=False</tt> As in calibration, we will NOT require use of a physical MODEL_DATA scratch column.<br />
<br />
[[Image:screenshot_3c391_interclean_start_v4.0.png|thumb|Interactive clean at beginning, having selected polygon region and ready to double-click inside to set the mask.]]<br />
[[Image:screenshot_3c391_interclean_finish_v4.0.png|thumb|Interactive clean part-way through cleaning (after 3000 iterations)]]<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 closed polygonal icon. 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. 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 (we have only a single mfs channel in the image cube), and likewise for Stokes planes using the "All Polarizations" (you will need to set this when we image all the Stokes).<br />
<br />
At any stage in the cleaning, you can adjust the number of iterations that clean will do before returning to the GUI. By default this is set to 100 (see the "iterations" window in mid-upper left of panel). You probably want to set this to a high number for this mosaic due to the complicated structure, values from 1000 to 5000 later on seem to work. Note that this will override the <tt>niter</tt> that was set when you started the clean task. Clean will keep going until it reaches threshold or runs out of cycles (the "cycles" window to the right of the "iterations").<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. The second figure to the right shows the interactive clean panel late in the process (after cleaning around 10000 iterations). At this point we have used the polygon tool to draw around the emission. There is still signal left in the residual, and it would take forever to clean all that out using our standard clean! You should just quit after doing around 10000-20000 iterations total. We'll improve this in the next part of the tutorial.<br />
<br />
[[Image:screenshot_3c391_viewer_noms_final.png|thumb|{{viewer}} display of the Stokes I mosaic of 3C 391]]<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_noms_I.image')<br />
</source><br />
<br />
This will bring up a viewer window containing the image, which should look similar to that shown at right. 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 />
As we saw during the interactive cleaning, this single-scale delta-function cleaning is having problems cleaning out the large-scale emission. You can see the large "clean bowl" of negative emission surrounding the object, and the heavy pixelization of the emission at low levels. We'll try to improve on this in the next part of the tutorial.<br />
<br />
== Next Steps ==<br />
<br />
In Part 2 of the tutorial we will carry out the polarization imaging, self-calibration, and polarization analysis and display of the data.<br />
Continue with [http://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391 3C391 Tutorial Part 2: Image Analysis, Polarization, Self-calibration] <br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2&diff=15565EVLA Advanced Topics 3C391 CASA 4.22014-02-06T16:52:05Z<p>Smyers: </p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2&diff=15564EVLA Advanced Topics 3C391 CASA 4.22014-02-06T16:50:33Z<p>Smyers: /* Starting Point */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2&diff=15563EVLA Advanced Topics 3C391 CASA 4.22014-02-06T16:49:45Z<p>Smyers: /* Starting Point */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2&diff=15562EVLA Advanced Topics 3C391 CASA 4.22014-02-06T16:47:25Z<p>Smyers: /* On Your Own: 3C391 second frequency and G93.3+6.9 */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 [https://science.nrao.edu/facilities/vla/docs/manuals/oss VLA Observational Status Summary (OSS)] 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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_6cmWideband_Tutorial_SN2010FZ_CASA_4.2&diff=15561EVLA 6cmWideband Tutorial SN2010FZ CASA 4.22014-02-06T16:38:50Z<p>Smyers: /* Cleaning using both basebands combined */</p>
<hr />
<div>This is an Advanced EVLA data reduction tutorial that calibrates and images a 6-cm wide-band continuum dataset.<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><br />
== Overview ==<br />
<br />
This article describes the calibration and imaging of a single-pointing 6-cm EVLA wideband continuum dataset of the galaxy NGC2967 (UGC5180) which was the location of the supernova candidate SN2010FZ. No supernova was detected in this observation, but the galactic continuum emission from this face-on spiral is nicely imaged. The data were taken in with 1024 MHz of bandwidth in each of two widely spaced basebands (each comprised of 8 128-MHz spectral windows), spanning 4.5 to 7.5 GHz. We will use wideband imaging techniques in this tutorial.<br />
<br />
This is a more advanced tutorial, and if you are a relative novice (and <em>particularly</em> for EVLA continuum calibration and imaging), it is <em>strongly</em> recommended that you start with the [[EVLA Continuum Tutorial 3C391]] (at least read it through) before tackling this dataset. We will not include basic information on CASA processing in this tutorial.<br />
<br />
From the [http://casaguides.nrao.edu MainPage] of this guide you can find helpful information:<br />
* [[What is CASA?]]<br />
* [[Getting Started in CASA]]<br />
* [[CASA Reference Manuals]]<br />
* [[Hints, Tips, & Tricks]]<br />
* [[AIPS-to-CASA Cheat Sheet]]<br />
<br />
In this tutorial we will be invoking the tasks as function calls. You can cut and paste these to your casapy session. We also recommend that you copy all the commands you use, with any relevant commentary, to a text file. This is good practice when tackling large datasets. If you wish, you can use the [http://casaguides.nrao.edu/index.php?title=Extracting_scripts_from_these_tutorials Script Extractor] to create a file with the tutorial commands, which can subsequently be edited as desired.<br />
<br />
Occasionally we will be setting Python variables (e.g. as lists for flags) outside the function call so make sure you<br />
set those before running the task command. Note that when you call a CASA task as a function the task parameters you<br />
do not set in the function call (assuming there is at least one) will be set to their defaults, and will not use values<br />
you set in previous calls or outside the call. See [[Getting_Started_in_CASA#Task_Execution]] for more <br />
on calling tasks and setting parameters in the scripting interface.<br />
<br />
NOTE: If you find that the figures on the right margin of the browser window overlap the text too much and make reading difficult,<br />
go ahead and widen the browser window.<br />
<br />
== Obtaining the Data ==<br />
<br />
The data for this tutorial were taken with the EVLA under program AS1015 as the scheduling block (SB) <tt>AS1015_sb1658169_1.55388.89474846065</tt>, and was run on 2010-07-11 from 21:28 to 22:28 UT (size 37.74GB). <br />
<br />
The data can be directly downloaded from [http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz] (dataset size: 2.9 GB). For example, in you Linux terminal:<br />
<br />
<source lang="bash"><br />
wget http://casa.nrao.edu/Data/EVLA/SN2010FZ/SN2010FZ_10s.ms.tar.gz<br />
</source><br />
<br />
Your first step will be to unzip and untar the file in a terminal, before you start CASA:<br />
<br />
<source lang="bash"><br />
tar -xzvf SN2010FZ_10s.ms.tar.gz <br />
</source><br />
<br />
If you are brave enough, you can also get the data straight from the EVLA archive. Go to the [https://archive.nrao.edu/archive/advquery.jsp NRAO Science Data Archive], and search for project **AS1015**. Then select the <tt>AS1015_sb1658169_1.55388.89474846065</tt> dataset and choose to apply the online flags (check box "Apply flags generated during observing") and time-averaging of 10 seconds. (The data were taken in D-configuration [max baselines 1km], so one can safely average to 3s or even 10s to reduce dataset size.) Also select the tar option. This will create a file equivalent to what is used at the workshop.<br />
<br />
== Starting CASA ==<br />
<br />
{{CaltechCASAStartup}}<br />
<br />
== Examining the MS ==<br />
<br />
We use {{listobs}} to summarize our MS:<br />
<source lang="python"><br />
# In CASA<br />
listobs('SN2010FZ_10s.ms')<br />
</source><br />
<br />
In the logger you should see:<br />
<br />
<pre><br />
##########################################<br />
##### Begin Task: listobs #####<br />
<br />
================================================================================<br />
MeasurementSet Name: SN2010FZ_10s.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. Alicia M. Soderberg Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 1570726 Total integration time = 3359 seconds<br />
Observed from 11-Jul-2010/21:30:44.0 to 11-Jul-2010/22:26:43.0 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) SpwIds ScanIntent<br />
11-Jul-2010/21:30:44.0 - 21:30:52.0 2 0 J0925+0019 404 6.43 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:31:02.0 - 21:32:22.0 3 0 J0925+0019 5062 9.68 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:32:32.0 - 21:33:52.0 4 0 J0925+0019 6277 9.91 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:34:02.0 - 21:34:52.0 5 0 J0925+0019 4148 9.96 [0, 1] CALIBRATE_PHASE#UNSPECIFIED<br />
21:35:02.0 - 21:35:51.5 6 0 J0925+0019 32640 9.44 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:36:01.0 - 21:38:20.5 7 0 J0925+0019 81600 9.93 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:38:44.0 - 21:39:51.0 9 1 SN2010FZ 43520 9.16 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:40:01.0 - 21:41:20.5 10 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:41:30.0 - 21:42:50.0 11 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:43:00.0 - 21:44:20.0 12 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:44:30.0 - 21:45:50.0 13 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:46:00.0 - 21:47:19.5 14 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:47:29.0 - 21:47:49.0 15 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:48:12.0 - 21:49:18.5 16 0 J0925+0019 43520 9 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
21:49:42.0 - 21:50:49.0 17 1 SN2010FZ 43520 9.17 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:50:59.0 - 21:52:19.0 18 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:52:29.0 - 21:53:48.5 19 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:53:58.0 - 21:55:18.0 20 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:55:28.0 - 21:56:48.0 21 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:56:58.0 - 21:58:18.0 22 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:58:28.0 - 21:58:47.5 23 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
21:59:10.5 - 22:00:17.0 24 0 J0925+0019 43520 8.99 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:00:39.5 - 22:01:47.0 25 1 SN2010FZ 43520 9.18 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:01:57.0 - 22:03:17.0 26 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:03:27.0 - 22:04:47.0 27 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:04:57.0 - 22:06:16.5 28 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:06:26.0 - 22:07:46.0 29 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:07:56.0 - 22:09:16.0 30 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:09:26.0 - 22:09:45.5 31 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:10:08.0 - 22:11:15.5 32 0 J0925+0019 43520 9.13 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:11:38.0 - 22:12:45.5 33 1 SN2010FZ 43520 9.19 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:12:55.0 - 22:14:15.0 34 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:14:25.0 - 22:15:45.0 35 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:15:55.0 - 22:17:15.0 36 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:17:25.0 - 22:18:44.5 37 1 SN2010FZ 48960 9.89 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:18:54.0 - 22:20:14.0 38 1 SN2010FZ 48960 10 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:20:24.0 - 22:20:43.5 39 1 SN2010FZ 16320 9.67 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]OBSERVE_TARGET#UNSPECIFIED<br />
22:21:06.0 - 22:22:13.5 40 0 J0925+0019 42690 9.15 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_PHASE#UNSPECIFIED<br />
22:25:13.0 - 22:25:13.0 42 2 3C286 1028 2.87 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
22:25:23.0 - 22:26:43.0 43 2 3C286 47757 9.6 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
(nVis = Total number of time/baseline visibilities per scan) <br />
Fields: 3<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 D J0925+0019 09:25:07.81503 +00.19.13.9334 J2000 0 303381 <br />
1 NONE SN2010FZ 09:42:04.77000 +00.19.51.0000 J2000 1 1218560<br />
2 K 3C286 13:31:08.28798 +30.30.32.9589 J2000 2 48785 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (18 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 64 TOPO 7686 2000 128000 RR RL LR LL <br />
1 64 TOPO 7836 2000 128000 RR RL LR LL <br />
2 64 TOPO 4488 2000 128000 RR RL LR LL <br />
3 64 TOPO 4616 2000 128000 RR RL LR LL <br />
4 64 TOPO 4744 2000 128000 RR RL LR LL <br />
5 64 TOPO 4872 2000 128000 RR RL LR LL <br />
6 64 TOPO 5000 2000 128000 RR RL LR LL <br />
7 64 TOPO 5128 2000 128000 RR RL LR LL <br />
8 64 TOPO 5256 2000 128000 RR RL LR LL <br />
9 64 TOPO 5384 2000 128000 RR RL LR LL <br />
10 64 TOPO 6488 2000 128000 RR RL LR LL <br />
11 64 TOPO 6616 2000 128000 RR RL LR LL <br />
12 64 TOPO 6744 2000 128000 RR RL LR LL <br />
13 64 TOPO 6872 2000 128000 RR RL LR LL <br />
14 64 TOPO 7000 2000 128000 RR RL LR LL <br />
15 64 TOPO 7128 2000 128000 RR RL LR LL <br />
16 64 TOPO 7256 2000 128000 RR RL LR LL <br />
17 64 TOPO 7384 2000 128000 RR RL LR LL <br />
Sources: 50<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J0925+0019 0 - - <br />
0 J0925+0019 1 - - <br />
0 J0925+0019 2 - - <br />
0 J0925+0019 3 - - <br />
0 J0925+0019 4 - - <br />
0 J0925+0019 5 - - <br />
0 J0925+0019 6 - - <br />
0 J0925+0019 7 - - <br />
0 J0925+0019 8 - - <br />
0 J0925+0019 9 - - <br />
0 J0925+0019 10 - - <br />
0 J0925+0019 11 - - <br />
0 J0925+0019 12 - - <br />
0 J0925+0019 13 - - <br />
0 J0925+0019 14 - - <br />
0 J0925+0019 15 - - <br />
0 J0925+0019 16 - - <br />
0 J0925+0019 17 - - <br />
1 SN2010FZ 2 - - <br />
1 SN2010FZ 3 - - <br />
1 SN2010FZ 4 - - <br />
1 SN2010FZ 5 - - <br />
1 SN2010FZ 6 - - <br />
1 SN2010FZ 7 - - <br />
1 SN2010FZ 8 - - <br />
1 SN2010FZ 9 - - <br />
1 SN2010FZ 10 - - <br />
1 SN2010FZ 11 - - <br />
1 SN2010FZ 12 - - <br />
1 SN2010FZ 13 - - <br />
1 SN2010FZ 14 - - <br />
1 SN2010FZ 15 - - <br />
1 SN2010FZ 16 - - <br />
1 SN2010FZ 17 - - <br />
2 3C286 2 - - <br />
2 3C286 3 - - <br />
2 3C286 4 - - <br />
2 3C286 5 - - <br />
2 3C286 6 - - <br />
2 3C286 7 - - <br />
2 3C286 8 - - <br />
2 3C286 9 - - <br />
2 3C286 10 - - <br />
2 3C286 11 - - <br />
2 3C286 12 - - <br />
2 3C286 13 - - <br />
2 3C286 14 - - <br />
2 3C286 15 - - <br />
2 3C286 16 - - <br />
2 3C286 17 - - <br />
Antennas: 27:<br />
ID Name Station Diam. Long. Lat. <br />
0 ea01 W09 25.0 m -107.37.25.2 +33.53.51.0 <br />
1 ea02 E02 25.0 m -107.37.04.4 +33.54.01.1 <br />
2 ea03 E09 25.0 m -107.36.45.1 +33.53.53.6 <br />
3 ea04 W01 25.0 m -107.37.05.9 +33.54.00.5 <br />
4 ea05 W08 25.0 m -107.37.21.6 +33.53.53.0 <br />
5 ea06 N06 25.0 m -107.37.06.9 +33.54.10.3 <br />
6 ea08 N01 25.0 m -107.37.06.0 +33.54.01.8 <br />
7 ea09 E06 25.0 m -107.36.55.6 +33.53.57.7 <br />
8 ea10 N03 25.0 m -107.37.06.3 +33.54.04.8 <br />
9 ea11 E04 25.0 m -107.37.00.8 +33.53.59.7 <br />
10 ea12 E08 25.0 m -107.36.48.9 +33.53.55.1 <br />
11 ea13 N07 25.0 m -107.37.07.2 +33.54.12.9 <br />
12 ea14 E05 25.0 m -107.36.58.4 +33.53.58.8 <br />
13 ea15 W06 25.0 m -107.37.15.6 +33.53.56.4 <br />
14 ea16 W02 25.0 m -107.37.07.5 +33.54.00.9 <br />
15 ea17 W07 25.0 m -107.37.18.4 +33.53.54.8 <br />
16 ea18 N09 25.0 m -107.37.07.8 +33.54.19.0 <br />
17 ea19 W04 25.0 m -107.37.10.8 +33.53.59.1 <br />
18 ea20 N05 25.0 m -107.37.06.7 +33.54.08.0 <br />
19 ea21 E01 25.0 m -107.37.05.7 +33.53.59.2 <br />
20 ea22 N04 25.0 m -107.37.06.5 +33.54.06.1 <br />
21 ea23 E07 25.0 m -107.36.52.4 +33.53.56.5 <br />
22 ea24 W05 25.0 m -107.37.13.0 +33.53.57.8 <br />
23 ea25 N02 25.0 m -107.37.06.2 +33.54.03.5 <br />
24 ea26 W03 25.0 m -107.37.08.9 +33.54.00.1 <br />
25 ea27 E03 25.0 m -107.37.02.8 +33.54.00.5 <br />
26 ea28 N08 25.0 m -107.37.07.5 +33.54.15.8 <br />
<br />
##### End Task: listobs #####<br />
##########################################<br />
</pre><br />
<br />
This task displays a lot of information about the MS. We can see that the observation was performed with the EVLA, for a total integration of 3359 seconds (1 hour). The number of data records (1570726) is equal to the number of baselines (N_antenna * [N_antenna - 1] / 2) X the number of integrations (observing time / time-average binning) X the number of spectral windows. For this observation, this is roughly 351 baselines (27X26/2) X 360 integrations (3600s total/10s avg) X 16 spectral windows = 2021760. Note that this is high by ~30%; this is because the archive already flagged bad data, and there are some scans which only have two (rather than 16) spectral windows present. Extra exercise: examine the MS using {{browsetable}} to see what a data record looks like (equivalent to a row, as displayed by this task).<br />
<br />
The most useful parts of the {{listobs}} output are the scan, field, and spectral window listings. <br />
<br />
From the spectral window information, we can see that there were a total of 18 (0 through 17) spectral windows in this dataset. The first two of these (0 and 1) were only used to help set up the correlator. <br />
<br />
Looking at the scan listing, we can see that the first four scans which are present used only these spectral windows. These are referred to as "dummy scans". We will not be using these, since they often contain bad data. <br />
<br />
The C-band data of interest is contained in scans 6-44 and spectral windows 2 to 17. Careful examination shows that scan 8 is missing but from the time ranges that the data has been merged into scan 7. This sort of correlator back-end data-capture issue was occasionally seen during 2010. Hopefully, it will not affect our data, but we should keep an eye out for problems with scan 7. <br />
<br />
The field listing shows three sources: <br />
<br />
* J0925+0019 (also referred to by its field ID, 0), which will serve as a calibrator for the visibility phases, <br />
* SN2010FZ (1), our science target field, and <br />
* 3C286 (2), which will serve as a calibrator for the visibility amplitudes, i.e., it is assumed to have a precisely known flux density; as well as the spectral bandpass.<br />
<br />
== Flagging the MS ==<br />
<br />
The online flags, which are a record of known bad data produced by the EVLA online system, have already been applied by the archive as it generated the MS. However, it's good to have a sense of what was deleted in this process. A record of the flags is also stored in a separate table in the MS, called <tt>FLAG_CMD</tt>. (In fact, the information for this table is actually a subdirectory within the MS; you can see this by listing the contents of <tt>SN2010FZ_10s.ms</tt>.)<br />
<br />
[[Image:PlotSN2010FZ_flagcmd_3.4.png|200px|thumb|right|online flags plotted from flagcmd]]<br />
You can examine the commands stored in the <tt>FLAG_CMD</tt> table using {{flagcmd}}.<br />
<source lang="python"><br />
# In CASA<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='table',action='list')<br />
</source><br />
These will go to the logger or terminal (they appear to go to the terminal now in 4.2).<br />
<br />
You can also plot the commands stored in the <tt>FLAG_CMD</tt> table:<br />
<source lang="python"><br />
# In CASA<br />
myrows = range(285)<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='table',action='plot',tablerows=myrows)<br />
</source><br />
<br />
Note that we are only plotting the first 285 rows -- this is because the last few are from flagging zeros in the data (caused by correlator errors) and data which have been flagged due to [http://evlaguides.nrao.edu/index.php?title=Observational_Status_Summary#Shadowing_and_Cross-Talk antenna shadowing]. Note that you can not do the <tt>tablerows</tt> selection and plot those too, you will just get lines at the bottom marked as "All" antennas for these flags.<br />
<br />
This will bring up a <tt>matplotlib</tt> plotter. You can have it plot to a PNG file instead:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagcmd(vis='SN2010FZ_10s.ms', inpmode='table', action='plot', tablerows=myrows, <br />
plotfile='PlotSN2010FZ_flagcmd_4.2.png')<br />
</source><br />
<br />
The flags as plotted in the figure to the above right look normal. <br />
They are color-coded by REASON, and you see ANTENNA_NOT_ON_SOURCE flags between scans, and the occasional SUBREFLECTOR_ERROR flag also between scans (most likely after band changes when the subreflector rotates to <br />
pick up the new feed on the ring, some are slower than others). What you watch for here are long blocks of unexpected flags, which might be false alarms and cause you to flag too much data. In that case, look at the data itself in {{plotms}} (see below for examples) to decide whether or not to apply all flags.<br />
<br />
[[Image:plotSN2010FZ_plotants.png|200px|thumb|right|plotants plotter]]<br />
To plot up the antenna positions in the array:<br />
<source lang="python"><br />
# In CASA<br />
plotants('SN2010FZ_10s.ms')<br />
</source><br />
<br />
NOTE: if after this point (or any other) you get "table locks", which may occur erroneously and are sometimes triggered by plotting tasks, use {{clearstat}} to clear them:<br />
<br />
<source lang="python"><br />
# In CASA<br />
clearstat<br />
</source><br />
<br />
Now we examine the MS looking for bad data to flag. We will use {{plotms}} to bring up an interactive GUI that will display 2-D Y vs.X style line plots. <b>NOTE: We do not recommend using the editing/flagging features of plotms.</b> It is very easy to mess up your data this way. Also, to improve speed we will be restricting the scope of plotting so most box/flag operations would not get rid of all the bad data. <br />
<br />
We will instead use plotms to identify bad data and then use flagcmd to flag it. This will also allow full scripting of the flagging, which is ultimately the best way to keep track of what's been deleted. Given the large dataset sizes now being generated, reproducibility is extremely important. Imaging spending a day flagging your data, then a disk error corrupts the MS. It's imperative that you have an automated way to regenerate your work. This is also why we encourage you to keep a running file with all the commands you use on a dataset.<br />
<br />
NOTE: If you need an introduction to {{plotms}}, see:<br />
* [[Data flagging with plotms]]<br />
* [[Averaging data in plotms]]<br />
* [[What's the difference between Antenna1 and Antenna2? Axis definitions in plotms]]<br />
<br />
WARNING: The '''Flag''' [[Image:FlagThoseData.png]] button on the plotms GUI is close to other buttons you will be using, in particular the one that gets rid of boxes you have drawn. Be careful and don't hit the '''Flag''' button by mistake!<br />
<br />
As we found above, the useful spectral windows are 2-17. To get an idea of the data layout, plot a single baseline (ea01&ea02) and channel (31, for all spectral windows) versus time:<br />
<br />
[[Image:screenshotPlotSN2010FZ_plotms_ants1_4.0.png|200px|thumb|right|plotms ea01&ea02 amp vs time]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='',spw='2~17:31~31', \<br />
antenna='ea01&ea02',correlation='RR,LL',xaxis='time',yaxis='amp')<br />
</source><br />
<br />
Here, we can see the alternating phase calibration and science target scans, as well as the (brighter) flux calibrator at the end of the observation. Feel free to play with ways to view, or color the data: for example, go to the "Display" left-hand tab, and choose "Colorize by: Field". You can also change the size of the plotted points, if they are too small to see easily, by setting "Unflagged Points Symbol" to "Custom" and increasing the number of pixels under "Style".<br />
<br />
[[Image:screenshotPlotSN2010FZ_plotms_ants2_4.0.png|200px|thumb|right|plotms ea01 for field 2 showing amp versus ANTENNA2]]<br />
Look for bad antennas by picking the last field and plotting baselines versus antenna <tt>ea01</tt>:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17:31~31', \<br />
antenna='ea01',correlation='RR,LL',xaxis='antenna2',yaxis='amp')<br />
</source><br />
<br />
You should be able to see that antenna 11 (= ea13) is bad (very low amplitude, it has no C-band receiver!) and that some of the spectral windows on 15 and 23 (ea17, ea25) are also on the low side. Boxing with the '''Mark Regions''' [[Image:MarkRegionsButton.png]] tool and using the '''Locate''' [[File:casaplotms-locate-tool.png]] tool will show in the logger that spw 10-17 are suspect for these antennas. (Note: you may also leave these in for now if you like; if this were truly a first pass through the data it is unlikely that they would be caught. Since this is a tutorial, and there is limited time for a second pass through the data, it's probably best to trust us and delete them now.)<br />
<br />
[[Image:plotSN2010FZ_plotms_ea02.png|200px|thumb|right|plotms field 2 ea02 amp vs frequency]]<br />
Now look at the bandpass for ea02 - it is in the inner core and a prospective reference antenna. Exclude ea13 using negation (represented by "!") in the selection:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17', \<br />
antenna='ea02;!ea13',correlation='RR,LL',xaxis='frequency',yaxis='amp')<br />
</source><br />
There is clearly less data for spw 11, and use of Locate shows spw 11 data only for ea02,ea03,04,08,09,11,12. We will later delete this incomplete spw. Note also the very strong RFI spike at 6614 MHz (spw 10 ch 63) with clear ringing contaminating both spw 10 and 11. There is also a tremendous roll-off in spw 10. We will drop these spectral window when we process the data.<br />
<br />
[[Image:plotSN2010FZ_plotms_ea02ea20.png|200px|thumb|right|plotms ea02 iteration with baseline stopped at ea02&ea20 showing phase vs frequency]]<br />
We can also step through the baselines to our antenna using iteraxis:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02;!ea13', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',iteraxis='baseline')<br />
</source><br />
and use the '''Next Iteration''' [[Image:NextIterationButton.png]] button to step through the baselines.<br />
This will make it easier to isolate the bad antennas. Now plot the phases, iterating through baselines to ea02:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02;!ea13', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',iteraxis='baseline')<br />
</source><br />
You see the slopes due to residual delays. Mostly a turn or less over a 128MHz subband, but there are some outliers.<br />
Step through to ea20. You see that there is a very large delay in RR (via locate) for<br />
the first baseband (spw 0~7). We will delete this (will also delete LL so there are no orphan polarization products, which would be ignored by {{clean}} in the imaging stage).<br />
Note ea17 and ea25 baselines drop close to zero in the middle of upper baseband (e.g. plot 'ea17&ea25') so we will delete these.<br />
<br />
To carry out flagging, we again use {{flagcmd}} in the mode where it takes a list of command strings:<br />
<source lang="python"><br />
# In CASA<br />
flaglist = ['antenna="ea13"',<br />
'antenna="ea17" spw="10~17"',<br />
'antenna="ea25" spw="10~17"',<br />
'antenna="ea20" spw="2~9"']<br />
flagcmd(vis='SN2010FZ_10s.ms',inpmode='list',inpfile=flaglist,action='apply',flagbackup=True)<br />
</source><br />
These commands will be carried out as well as being added to the FLAG_CMD table (marked as applied).<br />
<br />
Plot the data again, now that is has been flagged:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='',spw='5:30~33',avgchannel='64', \<br />
antenna='ea01&ea02',correlation='RR,LL',xaxis='time',yaxis='amp')<br />
plotms(vis='SN2010FZ_10s.ms',field='2',spw='2~17',antenna='ea02', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
<br />
[[Image:plotSN2010FZ_plotms_ea02fld0.png|200px|thumb|right|plotms field 0 ea02 amp vs frequency]]<br />
Now our phase calibrator - it is weaker, and we now start to really see the RFI:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='0',spw='2~17',antenna='ea02', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
Use the Zoom feature, Mark rectangles and use Locate to identify the frequency/channel of RFI. In particular, we note in our analysis:<br />
* 6614MHz (spw 10 ch 63) super strong<br />
* 6772-6778MHz (spw 12 ch 14-17)<br />
* 7260-7264MHz (spw 16 ch 2-4)<br />
* 7314-7340MHz (spw 16 ch 29-42)<br />
* 7402-7418MHz (spw 17 ch 9-17)<br />
* 7458-7466MHz (spw 17 ch 37-41)<br />
* 7488MHz (spw 17 ch 52)<br />
<br />
If you plot all antennas and avoid the band edges you see spw 16 and 17 are pretty wiped out:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_10s.ms',field='0',spw='2~17:4~59',antenna='', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',scan='7~43')<br />
</source><br />
<br />
For now we will not flag these spectral windows, but note the bad channels, which we will mask out when creating continuum calibration tables and images.<br />
<br />
Finally, split off the good scans and spw, this will allow us to work on the data without having to start completely over (if we mess something up badly) as well as letting us do simpler data selections. Note that we do not include spw 10, because of the bad RFI, or spw 11, because of the many missing antennas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_flagged10s.ms')<br />
split(vis='SN2010FZ_10s.ms',outputvis='SN2010FZ_flagged10s.ms',datacolumn='data',spw='2~9,12~17',scan='7~43')<br />
</source><br />
<br />
You now have a MS called <tt>SN2010FZ_flagged10s.ms</tt> in your working area. This should be 2.8GB in size, which you can see while still at the CASA command prompt by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('du -sh SN2010FZ_flagged10s.ms')<br />
</source><br />
<br />
Note that the built-in <tt>system</tt> function allows one to execute UNIX shell commands within a CASA session. (Some, like <tt>ls</tt>, don't need this extra wrapper, but most are not automatically understood.)<br />
<br />
[[Image:PlotSN2010FZ_plotms_datastream_zoomed.png|200px|thumb|right|plotms antenna2 vs. time "datastream" plot, zoomed in on last scan]]<br />
At this point it is useful to plot a "datastream" view of the dataset to show what antennas are present at what time. You can do this using<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='',correlation='RR,LL',<br />
timerange='',antenna='',spw='0:31',<br />
xaxis='time',yaxis='antenna2',<br />
plotrange=[-1,-1,0,26],coloraxis='field')<br />
</source><br />
This shows the times where data is present on baselines TO a given Antenna2 (which means there is no line for ea01 which is antenna 0). You can pick up ea01 (and drop ea28) by setting <tt>yaxis='antenna1'</tt>. To the right we show this plot, having zoomed in on the last scan on 3C286. You see here that some antennas are present in this scan earlier than others (e.g. ea02 comes in one 10s integration later than ea04).<br />
<br />
== Calibration ==<br />
<br />
Summarize the split flagged MS:<br />
<source lang="python"><br />
# In CASA<br />
listobs('SN2010FZ_flagged10s.ms')<br />
</source><br />
In the logger we see:<br />
<pre><br />
##########################################<br />
##### Begin Task: listobs #####<br />
<br />
================================================================================<br />
MeasurementSet Name: SN2010FZ_flagged10s.ms MS Version 2<br />
================================================================================<br />
Observer: Dr. Alicia M. Soderberg Project: T.B.D. <br />
Observation: EVLA<br />
Data records: 1375038 Total integration time = 3042 seconds<br />
Observed from 11-Jul-2010/21:36:01.0 to 11-Jul-2010/22:26:43.0 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) SpwIds ScanIntent<br />
11-Jul-2010/21:36:01.0 - 21:38:20.5 7 0 J0925+0019 73710 9.93 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
21:38:44.0 - 21:39:51.0 9 1 SN2010FZ 39312 9.16 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:40:01.0 - 21:41:20.5 10 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:41:30.0 - 21:42:50.0 11 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:43:00.0 - 21:44:20.0 12 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:44:30.0 - 21:45:50.0 13 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:46:00.0 - 21:47:19.5 14 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:47:29.0 - 21:47:49.0 15 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:48:12.0 - 21:49:18.5 16 0 J0925+0019 39312 9 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
21:49:42.0 - 21:50:49.0 17 1 SN2010FZ 39312 9.17 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:50:59.0 - 21:52:19.0 18 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:52:29.0 - 21:53:48.5 19 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:53:58.0 - 21:55:18.0 20 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:55:28.0 - 21:56:48.0 21 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:56:58.0 - 21:58:18.0 22 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:58:28.0 - 21:58:47.5 23 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
21:59:10.5 - 22:00:17.0 24 0 J0925+0019 39312 8.99 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:00:39.5 - 22:01:47.0 25 1 SN2010FZ 39312 9.18 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:01:57.0 - 22:03:17.0 26 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:03:27.0 - 22:04:47.0 27 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:04:57.0 - 22:06:16.5 28 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:06:26.0 - 22:07:46.0 29 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:07:56.0 - 22:09:16.0 30 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:09:26.0 - 22:09:45.5 31 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:10:08.0 - 22:11:15.5 32 0 J0925+0019 39312 9.13 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:11:38.0 - 22:12:45.5 33 1 SN2010FZ 39312 9.19 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:12:55.0 - 22:14:15.0 34 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:14:25.0 - 22:15:45.0 35 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:15:55.0 - 22:17:15.0 36 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:17:25.0 - 22:18:44.5 37 1 SN2010FZ 44226 9.89 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:18:54.0 - 22:20:14.0 38 1 SN2010FZ 44226 10 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:20:24.0 - 22:20:43.5 39 1 SN2010FZ 14742 9.67 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]OBSERVE_TARGET#UNSPECIFIED<br />
22:21:06.0 - 22:22:13.5 40 0 J0925+0019 38584 9.15 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_PHASE#UNSPECIFIED<br />
22:25:13.0 - 22:25:13.0 42 2 3C286 924 2.88 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
22:25:23.0 - 22:26:43.0 43 2 3C286 43148 9.6 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]CALIBRATE_BANDPASS#UNSPECIFIED,CALIBRATE_AMPLI#UNSPECIFIED<br />
(nVis = Total number of time/baseline visibilities per scan) <br />
Fields: 3<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 D J0925+0019 09:25:07.81503 +00.19.13.9334 J2000 0 230230 <br />
1 NONE SN2010FZ 09:42:04.77000 +00.19.51.0000 J2000 1 1100736<br />
2 K 3C286 13:31:08.28798 +30.30.32.9589 J2000 2 44072 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (14 unique spectral windows and 1 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 64 TOPO 4488 2000 128000 RR RL LR LL <br />
1 64 TOPO 4616 2000 128000 RR RL LR LL <br />
2 64 TOPO 4744 2000 128000 RR RL LR LL <br />
3 64 TOPO 4872 2000 128000 RR RL LR LL <br />
4 64 TOPO 5000 2000 128000 RR RL LR LL <br />
5 64 TOPO 5128 2000 128000 RR RL LR LL <br />
6 64 TOPO 5256 2000 128000 RR RL LR LL <br />
7 64 TOPO 5384 2000 128000 RR RL LR LL <br />
8 64 TOPO 6744 2000 128000 RR RL LR LL <br />
9 64 TOPO 6872 2000 128000 RR RL LR LL <br />
10 64 TOPO 7000 2000 128000 RR RL LR LL <br />
11 64 TOPO 7128 2000 128000 RR RL LR LL <br />
12 64 TOPO 7256 2000 128000 RR RL LR LL <br />
13 64 TOPO 7384 2000 128000 RR RL LR LL <br />
<snip><br />
</pre><br />
Note that the spectral windows are re-numbered to 0 through 13.<br />
<br />
=== Setting the flux density scale ===<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#x195-1920004 Synthesis Calibration] in the CASA Cookbook and User Reference Manual .<br />
<br />
Before calibrating, we insert a model for flux calibration source 3C286 into the MS. In order to do this, we first have to locate the model image on our system with {{setjy}}, which we will also use to set the flux density scale. The {{setjy}} task (in release 3.3.0 and later) has an option to list possible model images it knows about:<br />
<br />
<source lang="python"><br />
# In CASA<br />
setjy(vis='SN2010FZ_flagged10s.ms', listmodels=True)<br />
</source><br />
which sends output to your terminal (but not the logger). For example, on an NRAO workstation:<br />
<pre><br />
<br />
No candidate modimages matching '*.im* *.mod*' found in .<br />
<br />
Candidate modimages (*) in /usr/lib64/casapy/release/4.2.0/data/nrao/VLA/CalModels:<br />
3C138_A.im 3C138_S.im 3C147_K.im 3C147_X.im 3C286_Q.im 3C48_C.im 3C48_U.im<br />
3C138_C.im 3C138_U.im 3C147_L.im 3C286_A.im 3C286_S.im 3C48_K.im 3C48_X.im<br />
3C138_K.im 3C138_X.im 3C147_Q.im 3C286_C.im 3C286_U.im 3C48_L.im README<br />
3C138_L.im 3C147_A.im 3C147_S.im 3C286_K.im 3C286_X.im 3C48_Q.im<br />
3C138_Q.im 3C147_C.im 3C147_U.im 3C286_L.im 3C48_A.im 3C48_S.im<br />
</pre><br />
The relevant image for our purposes is <tt>3C286_C.im</tt>, in the directory <tt>/usr/lib64/casapy/release/data/nrao/VLA/CalModels</tt>. Your system may show a different location (for example <tt>/home/casa/data/nrao/VLA/CalModels/</tt>, or <tt>/Applications/CASA.app/Contents/data/nrao/VLA/CalModels</tt> on a Mac). Since it knows about this image, we only have to give the image name and not the entire path. Otherwise, you will need to give it the entire path. We now run the task using this model:<br />
<br />
<source lang="python"><br />
# In CASA<br />
mysetjy = setjy(vis='SN2010FZ_flagged10s.ms', field='2', scalebychan=True, model='3C286_C.im', usescratch=False)<br />
</source><br />
<br />
* <tt>scalebychan=True</tt>: will fill the model with per-channel values; otherwise, {{setjy}} would use a single value per spectral window.<br />
* <tt>usescratch=False</tt>: put the model in the header instead of creating scratch columns in the MS. This will take up considerably less disk space.<br />
<br />
We have not specified a Flux Density Scale Standard and are thus using the default (<tt>standard='Perley-Butler 2010'</tt>) as that was current when these observations were taken. In particular, there is a more recent "Perley-Butler 2013" scale that most users will want to use! See <tt>help setjy</tt> for more details.<br />
<br />
Inspecting the logger report shows that 3C286 is about 7.7 Jy at lower end of the band to 5.7 Jy at the upper end.<br />
<br />
Note: With release 4.2 {{setjy}} now returns a dictionary to Python, which we have captured in a variable. This can be used in scripts.<br />
<br />
=== Deriving pre-determined calibrations: antenna position corrections, gain-elevation curves, and requantizer gains ===<br />
<br />
Some calibration products are carried along throughout the calibration process and used as priors for subsequent calibration steps. These include the antenna position corrections, gain-elevation curves, and requantizer gains.<br />
<br />
We use {{gencal}} to determine any antenna-position corrections that need to be applied to the data. This is based on a database of corrections with the time they were determined and when they were applied by the observing system, compared to the times in your observations.<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.antpos',caltype='antpos',antenna='')<br />
</source><br />
You should see in the logger:<br />
<pre style="background-color: #fffacd;"><br />
Determine antenna position offests from the baseline correction database<br />
offsets for antenna ea01 : 0.00000 0.00300 0.00000<br />
offsets for antenna ea02 : -0.00080 0.00000 0.00000<br />
offsets for antenna ea03 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea05 : 0.00000 0.00280 0.00000<br />
offsets for antenna ea06 : 0.00220 0.00100 0.00590<br />
offsets for antenna ea10 : 0.00080 0.00300 -0.00140<br />
offsets for antenna ea11 : 0.00090 0.00000 0.00000<br />
offsets for antenna ea12 : -0.00280 0.00000 0.00000<br />
offsets for antenna ea13 : 0.00000 -0.00080 0.00000<br />
offsets for antenna ea17 : -0.00120 0.00000 0.00000<br />
offsets for antenna ea18 : 0.00040 -0.00080 0.00040<br />
offsets for antenna ea22 : -0.00370 -0.00130 0.00000<br />
offsets for antenna ea23 : -0.00140 0.00000 0.00000<br />
offsets for antenna ea24 : -0.00150 0.00000 0.00000<br />
offsets for antenna ea26 : -0.00190 0.00000 0.00210<br />
offsets for antenna ea27 : 0.00000 0.00190 -0.00160<br />
</pre><br />
Note that there are significant position corrections for a number of the antennas. <br />
<br />
In CASA 4.1, we now have the option to use {{gencal}} to create a calibration table containing the gain curves for the antennas. Although you can still use the <tt>gaincurve=True</tt> option in each task, we will make use of this new feature (note that the <tt>gaincurve=True</tt> will be phased out in future CASA releases):<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.gaincurve',caltype='gc')<br />
</source><br />
<br />
Finally, we will use {{gencal}} to create a calibration table containing corrections for the requantizer gains. Although this is only necessary for 3-bit data (and our SN2010FZ is 8-bit), we include it here for completeness. It will not affect the calibration for our 8-bit data, but if one is following this CASA Guide as a template for 3-bit data, this step is needed to account for the small gain changes (~5-10%) that result from resetting the quantizer gains as the correlator changes to a new 3-bit configuration.<br />
<source lang="python"><br />
# In CASA<br />
gencal('SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.requantizer',caltype='rq')<br />
</source><br />
<br />
Since we're running {{gencal}} on 3-bit data, it logs that it found "0 TIME/SPW switched power samples."<br />
<br />
The caltables we have generated -- <tt>calSN2010FZ.antpos</tt>, <tt>calSN2010FZ.gaincurve</tt>, and <tt>calSN2010FZ.requantizer</tt> -- will need to be pre-applied in subsequent calibration steps.<br />
<br />
=== Calibrating delays and bandpass ===<br />
<br />
[[Image:plotSN2010FZ_plotcal_G0p1_4.0.png|200px|thumb|right|plotcal G0 phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G0p2_4.0.png|200px|thumb|right|plotcal G0 phase ant 16~26]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_delays_4.2.png|200px|thumb|right|plotcal K0 delay vs. antenna]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_B0a1_4.0.png|200px|thumb|right|plotcal B0 bandpass amp ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_B0a2_4.0.png|200px|thumb|right|plotcal B0 bandpass amp ant 16~26]]<br />
[[Image:plotSN2010FZ_plotcal_B0p1_4.0.png|200px|thumb|right|plotcal B0 bandpass phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_B0p2_4.0.png|200px|thumb|right|plotcal B0 bandpass phase ant 16~26]]<br />
[[Image:plotSN2010FZ_plotcal_B0ea14_4.0.png|200px|thumb|right|plotcal B0 amp and phase vs. freq for ea14]]<br />
<br />
First, we do a phase-only calibration solution on a narrow range of channels in each spw on the bandpass/flux calibrator 3c286 to flatten them before solving for the bandpass. Note where we saw RFI in the higher spw and avoid those channels. The range 23~28 should work. Pick a refant near center - ea04 is a reasonable bet (see above):<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G0',field='2',spw='0~13:23~28', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve'],\<br />
gaintype='G',refant='ea04',calmode='p',solint='int',minsnr=3) <br />
</source><br />
<br />
* <tt>refant='ea04'</tt> : try to use ea04 as the reference antenna<br />
* <tt>solint='int'</tt> : do a per-integration solve (every 10 seconds, since we've time-averaged the data)<br />
* <tt>minsnr=3</tt> : apply a minimum signal-to-noise cutoff. Solutions with less than this value will be flagged<br />
* <tt>gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve']</tt> : pre-apply the antpos and gaincurve caltables<br />
<br />
Plot the phase solutions (using full phase range, -180 to 180, instead of autorange):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Step through the antenna-based solutions. They look good (and fairly flat over the scans).<br />
<br />
NOTE: When you are done plotting and want to use the caltable in another task, use the Quit button on the GUI to dismiss the plotter and free up the lock on the caltable. You should see a message in your terminal window saying "Resetting plotcal" which means you are good to go!<br />
<br />
If you want to make single-page multipanel plots (like those shown to the right), particularly for a<br />
hardcopy (where it only shows the first page), you can do:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase', \<br />
antenna='0~10,12~15',subplot=531,iteration='antenna', \<br />
plotrange=[-1,-1,-180,180],showgui=False,fontsize=6.0, \<br />
figfile='plotSN2010FZ_plotcal_G0p1.png')<br />
plotcal(caltable='calSN2010FZ.G0',xaxis='time',yaxis='phase', \<br />
antenna='16~26',subplot=531,iteration='antenna', \<br />
plotrange=[-1,-1,-180,180],showgui=False,fontsize=6.0, \<br />
figfile='plotSN2010FZ_plotcal_G0p2.png')<br />
</source><br />
<br />
We can now solve for the residual antenna-based delays that we saw in phase vs. frequency.<br />
This uses the new gaintype='K' option in gaincal. Note that this currently does not do a "global fringe-fitting" solution for delays,<br />
but instead does a baseline-based delay solution to all baselines to the refant, treating these<br />
as antenna-based delays. In most cases with high-enough S/N to get baseline-based delay solutions<br />
this will suffice. We avoid the beginning of spw 0 due to the extreme roll-off (with loss of S/N) at the<br />
starting edge.<br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.K0',\<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.G0'],\<br />
field='2',spw='0:8~59,1~13:4~59',gaintype='K', \<br />
refant='ea04',combine='scan',solint='inf',minsnr=3)<br />
</source><br />
We pre-apply our initial phase table, and produce a new K-type caltable for input to bandpass calibration.<br />
We can plot the delays, in nanoseconds, as a function of antenna index (you will get one for each subband and polarization):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.K0', xaxis='antenna', yaxis='delay')<br />
</source><br />
<br />
The delays range from around -6 to 6 nanoseconds.<br />
<br />
Now solve for the bandpass using the previous tables:<br />
<source lang="python"><br />
# In CASA<br />
bandpass(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.B0', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve', \<br />
'calSN2010FZ.G0','calSN2010FZ.K0'], \<br />
field='2',refant='ea04',solnorm=False, \<br />
bandtype='B', combine='scan', solint='inf')<br />
</source><br />
'''WARNING''': You must set <tt>solnorm=False</tt> here or later on you will find some offsets<br />
between spw due to how amplitude scaling adjusts weights internally during solving.<br />
<br />
You will see in the terminal some reports of solutions failing below our default S/N>3 cutoff:<br />
<pre><br />
32 of 50 solutions flagged due to SNR < 3 in spw=0 (chan=1) at 2010/07/11/22:26:05.4<br />
44 of 50 solutions flagged due to SNR < 3 in spw=0 (chan=0) at 2010/07/11/22:26:05.4<br />
</pre><br />
<br />
These are in the first two edge channels of the first spw where the response is low, and not unexpected. <br />
In the logger you will also see reports of reference antennas jumping in those channels, which can be <br />
be safely ignored (we will drop those channels later anyway).<br />
<br />
This is the first amplitude-scaling calibration that we do, so it is important to have used the <tt>calSN2010FZ.gaincurve</tt> caltable (or set <tt>gaincurve=True</tt>). If we were at higher frequency we would also have made an opacity caltable (or set <tt>opacity</tt>).<br />
<br />
Now plot this, in amplitude then phase:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',iteration='antenna')<br />
#<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
or to plot them all together<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',<br />
antenna='0~10,12~15',subplot=531,iteration='antenna',<br />
fontsize=6.0, figfile='plotSN2010FZ_plotcal_B0a1_4.2.png')<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp',<br />
antenna='16~26',subplot=531,iteration='antenna',<br />
fontsize=6.0, figfile='plotSN2010FZ_plotcal_B0a2_4.2.png')<br />
#<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',<br />
antenna='0~10,12~15',subplot=531,iteration='antenna',<br />
plotrange=[-1,-1,-180,180],fontsize=6.0, <br />
figfile='plotSN2010FZ_plotcal_B0p1_4.2.png')<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase',<br />
antenna='16~26',subplot=531,iteration='antenna',<br />
plotrange=[-1,-1,-180,180],fontsize=6.0, <br />
figfile='plotSN2010FZ_plotcal_B0p2_4.2.png')<br />
</source><br />
(this can take a long time to plot).<br />
<br />
In the bandpass phase you no longer see the residual antenna delays (just residual spw phase offsets from <br />
the delay solution registration) but there are some band edge effects.<br />
Note that some antennas have a little strange bandpasses at upper end of lower baseband in spw 5,6,7<br />
(e.g. ea14,ea16,ea17,ea25).<br />
To plot amp and phase for a single antenna versus frequency (see plots at right):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='amp', \<br />
antenna='ea14',subplot=211)<br />
plotcal(caltable='calSN2010FZ.B0',xaxis='freq',yaxis='phase', \<br />
antenna='ea14',subplot=212,plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Because our flux density calibrator 3C286 is bright enough, we were able to use this as the bandpass calibrator.<br />
Since {{setjy}} put the correct spectrum for 3C286 into the MODEL_DATA column, our bandpass will reflect the<br />
true bandpass of the instrument. However, if for your observation you were unable to use a source of known spectrum <br />
as the bandpass calibrator, then you would need to use the output of {{fluxscale}} later on to bootstrap a {{setjy}} <br />
on your bandpass source using the derived spectral index information.<br />
<br />
=== Final phase and amplitude calibration ===<br />
<br />
[[Image:plotSN2010FZ_plotcal_G1intp1_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G1intp2_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 16~26]]<br />
<br />
[[Image:plotSN2010FZ_plotcal_G1intp_ea01_4.0.png|200px|thumb|right|plotcal G1int per-int phase ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G1infp_ea01_4.0.png|200px|thumb|right|plotcal G1inf per-scan phase ant 0~15]]<br />
<br />
Now calibrate phases using the full bandwidth. <br />
First both our calibrators, one at a time - we could do them together, but in general you might need<br />
to do different solution intervals for each, so we keep the runs separate to illustrate how to <br />
do separate solutions and append them.<br />
We exclude RFI channels here, and obtain one solution per integration (these are bright enough):<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1int', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='2',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='int',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1int', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='int',gaintype='G',calmode='p',append=True)<br />
</source><br />
These will get applied when solving for amplitudes, and when calibrating the calibrators themselves.<br />
<br />
The phases look reasonably connected:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G1int',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
To apply phase calibration to the target, we make a second table with one solution on our gain calibrator per scan:<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1inf',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',gaintype='G',calmode='p')<br />
</source><br />
These scan phases will get interpolated by {{applycal}} onto our target. These look good also:<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G1inf',xaxis='time',yaxis='phase',iteration='antenna', \<br />
plotrange=[-1,-1,-180,180])<br />
</source><br />
<br />
Now solve for amplitudes on a per scan interval, after applying the per-integration phases. <br />
Do these separately using <tt>gainfield</tt> so phases don't get<br />
transferred across fields. For field 2 (3C286) we use <tt>combine='scan'</tt> as there are two scans <br />
on this source, with the first one having much less data (and will thus give a noisy solution on its own).<br />
Note that {{gaincal}} uses linear interpolation of the previously determined phases by default, so <br />
set this to "nearest" if you want to override this.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'], \<br />
gainfield=['','','2','2','2'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='2',refant='ea04',solnorm=F,<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'],\<br />
gainfield=['','','2','2','0'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',gaintype='G',calmode='a',append=True)<br />
</source><br />
This is the table we will apply to the data.<br />
<br />
[[Image:plotSN2010FZ_plotcal_G2infa1_4.0.png|200px|thumb|right|plotcal G2 per-scan amp ant 0~15]]<br />
[[Image:plotSN2010FZ_plotcal_G2infa2_4.0.png|200px|thumb|right|plotcal G2 per-scan amp ant 16~26]]<br />
<br />
We do a second version of the amplitude calibration, this time using <tt>combine='scan'</tt> on field 0. This is <br />
to use for input to {{fluxscale}} in the next step.<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G3', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'], \<br />
gainfield=['','','2','2','2'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='2',refant='ea04',solnorm=F,<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G3', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0','calSN2010FZ.B0','calSN2010FZ.G1int'],\<br />
gainfield=['','','2','2','0'], \<br />
interp=['','','nearest','nearest','nearest'], \<br />
field='0',refant='ea04',solnorm=F, \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
solint='inf',combine='scan',gaintype='G',calmode='a',append=True)<br />
</source><br />
<br />
Since the flux on the gain calibrator is not scaled to its correct flux (but to 1.0 Jy by default),<br />
use {{fluxscale}} to transfer the amplitude gains from 3c286:<br />
<source lang="python"><br />
# In CASA<br />
myflux = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G3', \<br />
fluxtable='calSN2010FZ.F3inc',reference='2',transfer='0',<br />
incremental=True)<br />
</source><br />
where we have captured the returned dictionary in the Python variable <tt>myflux</tt>. We have use the<br />
<tt>incremental=True</tt> option (new to CASA 4.0) to make this table contain only the scale factors <br />
per-antenna per-spw per-field needed to scale the data (rather than rescaling the input table). Thus it<br />
can be applied in addition to our <tt>G2</tt> table even though it was derived from the <tt>G3</tt> table.<br />
<br />
The logger output gives:<br />
<pre><br />
Found reference field(s): 3C286<br />
Found transfer field(s): J0925+0019<br />
Flux density for J0925+0019 in SpW=0 (freq=4.488e+09 Hz) is: 0.977483 +/- 0.00278572 (SNR = 350.891, N = 50)<br />
Flux density for J0925+0019 in SpW=1 (freq=4.616e+09 Hz) is: 0.975972 +/- 0.00253876 (SNR = 384.429, N = 50)<br />
Flux density for J0925+0019 in SpW=2 (freq=4.744e+09 Hz) is: 0.978538 +/- 0.00242824 (SNR = 402.982, N = 50)<br />
Flux density for J0925+0019 in SpW=3 (freq=4.872e+09 Hz) is: 0.979278 +/- 0.00244155 (SNR = 401.088, N = 50)<br />
Flux density for J0925+0019 in SpW=4 (freq=5e+09 Hz) is: 0.981804 +/- 0.00219239 (SNR = 447.823, N = 50)<br />
Flux density for J0925+0019 in SpW=5 (freq=5.128e+09 Hz) is: 0.981478 +/- 0.00314805 (SNR = 311.773, N = 50)<br />
Flux density for J0925+0019 in SpW=6 (freq=5.256e+09 Hz) is: 0.985493 +/- 0.00343534 (SNR = 286.869, N = 50)<br />
Flux density for J0925+0019 in SpW=7 (freq=5.384e+09 Hz) is: 0.978491 +/- 0.00201807 (SNR = 484.865, N = 50)<br />
Flux density for J0925+0019 in SpW=8 (freq=6.744e+09 Hz) is: 0.959005 +/- 0.00260159 (SNR = 368.623, N = 48)<br />
Flux density for J0925+0019 in SpW=9 (freq=6.872e+09 Hz) is: 0.955123 +/- 0.00262785 (SNR = 363.462, N = 48)<br />
Flux density for J0925+0019 in SpW=10 (freq=7e+09 Hz) is: 0.954202 +/- 0.00281227 (SNR = 339.3, N = 48)<br />
Flux density for J0925+0019 in SpW=11 (freq=7.128e+09 Hz) is: 0.950797 +/- 0.00354085 (SNR = 268.522, N = 48)<br />
Flux density for J0925+0019 in SpW=12 (freq=7.256e+09 Hz) is: 0.94732 +/- 0.00391511 (SNR = 241.965, N = 48)<br />
Flux density for J0925+0019 in SpW=13 (freq=7.384e+09 Hz) is: 0.939356 +/- 0.00383532 (SNR = 244.922, N = 48)<br />
Fitted spectrum for J0925+0019 with fitorder=1: Flux density = 0.968048 +/- 0.00159415 (freq=5.74863 GHz) <br />
spidx=-0.0721976 +/- 0.00943577<br />
...<br />
</pre><br />
You may see slightly different numbers on your machine (and will see more extensive output). Note that "N" here is the number of antennas x the number of polarizations used for the calculations; in this case, there are 24 unflagged antennas and 2 polarizations. As of CASA 4.0, {{fluxscale}} now returns a fitted spectral index (and possibly curvature, e.g. if fitorder>1), which can be input to {{setjy}} if you want to use these derived fluxes for a model. <br />
<br />
As it so happens, the derived flux for J0925+0019 is about 1 Jy (you can plot up the raw amplitudes for fields 0,2 and convince yourself this is indeed true and not a bug). The spectrum rises a bit to peak in spw 6 then falls again. We will not use the fitted spectrum (setjy does not yet take fitorder>1) but will apply a incremental table in subsequent processing.<br />
<br />
== Applying the Calibration and Final Editing ==<br />
<br />
Next we actually apply all our accumulated calibration tables. We apply these to the <br />
calibration fields individually using the appropriate gainfields and interpolation for each:<br />
* For 3C286 (field 2) we did short-timescale phase solutions and a single scan amplitude, so use "linear" and "nearest" interpolation respectively.<br />
* For the nearby gain calibrator (field 0) we did only scan-based phase and amplitude solutions so we use "nearest" interpolation<br />
* For the target source we use field 0 to calibrate field 1, so use "linear" interpolation. This takes a few minutes.<br />
<br />
[[Image:plotSN2010FZ_plotms_applied_fld2.png|200px|thumb|right|plotms of 3C286 with calibration applied]]<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1int','calSN2010FZ.G2'], \<br />
gainfield=['','','','','2','2'],<br />
interp=['','','nearest','nearest','nearest','nearest'], \<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1int','calSN2010FZ.G2',<br />
'calSN2010FZ.F3inc'], \<br />
gainfield=['','','','','0','0','0'],<br />
interp=['','','nearest','nearest','nearest','nearest',''], \<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1', \<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0',<br />
'calSN2010FZ.B0','calSN2010FZ.G1inf','calSN2010FZ.G2',<br />
'calSN2010FZ.F3inc'], \<br />
gainfield=['','','','','0','0','0'],<br />
interp=['','','nearest','nearest','linear','linear',''], \<br />
parang=False,calwt=False)<br />
</source><br />
Because we used <tt>usesratch=False</tt> in {{setjy}}, the <tt>CORRECTED_DATA</tt> scratch column will be created the first time you run {{applycal}}. This will store the calibrated data.<br />
<br />
We can examine the corrected data on 3c286 using our RFI mask from above and avoiding band edges<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
See figure above right. There is clearly discrepant data visible spw 5 and 6, in particular for baseline ea17&ea25 (use the '''Mark Regions''' [[Image:MarkRegionsButton.png]] tool on some of it and then use the '''Locate''' [[File:casaplotms-locate-tool.png]] tool), which gives a really strange response. You can plot just this baseline to be sure:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='ea17&ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
You can exclude this through antenna negation:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='!ea17&ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Then use '''Locate''' [[File:casaplotms-locate-tool.png]] for the other bad points, which seem to indicate spw 5,6,7 for ea14,ea16,ea17,ea25.<br />
Exclude these and replot:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
antenna='!ea14;!ea16;!ea17;!ea25', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld2.png|200px|thumb|right|plotms cal applied flagged fld2]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld2_phase.png|200px|thumb|right|plotms cal applied flagged fld2 phase]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_amp.png|200px|thumb|right|plotms cal applied flagged fld0 amp]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_phase.png|200px|thumb|right|plotms cal applied flagged fld0 phase]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_amp_exc_4.0.png|200px|thumb|right|plotms cal applied flagged fld0 amp, with new spw selection]]<br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_ampavg_4.0.png|200px|thumb|right|plotms cal applied flagged fld0 amp averaged]]<br />
<br />
This now looks clean except for the RFI in the upper subbands.<br />
<br />
Do flagging based on these:<br />
<source lang="python"><br />
# In CASA<br />
flaglist2 = ['antenna="ea14,ea16,ea17,ea25" spw="5~7"']<br />
flagcmd(vis='SN2010FZ_flagged10s.ms',inpmode='list',inpfile=flaglist2,action='apply')<br />
</source><br />
<br />
Now replot the corrected data (you may have to force reload if you plotted same thing right before this):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Looks pretty good.<br />
<br />
Plot the phase:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='2', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
Note the characteristic "bowtie" pattern of the phases about the sub-band centers.<br />
Here we can see the effect of the EVLA "delay clunking", where the delay steps through discrete values such that<br />
the phase goes from -11deg to +11deg across the sub-band as the delay changes due to geometry. This is D-configuration so the delays change slowly, it will change faster in wider configurations. As of Q3 2011 we have not enabled the corrections for this in the EVLA system so you will always have this remaining delay error in your data. In principle, you could solve for delays on short timescales and take this out; in practice, this in not possible for your weaker science target source (where it would matter most for results).<br />
<br />
Now let's plot the corrected data amplitude for the phase calibrator (field 0):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:10~59,1~7:4~59,8:4~13;18~59,9~11:4~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
You can see the bandpass filter roll-off increasing the noise at the baseband edges (about 8-16 channels worth). Also, we can see some RFI we missed:<br />
* <6804 MHz spw 8 below ch 30 lots of bad stuff (a lot from ea18,ea22 but others too)<br />
* 7168 MHz spw 11 ch 20<br />
* pretty much all of spw 12,13<br />
The ch 20 ones are all harmonics of a notorious 128 MHz tone. NOTE: You can get the frequency of a RFI feature by looking at the logger report from using the '''Locate''' [[File:casaplotms-locate-tool.png]] tool.<br />
<br />
We will not flag these, but exclude them in imaging (so that more advanced students can try flagging these in detail or using auto-flagging). A good channel selection string for imaging might be:<br />
<br />
<pre><br />
spw = '0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59'<br />
</pre><br />
<br />
Without further flagging, it may be best to drop spw 12-13 for imaging (we will do so from now on).<br />
<br />
Plot again (including this selection for spw 0-11):<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Looks better.<br />
<br />
Now plot amplitudes for the corrected data averaged over baseline to see the source spectrum:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0',<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59',<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
The "custom" plotting parameters show how to control the symbol shape and size from the task.<br />
<br />
The last two sub-bands spw 12-13 give reasonable values, with only a tiny offset from spw 8-11.<br />
There are also strange amplitude excursions, particularly in the low end of the first baseband. These must be coming<br />
from one or more scans. You can iterate over scan to see the strange amplitudes (mostly from scan 7):<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0',<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59,12:4~13;18~29;31~33;46~51;53~59,13:4~8;15~36;42~59',<br />
correlation='RR,LL',avgbaseline=True,avgtime='600s',iteraxis='scan',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
<br />
Also, there is an offset with the amplitudes for spw 6, perhaps due to the problem with baseline ea17&ea25 (which we flagged, but didn't recalibrate afterward) and likely affected the {{fluxscale}} solution. This is troubling enough that we will quickly go through a second round of calibration.<br />
<br />
== A Quick Recalibration ==<br />
<br />
We now go back and recalibrate the data. We may as well flag scan 7 first, as well:<br />
<br />
<source lang="python"><br />
# In CASA<br />
flagdata(vis='SN2010FZ_flagged10s.ms', scan='7')<br />
#<br />
# Clear the corrected data and model from header<br />
clearcal('SN2010FZ_flagged10s.ms',addmodel=False)<br />
#<br />
chanStr = '0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59'<br />
#<br />
mysetjy2 = setjy(vis='SN2010FZ_flagged10s.ms', field='2', scalebychan=True, modimage='3C286_C.im')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G0.2',field='2',spw='0~11:23~28',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve'],<br />
gaintype='G',refant='ea04',calmode='p',solint='int',minsnr=3)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.K0.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.G0.2'],<br />
field='2', spw=chanStr, gaintype='K',<br />
refant='ea04', combine='scan', solint='inf', minsnr=3)<br />
#<br />
bandpass(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.B0.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.G0.2','calSN2010FZ.K0.2'],<br />
field='2',refant='ea04',solnorm=False,<br />
spw='0~11', <br />
bandtype='B', combine='scan', solint='inf')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2int',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='2',refant='ea04',solnorm=F, <br />
spw=chanStr,<br />
solint='int',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2int',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='int',gaintype='G',calmode='p',append=True)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G1.2inf',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',gaintype='G',calmode='p')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','2'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='2',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.2',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','0'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',gaintype='G',calmode='a',append=True)<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.3',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','2'],<br />
interp=['','','nearest','nearest','nearest'],<br />
field='2',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a')<br />
#<br />
gaincal(vis='SN2010FZ_flagged10s.ms', caltable='calSN2010FZ.G2.3',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve',<br />
'calSN2010FZ.K0.2','calSN2010FZ.B0.2','calSN2010FZ.G1.2int'],<br />
gainfield=['','','2','2','0'], <br />
interp=['','','nearest','nearest','nearest'],<br />
field='0',refant='ea04',solnorm=F,<br />
spw=chanStr,<br />
solint='inf',combine='scan',gaintype='G',calmode='a',append=True)<br />
#<br />
myflux2 = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G2.3',<br />
fluxtable='calSN2010FZ.F2.3inc',reference='2',transfer='0',<br />
incremental=True)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='2',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2'],<br />
gainfield=['','','','','2','2'],<br />
interp=['','','nearest','nearest','linear','nearest'],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3inc'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','nearest','nearest',''],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2inf','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3inc'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','linear','linear',''],<br />
parang=False,calwt=False)<br />
</source><br />
<br />
Note that we have set the variable <tt>chanStr</tt> for our channel selection; this makes the task commands shorter and easier to read.<br />
<br />
The {{fluxscale}} output this time around is slightly different to the last:<br />
<pre><br />
Found reference field(s): 3C286<br />
Found transfer field(s): J0925+0019<br />
Flux density for J0925+0019 in SpW=0 (freq=4.488e+09 Hz) is: 0.978946 +/- 0.00284837 (SNR = 343.686, N = 50)<br />
Flux density for J0925+0019 in SpW=1 (freq=4.616e+09 Hz) is: 0.978634 +/- 0.00264066 (SNR = 370.602, N = 50)<br />
Flux density for J0925+0019 in SpW=2 (freq=4.744e+09 Hz) is: 0.980438 +/- 0.00251668 (SNR = 389.575, N = 50)<br />
Flux density for J0925+0019 in SpW=3 (freq=4.872e+09 Hz) is: 0.980116 +/- 0.00255481 (SNR = 383.636, N = 50)<br />
Flux density for J0925+0019 in SpW=4 (freq=5e+09 Hz) is: 0.982175 +/- 0.00230804 (SNR = 425.545, N = 50)<br />
Flux density for J0925+0019 in SpW=5 (freq=5.128e+09 Hz) is: 0.979574 +/- 0.00269688 (SNR = 363.225, N = 42)<br />
Flux density for J0925+0019 in SpW=6 (freq=5.256e+09 Hz) is: 0.980193 +/- 0.00271312 (SNR = 361.279, N = 42)<br />
Flux density for J0925+0019 in SpW=7 (freq=5.384e+09 Hz) is: 0.98102 +/- 0.00249166 (SNR = 393.721, N = 42)<br />
Flux density for J0925+0019 in SpW=8 (freq=6.744e+09 Hz) is: 0.962693 +/- 0.00282815 (SNR = 340.397, N = 48)<br />
Flux density for J0925+0019 in SpW=9 (freq=6.872e+09 Hz) is: 0.960313 +/- 0.00285418 (SNR = 336.459, N = 48)<br />
Flux density for J0925+0019 in SpW=10 (freq=7e+09 Hz) is: 0.957056 +/- 0.00303716 (SNR = 315.116, N = 48)<br />
Flux density for J0925+0019 in SpW=11 (freq=7.128e+09 Hz) is: 0.953964 +/- 0.00378326 (SNR = 252.154, N = 48)<br />
Flux density for J0925+0019 in SpW=12 is: INSUFFICIENT DATA <br />
Flux density for J0925+0019 in SpW=13 is: INSUFFICIENT DATA <br />
Fitted spectrum for J0925+0019 with fitorder=1: Flux density = 0.973376 +/- 0.00118872 (freq=5.52174 GHz) <br />
spidx=-0.0573991 +/- 0.00778736201<br />
</pre><br />
<br />
The source spectrum plot now looks somewhat better:<br />
<br />
[[Image:plotSN2010FZ_plotms_reproc_fld0_ampavg_4.0.png|200px|thumb|right|plotms recalibrated applied flagged fld0 amp averaged]]<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
As you see in the figure to the right, there are still spectral window to window variations that deviate from a smooth spectrum. This is due to noise in the {{fluxscale}} median filter now used in CASA 4.0 (in this well-calibrated case, the old weighted means used by {{fluxscale}} in CASA3.4 behaved better). If we use {{plotcal}} to plot the solutions versus antenna<br />
<source lang="python"><br />
# In CASA<br />
plotcal(caltable='calSN2010FZ.G2.3',xaxis='antenna',yaxis='amp',field='0',<br />
subplot=211,plotrange=[-1,-1,0.9,1.1])<br />
plotcal(caltable='calSN2010FZ.G2.3',xaxis='antenna',yaxis='amp',field='2',<br />
subplot=212,plotrange=[-1,-1,0.9,1.1],figfile='plotSN2010FZ_plotcal_G2.3_ampant.png')<br />
</source><br />
we see that there are variations that will enter into the medians. Some antennas are better behaved than others, for example ea12 (index 10) seems better than most.<br />
<br />
[[Image:plotSN2010FZ_plotcal_G2.3_ampant.png|200px|thumb|right|plotcal of G2.3 table, showing variation of solutions per antenna]]<br />
[[Image:screenshotPlotSN2010FZ_plotcal_fluxedit3_ea12.png|200px|thumb|right|plotcal of G2.3.ea12 table, marking all solutions but those for ea12 for flagging]]<br />
[[Image:screenshotPlotSN2010FZ_plotms_recalibrated3_EA12_fld0_amp_4.0.png|200px|thumb|right|plotms for fld 0 after application of F2.3.ea12 table]]<br />
Because we are applying an incremental correction for the flux scale, we have the latitude to change the caltable that goes into {{fluxscale}} to get a better result. For example, we can restrict the antennas that are used to derive the scale. Although there is not yet antenna selection in {{fluxscale}} itself, we can edit the caltable using {{plotcal}}. For example, make a copy of the G2.3 caltable and select only a single antenna:<br />
<source lang="python"><br />
# In CASA<br />
os.system('cp -rf calSN2010FZ.G2.3 calSN2010FZ.G2.3.ea12')<br />
plotcal(caltable='calSN2010FZ.G2.3.ea12',xaxis='antenna',yaxis='amp')<br />
</source><br />
In the plot to the right we show the GUI where we have boxed all but antenna ea12.<br />
Now we carry on with the {{fluxscale}} and {{applycal}}:<br />
<source lang="python"><br />
# In CASA<br />
myfluxEdit3 = fluxscale(vis='SN2010FZ_flagged10s.ms',caltable='calSN2010FZ.G2.3.ea12',<br />
fluxtable='calSN2010FZ.F2.3.ea12',reference='2',transfer='0',<br />
incremental=True)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='0',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2int','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3.ea12'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','nearest','nearest',''],<br />
parang=False,calwt=False)<br />
#<br />
applycal(vis='SN2010FZ_flagged10s.ms',field='1',spw='0~11',<br />
gaintable=['calSN2010FZ.antpos','calSN2010FZ.gaincurve','calSN2010FZ.K0.2',<br />
'calSN2010FZ.B0.2','calSN2010FZ.G1.2inf','calSN2010FZ.G2.2',<br />
'calSN2010FZ.F2.3.ea12'],<br />
gainfield=['','','','','0','0','0'], <br />
interp=['','','nearest','nearest','linear','linear',''],<br />
parang=False,calwt=False)<br />
</source><br />
The results appear better:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='60000s',<br />
xaxis='frequency',yaxis='amp',ydatacolumn='corrected',<br />
customsymbol=True,symbolshape='circle',symbolsize=2)<br />
</source><br />
Note that if you choose a different antenna than ea12 to use for this, you will get<br />
different results, usually worse. But this procedure illustrates how to use the<br />
incremental solutions from {{fluxscale}} to your possible advantage.<br />
<br />
We now return to examining our calibration.<br />
<br />
We can also plot the corrected phase - looks good:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
<br />
We can average over baseline and each scan:<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='0', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',avgbaseline=True,avgtime='600s',<br />
xaxis='frequency',yaxis='phase',ydatacolumn='corrected')<br />
</source><br />
[[Image:plotSN2010FZ_plotms_appliedflags_fld0_phaseavg.png|200px|thumb|right|plotms cal applied flagged fld0 phase averaged]]<br />
<br />
In this case, we can see the residual effect of the EVLA "delay clunking" described above, but it is reduced due to the averaging that we applied, but it is still there.<br />
<br />
You can look at the target source field='1', but there are lots of data so you will need to do a lot of averaging.<br />
For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='SN2010FZ_flagged10s.ms',field='1',avgtime='300s', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
correlation='RR,LL',xaxis='frequency',yaxis='amp',ydatacolumn='corrected')<br />
</source><br />
<br />
Alas, the upper baseband still has lots of low level RFI.<br />
<br />
Now split off the data for calibrators and target, to avoid later issues that can corrupt the MSs. We don't keep spw 12-15, since they weren't included in the last round of calibration, and we don't plan to image them.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_split10s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_split10s.ms', \<br />
datacolumn='corrected',field='1',spw='0~11')<br />
#<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_3c28610s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_3c28610s.ms', \<br />
datacolumn='corrected',field='2',spw='0~11')<br />
#<br />
# Remove any existing split data, otherwise split will not happen<br />
os.system('rm -rf SN2010FZ_J092510s.ms')<br />
split(vis='SN2010FZ_flagged10s.ms',outputvis='SN2010FZ_J092510s.ms', \<br />
datacolumn='corrected',field='0',spw='0~11')<br />
</source><br />
<br />
== Imaging ==<br />
<br />
This is EVLA D-configuration data at C-band. To determine the best parameters for imaging, it helps to start with the relevant information in the [http://evlaguides.nrao.edu/index.php?title=Observational_Status_Summary_-_Current Observational Status Summary]:<br />
<br />
* Synthesized beam should be 12" at 6 GHz with primary beam field of view of 7.5 arcmin (450")<br />
<br />
Our data spans 4.5-7.5 GHz: this is a relatively large fractional bandwidth, resulting in substantial variation of the field of view over the entire frequency range. FOV = 45 arcmin / Frequency (GHz), giving 10 arcmin at 4.5 GHz, and 6 arcmin at 7.5 GHz. Likewise, the synthesized beam ranges from 16" at 4.5 GHz to 9.6" at 7.5 GHz. We want to subsample the synthesized beam by a factor of 3-4, so will use a cellsize of 3". To cover the full FOV (keeping it at the inner part of the image) at the lowest frequencies, we will want an image size of >400 pixels, or >20 arcmin.<br />
<br />
We will also use the Briggs robust (with <tt>robust=0.5</tt>) weighting, which is a compromise between uniform and natural weighting,<br />
and will give reasonable resolution but will allow us to still see larger scale structure.<br />
<br />
Due to the numerology of [http://www.fftw.org/ FFTW's] (which {{clean}} uses under the hood for FFTs) optimal sizes, <br />
<tt>imsize</tt> should be composite number with two and only two prime factors chosen from<br />
2, 3, and 5. Taking into account the x1.2 padding that clean uses internally to the imsize<br />
you give it (and 1.2 = 2*3/5), we choose 640 or 1280 as our imsize (640 = 2^7*5). Other<br />
reasonable sets would be 405, 1215, etc. (405 = 3^4*5) or 432, 648, 1296 (these are 2^n*3^m*5).<br />
In practice, if you give it non-optimal values for imsize, you may find that the transforms<br />
take a bit longer, which is noticeable if you are doing interactive clean.<br />
<br />
WARNING: By default, a single-field nterms=1 clean does NOT use Cotton-Schwab (CS) clean to break<br />
into major cycles going back to data residuals, it just does cleaning in a bunch of minor<br />
cycles in the image plane. This can give much poorer imaging quality in cases with poor<br />
uv coverage (snapshots) or in the case of complex emission structure (like ours) -- clean tends to<br />
diverge in this case. You should explicitly set <tt>imagermode='csclean'</tt> in your<br />
call to clean. Also, in our case the psf is very good using mfs, so by default it will not<br />
take many major cycle breaks. We use the <tt>cyclefactor</tt> parameter to control this, which<br />
sets the break threshold to be cyclefactor times the max psf sidelobe level (outside the main<br />
peak). We start at <tt>cyclefactor=1.5</tt> in a single spw, and ratchet it up to 4.5 when we<br />
clean all the spw. This seems to work ok. Rule of thumb is if it is gobbling up many hundreds of<br />
clean iterations in the minor cycles early on, increase cyclefactor. Conversely, if your psf is poor<br />
but you source structure is simple, you can reduce cyclefactor (e.g. below 1) to stop it from taking<br />
lots of extra major cycles.<br />
<br />
For more information on using {{clean}}, in particular on using the interactive GUI, see<br />
[[EVLA_Continuum_Tutorial_3C391#Imaging]]. WARNING: In CASA 4.0 the GUI interface for clean <br />
and the viewer has changed slightly. Some of the screenshots shown below may differ slightly <br />
from what you see.<br />
<br />
NOTE: If you are pressed for time, then you might want to jump ahead to<br />
[[EVLA_6-cm_Wideband_Tutorial_SN2010FZ_(Caltech)#Cleaning_the_lower_baseband_using_two_MFS_Taylor_terms]] <br />
and while it is cleaning you can read the other Imaging descriptions.<br />
<br />
=== Cleaning a single spectral window ===<br />
<br />
Let us start by interactively cleaning one of the lower baseband spw (spw 5 in this example).<br />
NOTE: this first time will take a few minutes at start to create scratch columns<br />
in the MS in case we want to do self-calibration later.<br />
<br />
'''Note that interrupting {{clean}} by Ctrl+C may corrupt your visibilities -- you may be better off choosing to let {{clean}} finish. We are currently implementing a command that will nicely exit to prevent this from happening, but for the moment try to avoid Ctrl+C.'''<br />
<br />
[[Image:viewSN2010FZ_spw5_clean640_4.0.png|200px|thumb|right|interactive clean spw5 640x640 after around 1000 iterations]]<br />
[[Image:viewSN2010FZ_spw5_clean1280.png|200px|thumb|right|2nd interactive clean spw5 1280x1280 before cleaning]]<br />
[[Image:viewSN2010FZ_spw5_clean1280final_4.0.png|200px|thumb|right|viewer showing clean spw5 1280x1280 restored image]]<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw5_clean640*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='5:4~59', \<br />
imagename='imgSN2010FZ10s_spw5_clean640', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[640,640],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
* Start carefully by boxing the bright source and setting iterations to 10 at first<br />
* Gradually add more boxes and increase the number of iterations<br />
* Since this is not much more than a snapshot you see the six-fold sidelobe pattern<br />
of the extended emission in the center of the map. This decreases as you clean<br />
out this emission.<br />
* Stop cleaning when the residuals look like noise (and you cannot clearly see sources).<br />
* To stop, click the red [[File:clean-stop.png]] button.<br />
<br />
The top figure to the right shows a zoom in on the end state of the clean, where<br />
we have marked a number of boxes and cleaned them out.<br />
<br />
Note that there are some strange sidelobe patterns in lower left, possibly <br />
from a source outside the image area. We can make a bigger image starting from<br />
our current model:<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw5_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='5:4~59', \<br />
imagename='imgSN2010FZ10s_spw5_clean1280', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
modelimage='imgSN2010FZ10s_spw5_clean640.model', \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
Sure enough, there is a bright source near the lower left (see middle panel at right). <br />
Box it, clean it a bit, and look again. There is a second source in the mid-left (track<br />
it down by its sidelobes). Box this one, clean it a bit, and when satisfied stop.<br />
<br />
You can use the CASA {{viewer}} to display the images that {{clean}} creates. If you need more guidance<br />
on using the viewer, see the [http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html CASA Viewer Demo] video<br />
(note that this is for a much earlier version of the viewer, and the interface has changed since then). <br />
<br />
Bring up your restored image directly:<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw5_clean1280.image')<br />
</source><br />
<br />
The restored image is shown in the bottom panel to the right. I have chosen the Grayscale1 instead of default color<br />
map as I prefer "Grayscale" to false color "Rainbow" for assessing image quality. Also, you can change the scaling of the image using the "scaling power cycles" slider under "basic settings".<br />
<br />
Check the rms of the residuals using the {{imstat}} task:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw5_clean1280.residual')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
In this particular case, it's 31.8 uJy; yours will likely be slightly different.<br />
<br />
=== Cleaning the lower baseband ===<br />
<br />
[[Image:viewSN2010FZ_spw0to7_clean1280final.png|200px|thumb|right|clean spw0-7 restored image center]]<br />
Now, image the entire lower baseband (spw 0-7).<br />
Follow same iterative procedure as before, and get the best<br />
residuals you can without "cleaning the noise". <br />
<br />
* Because of the bandwidth and frequency synthesis, the sidelobe pattern is different than before and it is much easier to see fainter emission.<br />
* Be careful cleaning sources that lie near or on sidelobe splotches.<br />
* Clean the central emission region way down first to reduce the sidelobe level before adding components in the sidelobe areas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to7_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='0:16~59,1~6:4~59,7:4~54', \<br />
imagename='imgSN2010FZ10s_spw0to7_clean1280', \<br />
mode='mfs',nterms=1,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=1.5, \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to7_clean1280.residual')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this run, the rms is 11.3 uJy (and there is clearly some structure left in the residual). To the right is a zoom-in on the center of the restored image.<br />
<br />
==== Cleaning the lower baseband using two MFS Taylor terms ====<br />
<br />
The mfs nterms=2 option creates two "Taylor Term" images - an average intensity image (with suffix <tt>.image.tt0</tt>) <br />
and a spectral slope image (with suffix <tt>.image.tt1</tt>) which is intensity x alpha (where alpha is spectral index).<br />
For convenience there is a spectral index image (with suffix <tt>.image.alpha</tt>). These Taylor expansions are with respect to the "Reference Frequency" of the image (by default the center frequency of the spw selected, but can be specified using the <tt>reffreq</tt> parameter in {{clean}}). The convention for spectral index alpha is that<br />
<br />
<math><br />
S \propto \nu^\alpha<br />
</math><br />
<br />
so negative spectral indexes indicate a "steep" spectrum (falling with frequency).<br />
<br />
[[Image:viewSN2010FZ_spw0to7_mfs2clean.png|200px|thumb|right|clean spw0-7 mfs nterms=2 in progress]]<br />
Let's try using multi-frequency synthesis with nterms=2 on the lower baseband.<br />
The dirty beam will have lower sidelobes so we turn up <tt>cyclefactor</tt> for <tt>csclean</tt> a bit. Note: if you're feeling a bit lazy, and trust your previous set of clean boxes, you can also set <tt>mask='imgSN2010FZ10s_spw0to7_clean1280.mask'</tt> to use these as a starting point:<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to7_mfs2_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms',spw='0:16~59,1~6:4~59,7:4~54', \<br />
imagename='imgSN2010FZ10s_spw0to7_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=10000,gain=0.1,threshold='0.0mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
weighting='briggs',robust=0.5,interactive=True,mask=[])<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to7_mfs2_clean1280.residual.tt0')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this run, the rms is 10.5 uJy (somewhat better-looking than the nterms=1).<br />
The top screenshot to the right shows an intermediate but early stage of cleaning where we are looking at<br />
the central emission and cleaning it out slowly.<br />
<br />
You can use the {{viewer}} to load the average intensity image:<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0')<br />
</source><br />
<br />
and then use the Open Data panel to load the spectral index image <tt>imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha</tt><br />
which can then be blinked (optionally plotted side-by-side using the Panel Display Options panel to set 2 panels in the x direction). <br />
<br />
[[Image:viewSN2010FZ_spw0to7_mfs2loadalpha_4.0.png|200px|thumb|right|clean spw0-7 mfs nterms=2 load alpha with LEL]]<br />
[[Image:viewSN2010FZ_spw0to7_mfs2panelalpha_4.0.png|200px|thumb|right|clean spw0-7 mfs nterms=2 tt0 and alpha (filtered at 0.1mJy in tt0)]]<br />
<br />
Note there is a lot of noise in alpha in the low-intensity regions, and thus filtering the alpha image based on the values in the tt0 image is desirable. You can use the {{immath}} task to make this filtered alpha image explicitly, using a <br />
Lattice Expression Language (LEL) expression: <br />
<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename=['imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha', <br />
'imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM1>1.0E-4]',<br />
outfile='imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha.filtered')<br />
</source><br />
<br />
This will use 0.1 mJy (or 10 x the sigma we found) as the cutoff.<br />
You can then view or manipulate the filtered alpha image as normal.<br />
<br />
We can also use LEL to filter the alpha image on the intensity on-the-fly when we load this raster in the Open Data panel<br />
by specifying a LEL string in the LEL box instead of selecting the image from the directory <br />
listing. The LEL string:<br />
<br />
<pre><br />
'imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.alpha'['imgSN2010FZ10s_spw0to7_mfs2_clean1280.image.tt0'>1.0E-04]<br />
</pre><br />
<br />
will replicate what we did above. The middle figure to the right shows the Open Data panel<br />
with our LEL string in it. Just click the Raster button to load this.<br />
<br />
The lower panel to the right shows the intensity and LEL-filtered alpha images side-by-side in the viewer, zoomed<br />
in on the galaxy emission. Mousing over the alpha shows spectral indexes ranging from -1 to +1 in the center, with<br />
the brightest emission with alpha -0.7 in the knots in the disk.<br />
<br />
=== Cleaning using both basebands combined ===<br />
<br />
For the ultimate image, use the "clean" part of the upper baseband in addition<br />
to the lower (use spw 0-11). We will use mfs with nterms=2 (if you try nterms=1 <br />
on this wide bandwidth you will get much poorer residuals). Because of the added<br />
work and extra data involved, this will take much longer than our other runs of<br />
clean. Therefore, we will get a head start by doing a non-interactive clean using<br />
the mask left from the previous clean (spw 0-7). We will insert a clean threshold<br />
to limit runaway cleaning too far beneath the noise level. <br />
<br />
This will take a while, especially if there are other processes running on your machine (with nothing else running, expect ~30-40 minutes).<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Removing any previous cleaning information<br />
# This assumes you want to start this clean from scratch<br />
# If you want to continue this from a previous clean run, <br />
# the rm -rf system command should be be skipped<br />
os.system ('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280*')<br />
clean(vis='SN2010FZ_split10s.ms', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
imagename='imgSN2010FZ10s_spw0to11_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=3000,gain=0.1,threshold='0.002mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
mask=['imgSN2010FZ10s_spw0to7_mfs2_clean1280.mask'], \<br />
weighting='briggs',robust=0.5,interactive=False)<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.residual.tt0')<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
For this particular run, the rms was 8.9 uJy (noticeably better than the lower baseband only results).<br />
<br />
[[Image:viewSN2010FZ spw0to11_mfs2resid.png|200px|thumb|right|final residual and mask]]<br />
<br />
Let us see if there is more to clean. Bring this up in interactive mode:<br />
<br />
<source lang="python"><br />
# In CASA<br />
clean(vis='SN2010FZ_split10s.ms', \<br />
spw='0:16~59,1~6:4~59,7:4~54,8:30~59,9~10:4~59,11:4~19;21~59', \<br />
imagename='imgSN2010FZ10s_spw0to11_mfs2_clean1280', \<br />
mode='mfs',nterms=2,niter=3000,gain=0.1,threshold='0.001mJy', \<br />
psfmode='clark',imsize=[1280,1280],cell=['3.0arcsec'],stokes='I', \<br />
imagermode='csclean', cyclefactor=4.5, \<br />
mask='imgSN2010FZ10s_spw0to11_mfs2_clean1280.mask', \<br />
weighting='briggs',robust=0.5,interactive=True)<br />
</source><br />
<br />
This should start cleaning from where our previous non-interactive clean left off.<br />
<b>Note for 4.2.0:</b> In this case we have specified <tt>mask='imgSN2010FZ10s_spw0to11_mfs2_clean1280.mask'</tt> explicitly due to a bug where it will not otherwise allow you to edit the mask interactively.<br />
<br />
You might find a few more sources revealed in the outer parts of the image, and also more <br />
emission around the galaxy disk in the center. Try drawing new boxes, perhaps extend the box<br />
in the center, and do ~100-1000 more iterations. At the end, what is left should be dominated<br />
by the error patterns from mis-calibration. Only self-calibration will get rid of<br />
these. Stop cleaning for now. See the figure to the right for the interactive display panel<br />
showing final residuals and mask (changing the colormap to <tt>Greyscale 1</tt>).<br />
<br />
Check the residual levels:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.residual.tt0')<br />
sigma = mystat['sigma'][0]<br />
print 'Residual standard deviation = '+str(mystat['sigma'][0])<br />
</source><br />
<br />
The final rms achieved here is 8.7 uJy; slightly better.<br />
<br />
== Analyzing the image ==<br />
<br />
Let's see how close we got to expected noise and dynamic range:<br />
<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0')<br />
peak = mystat['max'][0]<br />
print 'Image max flux = '+str(mystat['max'][0])<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.model.tt0')<br />
total = mystat['sum'][0]<br />
print 'Model total flux = '+str(mystat['sum'][0])<br />
#<br />
snr = peak/sigma<br />
print 'SN2010FZ peak S/N = '+str(snr)<br />
#<br />
snr = total/sigma<br />
print 'SN2010FZ total S/N = '+str(snr)<br />
</source><br />
The output gives:<br />
<pre><br />
Residual standard deviation = 8.60710739215e-06<br />
Image max flux = 0.00995589420199<br />
Model total flux = 0.0371581438531<br />
SN2010FZ peak S/N = 1156.70616717<br />
SN2010FZ total S/N = 4317.14653485<br />
</pre><br />
<br />
What do we expect? If we do {{listobs}} on this MS we see the scans:<br />
<pre><br />
Date Timerange (UTC) Scan FldId FieldName nRows Int(s) <br />
11-Jul-2010/21:38:44.0 - 21:39:51.0 9 0 SN2010FZ 33696 9.16 <br />
21:40:01.0 - 21:41:20.5 10 0 SN2010FZ 37908 9.89 <br />
21:41:30.0 - 21:42:50.0 11 0 SN2010FZ 37908 10 <br />
21:43:00.0 - 21:44:20.0 12 0 SN2010FZ 37908 10 <br />
21:44:30.0 - 21:45:50.0 13 0 SN2010FZ 37908 10 <br />
21:46:00.0 - 21:47:19.5 14 0 SN2010FZ 37908 9.89 <br />
21:47:29.0 - 21:47:49.0 15 0 SN2010FZ 12636 9.67 <br />
21:49:42.0 - 21:50:49.0 17 0 SN2010FZ 33696 9.17 <br />
21:50:59.0 - 21:52:19.0 18 0 SN2010FZ 37908 10 <br />
21:52:29.0 - 21:53:48.5 19 0 SN2010FZ 37908 9.89 <br />
21:53:58.0 - 21:55:18.0 20 0 SN2010FZ 37908 10 <br />
21:55:28.0 - 21:56:48.0 21 0 SN2010FZ 37908 10 <br />
21:56:58.0 - 21:58:18.0 22 0 SN2010FZ 37908 10 <br />
21:58:28.0 - 21:58:47.5 23 0 SN2010FZ 12636 9.67 <br />
22:00:39.5 - 22:01:47.0 25 0 SN2010FZ 33696 9.18 <br />
22:01:57.0 - 22:03:17.0 26 0 SN2010FZ 37908 10 <br />
22:03:27.0 - 22:04:47.0 27 0 SN2010FZ 37908 10 <br />
22:04:57.0 - 22:06:16.5 28 0 SN2010FZ 37908 9.89 <br />
22:06:26.0 - 22:07:46.0 29 0 SN2010FZ 37908 10 <br />
22:07:56.0 - 22:09:16.0 30 0 SN2010FZ 37908 10 <br />
22:09:26.0 - 22:09:45.5 31 0 SN2010FZ 12636 9.67 <br />
22:11:38.0 - 22:12:45.5 33 0 SN2010FZ 33696 9.19 <br />
22:12:55.0 - 22:14:15.0 34 0 SN2010FZ 37908 10 <br />
22:14:25.0 - 22:15:45.0 35 0 SN2010FZ 37908 10 <br />
22:15:55.0 - 22:17:15.0 36 0 SN2010FZ 37908 10 <br />
22:17:25.0 - 22:18:44.5 37 0 SN2010FZ 37908 9.89 <br />
22:18:54.0 - 22:20:14.0 38 0 SN2010FZ 37908 10 <br />
22:20:24.0 - 22:20:43.5 39 0 SN2010FZ 12636 9.67 <br />
(nVis = Total number of time/baseline visibilities per scan) <br />
</pre><br />
(listing columns truncated) and we estimate about 37 minutes on target. We had about 25 antennas on average, and our spw selection picked out 610 channels (2 MHz each) for a total of 1220 MHz bandwidth. If we plug this<br />
into the<br />
[https://science.nrao.edu/facilities/evla/calibration-and-tools/exposure EVLA exposure calculator], at 5 GHz, we find that we expect a rms thermal noise level of 8.7 uJy, and at 7 GHz, 7.0 uJy. So, our values are within the expected range (a bit higher than theoretical, but that's expected). <br />
<br />
[[Image:plotSN2010FZ_viewerfinal.png|200px|thumb|right|final image]]<br />
Look at this in the viewer:<br />
<source lang="python"><br />
# In CASA<br />
viewer('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0')<br />
</source><br />
Zoom in on the center (see figure to the right).<br />
<br />
[[Image:viewSN2010FZ_spw0to11_mfs2tt1.png|200px|thumb|right|final tt1 image with box]]<br />
In the previous section we demonstrated how to process and display the spectral index image. You can do<br />
the same for this final image. Here, we will do some rough analysis on the spectral index to determine<br />
an intensity-weighted mean spectral index over the core region.<br />
The <tt>.image.tt1</tt> from our mfs is an intensity times alpha image. See the figure to the right.<br />
Let's gate the Taylor-term images on intensity:<br />
<source lang="python"><br />
# In CASA<br />
# Removing any file output from previous runs, so immath will proceed<br />
os.system('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered')<br />
immath(imagename=['imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1',<br />
'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM1>5.0E-5]',<br />
outfile='imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered')<br />
#<br />
# Removing any file output from previous runs, so immath will proceed<br />
os.system('rm -rf imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered')<br />
immath(imagename=['imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'],<br />
mode='evalexpr',<br />
expr='IM0[IM0>5.0E-5]',<br />
outfile='imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered')<br />
</source><br />
<br />
We can identify a box containing the central emission (see figure of tt1 in viewer) and note the corners.<br />
(We could also use the region tools from the viewer, but that is for another exercise.)<br />
Let us compute the intensity-weighted spectral index over this box by averaging<br />
these masked images using {{imstat}} and computing the ratio:<br />
<source lang="python"><br />
# In CASA<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt1.filtered',<br />
box='503,533,756,762')<br />
avgtt0alpha = mystat['mean'][0]<br />
#<br />
mystat = imstat('imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0.filtered',<br />
box='503,533,756,762')<br />
avgtt0 = mystat['mean'][0]<br />
avgalpha = avgtt0alpha/avgtt0<br />
print 'SN2010FZ I-weighted Alpha = '+str(avgalpha)<br />
</source><br />
We get <br />
<pre><br />
SN2010FZ I-weighted Alpha = -1.38157453384<br />
</pre><br />
<br />
The emission in this source is on the steep side. At this point we do not know how reliable this is or<br />
what we expect (though our calibrators come out with correct spectral indexes if we image them the<br />
same way). But this illustrates a way to extract spectral information from our wideband mfs images.<br />
<br />
== Comparing with the Optical/Infrared ==<br />
<br />
As a final comparison, we turn to the Sloan Digital Sky Survey (SDSS) and a cutout image of our galaxy:<br />
[[Image:NGC_2967_UGC_5180_IRAS_09394+0033_irg.jpg|400px|thumb|center|]]<br />
from their [http://cosmo.nyu.edu/hogg/rc3/NGC_2967_UGC_5180_IRAS_09394+0033_irg.jpg RC3]<br />
album (courtesy D.Hogg, M.Blanton, SDSS collaboration - see [[#Credits]]). This looks like a nice nearby<br />
face-on spiral galaxy. How does our 6cm continuum emission line up with the optical?<br />
<br />
Here is the EVLA 6cm image side by side with a i-band image from the Sloan Digital Sky Survey (SDSS) registered to our image:<br />
<br />
[[Image:plotSN2010FZ viewerfinalandSDSS.png|600px|thumb|center|final and sdss image]]<br />
<br />
You can also find this image, named <tt>NGC_2967_UGC_5180_IRAS_09394+0033-i.fits</tt>, on the web at <tt>http://casa.nrao.edu/Data/EVLA/SN2010FZ/NGC_2967_UGC_5180_IRAS_09394+0033-i.fits</tt> (at the CASA workshop, it's in <tt>/data/casa/evla/</tt> or a similar location that will be given to you in the instructions). Load it into your viewer, and blink against our 6cm image.<br />
<br />
We can also plot one as a raster and the other overlaid as contours. You can load the SDSS image<br />
from the viewer Load Data panel and fiddle with contours. Once you know contour levels, you can<br />
also use the imview task to load a raster and contour image:<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={ 'file' : 'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0'},<br />
contour = { 'file' : 'NGC_2967_UGC_5180_IRAS_09394+0033-i.fits',<br />
'levels' : [0.2, 0.5, 1, 1.5, 3],<br />
'base' : 0.0,<br />
'unit' : 1.0 } )<br />
</source><br />
<br />
The figure below shows the SDSS contours overlaid on our 6cm image (after fiddling with the <br />
colormap shift/slope for the EVLA raster image). <br />
<br />
[[Image:viewSN2010FZ_spw0to11_mfs2tt0plusSDSS.png|400px|thumb|center|6cm EVLA raster plus SDSS i-band contours]]<br />
<br />
Likewise, we can plot the SDSS image as a raster and overlay EVLA 6cm contours:<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={ 'file' : 'NGC_2967_UGC_5180_IRAS_09394+0033-i.fits',<br />
'scaling' : -2.0,<br />
'range' : [0,10] },<br />
contour = { 'file' : 'imgSN2010FZ10s_spw0to11_mfs2_clean1280.image.tt0',<br />
'levels' : [0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56],<br />
'base' : 0.0,<br />
'unit' : 0.001 },<br />
zoom = { 'blc' : [397,300],<br />
'trc' : [1567,1231] } )<br />
</source><br />
<br />
This is shown in the figure below. Is the compact 6cm emission in upper left associated with a<br />
spiral arm?<br />
<br />
[[Image:viewSN2010FZ_spw0to11_SDSSiplusEVLA6cm.png|400px|thumb|center|SDSS i-band raster plus EVLA 6cm contours]]<br />
<br />
== What to do next: some exercises for the user ==<br />
<br />
Here are a number of things you can try after completing this tutorial:<br />
<br />
# Use self-calibration to improve the data and re-clean to make a better image. See [http://casaguides.nrao.edu/index.php?title=WorkshopSelfcal_(Caltech) this tutorial] for more information on self-calibration.<br />
# Use multi-scale clean by adding non-zero scales to the <tt>multiscale</tt> parameter.<br />
# Image the calibrators. What sort of dynamic range can you get on them? Is self-calibration needed (and if so what dynamic range do you get when you use it)?<br />
# Try the <tt>testautoflag</tt> task (in 3.3.0 and later) to automatically flag RFI from the upper sideband. There is more information on running <tt>testautoflag</tt> in [http://casaguides.nrao.edu/index.php?title=EVLA_Wide-Band_Wide-Field_Imaging:_G55.7_3.4_(Caltech) this tutorial].<br />
<br />
== Credits ==<br />
<br />
The EVLA data was taken by A. Soderberg et al. as part of project AS1015. See <br />
[https://science.nrao.edu/enews/3.8/index.shtml#evlanoise NRAO eNews 3.8] (1-Sep-2010) for more on this result.<br />
<br />
<blockquote><i><br />
The Expanded Very Large Array (EVLA) is a partnership of the United States, Canada, and Mexico. The EVLA is funded in the United States by the National Science Foundation, in Canada by the National Research Council, and in Mexico by the Comisión Nacional de Investigación CientÃfica y Tecnológica (CONICyT).<br />
</i></blockquote><br />
<br />
<blockquote><i><br />
The National Radio Astronomy Observatory is a facility of the National Science Foundation operated under cooperative agreement by Associated Universities, Inc.<br />
</i></blockquote><br />
<br />
SDSS image courtesy David Hogg & Michael Blanton, private communication. Data comes from<br />
SDSS DR7, see [http://adsabs.harvard.edu/abs/2009ApJS..182..543A Abazajian et. al 2009].<br />
<br />
<blockquote><i><br />
Funding for the SDSS and SDSS-II has been provided by the Alfred P. Sloan Foundation, the Participating Institutions, the National Science Foundation, the U.S. Department of Energy, the National Aeronautics and Space Administration, the Japanese Monbukagakusho, the Max Planck Society, and the Higher Education Funding Council for England. The SDSS Web Site is [http://www.sdss.org/].<br />
</i></blockquote><br />
<br />
<blockquote><i><br />
The SDSS is managed by the Astrophysical Research Consortium for the Participating Institutions. The Participating Institutions are the American Museum of Natural History, Astrophysical Institute Potsdam, University of Basel, University of Cambridge, Case Western Reserve University, University of Chicago, Drexel University, Fermilab, the Institute for Advanced Study, the Japan Participation Group, Johns Hopkins University, the Joint Institute for Nuclear Astrophysics, the Kavli Institute for Particle Astrophysics and Cosmology, the Korean Scientist Group, the Chinese Academy of Sciences (LAMOST), Los Alamos National Laboratory, the Max-Planck-Institute for Astronomy (MPIA), the Max-Planck-Institute for Astrophysics (MPA), New Mexico State University, Ohio State University, University of Pittsburgh, University of Portsmouth, Princeton University, the United States Naval Observatory, and the University of Washington.<br />
</i></blockquote><br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2&diff=15560EVLA Advanced Topics 3C391 CASA 4.22014-02-06T16:22:11Z<p>Smyers: /* 3C391 Line studies */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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 high frequency Spectral Line tutorial - 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].<br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2&diff=15559EVLA Advanced Topics 3C391 CASA 4.22014-02-06T16:20:34Z<p>Smyers: /* 3C391 Line studies */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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].<br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2&diff=15558EVLA Advanced Topics 3C391 CASA 4.22014-02-06T00:18:20Z<p>Smyers: /* Self-Calibration */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=[False])<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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-CASA4.1.0]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391-CASA4.1]], 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].<br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2&diff=15557EVLA Advanced Topics 3C391 CASA 4.22014-02-05T23:57:33Z<p>Smyers: /* Multi-scale Polarization Clean */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<b>Warning:</b> This will be significantly slower than in 4.1 due to improvements in the calculation of the frequency-dependent primary beam. For this example it will take around 4-5 minutes to bring up the first image, and something like a few minutes per major cycle.<br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=F)<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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-CASA4.1.0]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391-CASA4.1]], 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].<br />
<br />
{{Checked 4.2.0}}</div>Smyershttps://casaguides.nrao.edu/index.php?title=EVLA_Advanced_Topics_3C391_CASA_4.2&diff=15556EVLA Advanced Topics 3C391 CASA 4.22014-02-05T23:37:25Z<p>Smyers: /* Image Analysis and Manipulation */</p>
<hr />
<div>[[Category:EVLA]]<br />
This is the second part of the EVLA 3C391 data reduction tutorial. [http://casaguides.nrao.edu/index.php?title=EVLA_Continuum_Tutorial_3C391_CASA_4.2 3C391 Tutorial Part 1: calibration, imaging]<br />
<br />
<b>This casaguide is for Version 4.2.0 of CASA.</b><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 in the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]]. <br />
<!-- on the first day of the NRAO Synthesis Imaging Workshop data reduction tutorials. --><br />
<br />
== Starting Point ==<br />
<br />
If you finished the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] you will have ended up with a dataset called <br />
<tt>3c391_ctm_mosaic_spw0.ms</tt>. This is what we will use to carry on with our polarization imaging.<br />
<br />
If you have not completed the first part of the EVLA Continuum Data Reduction Tutorial, you have a couple of options (in order of increasing complexity):<br />
<br />
* You can obtain the calibrated split mosaic data from [http://casa.nrao.edu/Data/EVLA/3C391/EVLA_3C391_FinalCalibratedMosaicMS.tgz EVLA_3C391_FinalCalibratedMosaicMS.tgz] (dataset size: 1.3GB). You unpack it using <tt>tar xzf EVLA_3C391_FinalCalibratedMosaicMS.tgz</tt> which will create a subdirectory called <tt>VLA_3C391_FinalCalibratedMosaicMS</tt> with the MS <tt>3c391_ctm_mosaic_spw0.ms</tt> inside it. You can then <tt>cd</tt> into this directory and run <tt>casapy</tt> from there.<br />
* One could use the [[Extracting scripts from these tutorials | script extractor]] to generate a CASA reduction script from the [[EVLA Continuum Tutorial 3C391-CASA4.1 | Continuum Data Reduction Tutorial]] 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 />
== Multi-scale Polarization Clean ==<br />
<br />
[[Image:screenshot_3c391part2_interclean_1.png|thumb|After the first 500 iterations of multi-scale clean for Stokes I plane]]<br />
[[Image:screenshot_3c391_clean_interactive_ms_final.png|thumb|Interactive residuals in I after 15000 iterations of multi-scale clean]]<br />
We now employ a multi-scale clean to image Stokes IQUV:<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=25000,<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=[480,480], cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
pbcor=False,<br />
usescratch=False)<br />
</source><br />
<br />
For these inputs, we have changed:<br />
* <tt>stokes='IQUV', psfmode='clarkstokes'</tt> : 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 />
* <tt>multiscale=[0, 6, 18, 54], smallscalebias=0.9</tt> : 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 />
* <tt>pbcor=False</tt> : by default <tt>pbcor=False</tt> and a flat-noise image is produced. We can do the primary beam correction later (see below).<br />
<br />
[[Image:screenshot_3c391_viewer_ms_final_I.png|thumb|Viewer panel for Stokes I of final restored image (using HotMetal1 colormap)]]<br />
[[Image:screenshot_3c391_viewer_ms_final_V.png|thumb|Viewer panel for Stokes V (using scaling power cycles of -1.5)]]<br />
As previously, we guide the clean using polygon regions in the interactive clean GUI. Because we now have the four Stokes planes in the image for IQUV, you should be sure to extend the mask you draw by selecting the "All Polarizations" radio button <b>before</b> drawing the mask. As you clean, you can use the tapedeck to examine the residuals in the QUV planes. In practice, those will reach the 1 mJy threshold fairly quickly and not be cleaned further while the I cleaning proceeds for a long time. In the screen-shots to the right, you can see that the multiscale clean is doing a better job of picking up the larger-scale emission. After about 15000 iterations the residuals were looking pretty good. As mentioned above restarting clean with different <tt>multiscale</tt> choices can help also.<br />
<br />
After the imaging and deconvolution process has finished, you can use the {{viewer}} to look at your image.<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.image')<br />
</source><br />
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). Also using the "wrench" panel to change Display Options will be helpful here. In the I Stokes plane (1) shown to the right we chose the "Hot Metal 1" colormap. In the lower panel showing the V Stokes plane (3) we also set the "scaling power cycles" to -1.5 to enhance low-contrast emission. Our Stokes I image is significantly better than with just a delta-function classic clean. You can also explore the Q and U images but we will produce more intuitive images from these later on. Finally, note that the residual emission in Stokes V is not real, but likely due to the EVLA "beam squint" between R and L (they are slightly separated on the sky, and this is not currently compensated for in our production version of clean).<br />
<br />
The clean task naturally operates in a "flat noise" image, i.e. an image where the effective weighting across the mosaic field of view is set so that the noise is constant. This is so that the clean threshold has a uniform meaning for the stopping criterion and that the image fed into the minor cycles has uniform noise levels. However, this means that the image does not take into account the primary beam fall-off in the edges and interstices of the mosaic. We could have set <tt>pbcor=True</tt> in {{clean}}, but it is useful to see the flat-noise image and residuals to evaluate the quality of the clean image. Therefore, we use {{immath}} to divide the <tt>.image</tt> by the <tt>.flux</tt> image to produce a primary beam corrected restored image:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0_IQUV.pbcorimage',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0_IQUV.image','3c391_ctm_spw0_IQUV.flux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
where<br />
* <tt>mode='evalexpr'</tt> : Use the <tt>expr</tt> parameter to describe the mathematical operation to perform.<br />
* <tt>imagename</tt> : A list of images to manipulate, in the order <tt>[IM0, IM1, ...]</tt> for purposes of <tt>expr</tt><br />
* <tt>expr</tt> : the [[http://casa.nrao.edu/aips2_docs/notes/223/index.shtml Lattice Expression Language]] (LEL) expression for the operation. In our case <tt>IM0[IM1>0.2]/IM1</tt> means to divide IM0 by IM1 gating on IM1 (and masking outside that).<br />
* <tt>outfile</tt> : the name of the output image<br />
<br />
You can open this in the viewer and see that it has indeed raised the noise (and signal) at the edges of the mosaic.<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 <tt>3c391_ctm_spw0_IQUV.image</tt>, resulting from the above clean, 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 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 />
mystat = imstat(imagename='3c391_ctm_spw0_IQUV.pbcorimage',stokes='')<br />
</source><br />
* <tt>mystat=imstat()</tt> : imstat returns a Python dictionary which we capture in the variable <tt>mystat</tt><br />
* <tt>stokes=' '</tt> : 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 dictionary contains the values which you can extract for further use, for example:<br />
<pre style="background-color: #E0FFFF;"><br />
CASA <4>: mystat<br />
Out[4]: <br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '18:50:04.251, -01.05.40.567, I, 4.59901e+09Hz',<br />
'flux': array([ 8.09906766]),<br />
'max': array([ 0.15493493]),<br />
'maxpos': array([288, 256, 0, 0], dtype=int32),<br />
'maxposf': '18:49:16.243, -00.55.00.579, I, 4.59901e+09Hz',<br />
'mean': array([ 0.00075846]),<br />
'medabsdevmed': array([ 0.00016474]),<br />
'median': array([ 9.20415550e-06]),<br />
'min': array([-0.00701752]),<br />
'minpos': array([279, 430, 0, 0], dtype=int32),<br />
'minposf': '18:49:17.743, -00.47.45.579, I, 4.59901e+09Hz',<br />
'npts': array([ 481620.]),<br />
'quartile': array([ 0.00032993]),<br />
'rms': array([ 0.00580542]),<br />
'sigma': array([ 0.00575567]),<br />
'sum': array([ 365.28803472]),<br />
'sumsq': array([ 16.23199992]),<br />
'trc': array([479, 479, 3, 0], dtype=int32),<br />
'trcf': '18:48:44.407, -00.45.43.065, V, 4.59901e+09Hz'}<br />
<br />
CASA <5>: mystat['max'][0]<br />
Out[5]: 0.15493492782115936<br />
</pre><br />
and so the peak flux density is 0.155 Jy/beam (likely in the I Stokes plane).<br />
<br />
[[Image:screenshot_3c391_viewer_polygon.png|thumb|right|viewer polygon region drawing for on-source statistics]]<br />
[[Image:screenshot_3c391_viewer_polygon_forrms.png|thumb|right|viewer polygon region for off-source statistics]]<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., <br />
<br />
<center><br />
<math>S = \int d\Omega I</math><br />
</center><br />
<br />
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 />
Open {{viewer}} and use it to display the corrected image<br />
<source lang="python"><br />
# In CASA<br />
viewer('3c391_ctm_spw0_IQUV.pbcorimage')<br />
</source><br />
One can choose the function assigned to each mouse button; after zooming into the desired view, assign 'polygon region' to a desired mouse button (e.g., left 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. You start drawing vertices by clicking on points in the image in succession, when you draw the final vertex then you double-click to connect and close the region. When you mouse is inside the region a bounding box will appear with the vertices shown as draggable solid squares. If you want to adjust the vertices you can do so!<br />
<br />
If you find you don't like your region you can dismiss it with with ESC key or using the remove region "X" button in lower right of the panel. You can also employ the region panel to save a region you have created, for later use.<br />
<br />
Double click inside of that region (using the <em>left</em> mouse button in 4.1), and the statistics will be reported. This will include the flux density value within the region selected.<br />
<pre style="background-color: #E0FFFF;"><br />
(3c391_ctm_spw0_IQUV.pbcorimage)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 35965 3.468445e+02 7.690144e+00 <br />
Mean Rms Std dev Minimum Maximum <br />
9.643947e-03 2.105594e-02 1.871781e-02 -6.193980e-03 1.549349e-01 <br />
region count <br />
1 <br />
</pre><br />
In our example we find a total Flux density of 7.7 Jy while the max brightness is only 0.155 Jy/beam. Note that the numbers you get may be slightly different depending on how deeply you cleaned.<br />
<br />
By contrast, for the rms noise level, one wants load the original (un-pbcor) image and to <em>exclude</em> the source's emission to the extent possible, as the source's emission will bias the estimated noise level high. Likewise, one should avoid the "clean bowl" around the source emission. One can repeat the procedure above, defining a polygonal region, then double clicking inside it, to determine the statistics. You can use the tapedeck to change which Stokes plane you are viewing and double-click in each to get those statistics. For example, from the region selection shown to the right for off-source statistics:<br />
<pre style="background-color: #E0FFFF;"><br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
I -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -2.183726e+00 -4.841698e-02 <br />
Mean Rms Std dev Minimum Maximum <br />
-7.675932e-05 5.514743e-04 5.461158e-04 -2.255022e-03 2.184846e-03 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
Q -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 -1.938583e-01 -4.298173e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
-6.814238e-06 5.552247e-05 5.510370e-05 -3.182797e-04 2.785026e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
U -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 4.726386e-03 1.047922e-04 <br />
Mean Rms Std dev Minimum Maximum <br />
1.661354e-07 5.337158e-05 5.337226e-05 -2.365123e-04 2.127615e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
(3c391_ctm_spw0_IQUV.image)<br />
Stokes Velocity Frame Doppler Frequency <br />
V -42.9832km/s LSRK RADIO 4.59901e+09 <br />
BrightnessUnit BeamArea Npts Sum FluxDensity <br />
Jy/beam 45.1025 28449 3.330011e-01 7.383210e-03 <br />
Mean Rms Std dev Minimum Maximum <br />
1.170520e-05 1.145072e-04 1.139094e-04 -3.921018e-04 3.341468e-04 <br />
region count <br />
1 <br />
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----<br />
</pre><br />
Thus the I rms is 0.55 mJy and Q and U rms are around 0.056 mJy. It will be useful later on to have the flat-noise and pb-corrected images available separately along with the statistics.<br />
<br />
== Constructing Polarization Intensity and Angle Images ==<br />
<br />
At the beginning of this Advanced 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 />
The relevant task is {{immath}}, with specific examples for processing of polarization images given in<br />
[http://casa.nrao.edu/docs/UserMan/UserMansu309.html 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. Use the flat-noise images so that non-uniform noise does not bias us.<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 />
We also extract a pb-corrected I image for later use:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.pbcorI',<br />
mode='evalexpr',<br />
imagename='3c391_ctm_spw0_IQUV.pbcorimage',<br />
expr='IM0',stokes='I')<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(outfile='3c391_ctm_spw0.P',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.0Jy/beam')<br />
</source><br />
Because P is formed from the sum of the squares of the Q and U values, it is biased by the noise. In principle, one can set the <tt>sigma</tt> value to debias this (it subtracts the square of this value from the Q<sup>2</sup>+U<sup>2</sup> before taking the square-root). <br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias',<br />
mode='poli',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
sigma='0.000041Jy/beam')<br />
</source><br />
Currently in CASA 4.1 and earlier, there is a bug where pixels where the noise subtraction makes it negative are set to NaN. To filter this out use {{immath}}. Also, you must give <tt>sigma</tt> in Jy/beam (not mJy/beam). We do:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.P_unbias_filtered',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias'],<br />
expr="IM0[IM0>-10000.0]")<br />
</source> <br />
Finally, one can pb-correct this (after first extracting one plane of the <tt>.flux</tt> image, they are all the same):<br />
<source lang="python"><br />
# In CASA<br />
immath(imagename='3c391_ctm_spw0_IQUV.flux',<br />
outfile='3c391_ctm_spw0.Qflux',<br />
expr='IM0',stokes='Q')<br />
#<br />
immath(outfile='3c391_ctm_spw0.pbcorP',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.P_unbias_filtered','3c391_ctm_spw0.Qflux'],<br />
expr="IM0[IM1>0.2]/IM1")<br />
</source><br />
<br />
[[Image:screenshot_3c391_viewer_menu_raster.png|200px|thumb|right|data display options for P raster]]<br />
[[Image:screenshot_3c391_viewer_menu_contour.png|200px|thumb|right|data display options for total intensity contours]]<br />
[[Image:screenshot_3c391_viewer_menu_vector.png|200px|thumb|right|data display options for position angle vectors]]<br />
[[Image:screenshot_3c391_viewer_allpol.png|200px|thumb|right|final full-polarization image of 3C391]]<br />
<br />
3. 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. Also, we use the flat-noise images as only the ratio matters and for thresholding you want a uniform noise:<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.X',<br />
mode='pola',<br />
imagename=['3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
polithresh='0.2mJy/beam')<br />
</source><br />
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 around 0.2 mJy/beam.<br />
<br />
4. If desired, form the fractional linear polarization image, defined as P/I. We can do this on the flat-noise image.<br />
<source lang="python"><br />
# In CASA<br />
immath(outfile='3c391_ctm_spw0.F',<br />
mode='evalexpr',<br />
imagename=['3c391_ctm_spw0.I','3c391_ctm_spw0.Q','3c391_ctm_spw0.U'],<br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-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 I noise level. The computation of the polarized intensity is specified by <br />
<pre style="background-color: #E0FFFF;"><br />
expr='sqrt((IM1^2+IM2^2)/IM0[IM0>1.2e-3]^2)'<br />
</pre><br />
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.pbcorP')<br />
</source><br />
* Next, load the pb-corrected 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.pbcorI) 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 pbcorP image), we would paste the expression <br />
<pre style="background-color: #E0FFFF;"><br />
'3c391_ctm_spw0.X'['3c391_ctm_spw0.pbcorP'>0.0004]<br />
</pre><br />
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 />
While we now have all three images loaded into the viewer (the polarized intensity (3c391_ctm_spw0.pbcorP) in color, the total intensity (3c391_ctm_spw0.pbcorI) 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 />
* Click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. <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. You can change the colormap (e.g. to HotMetal1) in the first tab of the Data Display Options GUI.<br />
* Change the contour levels. Select the total intensity tab (3c391_ctm_spw0.pbcorI) tab (2nd) in the Data Display Options GUI. 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.004 Jy (<math>5\sigma</math> of pbcorI rms in the outer part of the mosaic). Choose a nice contour color (e.g. "magenta").<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 (4 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'' (green 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 />
<b>CASA 4.0 Note:</b> It would be desirable to produce the spectral index image through the first-order Taylor term expansion in the MFS imaging. This is unfortunately not available with mosaics in the current version of CASA. Stay tuned.<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/UserManse32.html 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]]. From this we will make an I-only multiscale image (3c391_ctm_spw0_I.image) and in particular the model (3c391_ctm_spw0_I.model) to generate a series of gain corrections (stored in 3C391_ctm_mosaic_spw0.selfcal1), 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_selfcal1.image). Note that in the clean before the self-cal, it is important that we only image I so that any cleaned polarization does not affect the gaincal. Note that in CASA 4.0 we first use <tt>delmod</tt> on the MS to get rid of the previous polarized model.<br />
<source lang="python"><br />
#In CASA<br />
delmod('3c391_ctm_mosaic_spw0.ms')<br />
#<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_ms_I',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clark',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='I',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
You don't (or even shouldn't) have to clean extremely deep. You want to be sure to capture as much of the source total flux density as possible, but not include low-level questionable features or sub-structure (ripples) that might be due to calibration or clean artifacts. <br />
<br />
After you are happy with the image:<br />
<source lang="python"><br />
#In CASA<br />
gaincal(vis='3c391_ctm_mosaic_spw0.ms',caltable='3c391_ctm_mosaic_spw0.selfcal1',<br />
field='',spw='',selectdata=False,<br />
solint='30s',refant='ea21',minblperant=4,minsnr=3,<br />
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.selfcal1'],gainfield=[''],interp=['nearest'],<br />
calwt=F)<br />
</source><br />
The <tt>CORRECTED_DATA</tt> column of the MS now contains the self-calibrated visibilities, when will now be used by clean.<br />
<br />
If you planned on doing multiple iterations of self-cal, you would do another I-only image (e.g. <tt>3c391_ctm_spw0_ms_I_selfcal1</tt>) as that is what is needed for the next step. If you want to just go ahead and see what this selfcal has done, make a full IQUV cube:<br />
<source lang="python"><br />
#In CASA<br />
clean(vis='3c391_ctm_mosaic_spw0.ms',imagename='3c391_ctm_spw0_IQUV_selfcal1',<br />
field='',spw='',<br />
mode='mfs',<br />
niter=25000,<br />
gain=0.1,threshold='1mJy',<br />
psfmode='clarkstokes',<br />
imagermode='mosaic',ftmachine='mosaic',<br />
multiscale=[0, 6, 18, 54],smallscalebias=0.9,<br />
interactive=True,<br />
imsize=[480,480],cell=['2.5arcsec','2.5arcsec'],<br />
stokes='IQUV',<br />
weighting='briggs',robust=0.5,<br />
usescratch=False)<br />
</source><br />
<br />
{| style="background:#98FB98"<br />
|-<br />
| <b>Questions for the Advanced Student:</b><br />
* Is this better than the original IQUV image cube? By how much?<br />
* Can you make a difference image (between the original and selfcal1 images) using {{immath}}?<br />
* How big were the phase changes made by the calibration? Were there specific antennas with larger errors?<br />
|-<br />
|}<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 <tt>'selfcal1'</tt> is attached to various files to help keep straight which is what. Successive iterations of self-cal could then be <tt>'selfcal2'</tt>, <tt>'selfcal3'</tt>, 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 (if it can), 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 />
* The task applycal will flag data with no good calibration solutions. During the initial self-calibration steps, this flagging may be excessive. If so, one can restore the flags to the state right before running applycal by using the task flagmanager.<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-CASA4.1.0]] tutorial, then having reduced the continuum data in the [[EVLA Continuum Tutorial 3C391-CASA4.1]], 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].<br />
<br />
{{Checked 4.2.0}}</div>Smyers