https://casaguides.nrao.edu/api.php?action=feedcontributions&user=Dkim&feedformat=atomCASA Guides - User contributions [en]2024-03-28T08:54:15ZUser contributionsMediaWiki 1.38.6https://casaguides.nrao.edu/index.php?title=File:South_interact2_CASA5.7.png&diff=29502File:South interact2 CASA5.7.png2020-10-06T12:54:29Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29501AntennaeBand7 Imaging 5.72020-10-06T12:52:40Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare_CASA5.7.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Southern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare_CASA5.7.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord_CASA5.7.png&diff=29500File:Antennae South.CO3 2Line.Clean.pcal1.image.mom.weighted dispersion coord CASA5.7.png2020-10-05T21:32:34Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord_CASA5.7.png&diff=29499File:Antennae South.CO3 2Line.Clean.pcal1.image.mom.weighted coord CASA5.7.png2020-10-05T21:31:53Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0_CASA5.7.png&diff=29498File:Antennae South.CO3 2Line.Clean.pcal1.image.mom0 CASA5.7.png2020-10-05T21:30:06Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord_CASA5.7.png&diff=29497File:Antennae North.CO3 2Line.Clean.pcal1.image.mom.weighted dispersion coord CASA5.7.png2020-10-05T21:28:17Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord_CASA5.7.png&diff=29496File:Antennae North.CO3 2Line.Clean.pcal1.image.mom.weighted coord CASA5.7.png2020-10-05T21:26:23Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0_CASA5.7.png&diff=29495File:Antennae North.CO3 2Line.Clean.pcal1.image.mom0 CASA5.7.png2020-10-05T21:24:22Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29494AntennaeBand7 Imaging 5.72020-10-05T21:17:30Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare_CASA5.7.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Southern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare_CASA5.7.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord_CASA5.7.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:North_ch43compare_CASA5.7.png&diff=29471File:North ch43compare CASA5.7.png2020-10-05T16:22:15Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29470AntennaeBand7 Imaging 5.72020-10-05T16:21:46Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare_CASA5.7.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Southern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare_CASA5.7.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:South_ch31compare_CASA5.7.png&diff=29469File:South ch31compare CASA5.7.png2020-10-05T16:18:15Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29468AntennaeBand7 Imaging 5.72020-10-05T16:17:20Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Southern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare_CASA5.7.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29467AntennaeBand7 Imaging 5.72020-10-05T16:16:08Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Southern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_6.1&diff=29466AntennaeBand7 Imaging 6.12020-10-05T16:15:31Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 6.1 and uses Python 3. The same functionality is implemented in Python 2 using CASA 5.7 at [[AntennaeBand7 Imaging 5.7]]'''<br />
* '''This guide is designed for CASA 6.1. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 6.1]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 6.1. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casalith<br />
version = casalith.version_string()<br />
print ("You are using {}".format(version))<br />
if (version < '6.1'):<br />
print ("YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE.")<br />
print ("PLEASE UPDATE IT BEFORE PROCEEDING.")<br />
else:<br />
print ("Your version of CASA is appropriate for this guide.")<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_6.1.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_6.1.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_6.1.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations; the clean mask is shown by the white contour.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_6.1.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations; the clean mask is shown by the white contour.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_6.1.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_6.1.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.4, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_6.1.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_6.1.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_6.1.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_6.1.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_6.1.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan_6.1.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase_6.1.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Southern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0_6.1.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord_6.1.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord_6.1.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0_6.1.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord_6.1.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord_6.1.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
<div style="background-color: #CCFF99;"><br />
<p>Last checked on CASA Version 6.1.0.<br />
</p><br />
</div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:South_selfchan_CASA5.7.png&diff=29461File:South selfchan CASA5.7.png2020-10-03T01:05:42Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29460AntennaeBand7 Imaging 5.72020-10-03T01:03:20Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Northern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:South_pcal1_phase_CASA5.7.png&diff=29459File:South pcal1 phase CASA5.7.png2020-10-03T01:01:39Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29458AntennaeBand7 Imaging 5.72020-10-03T01:00:15Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Northern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29457AntennaeBand7 Imaging 5.72020-10-03T00:58:22Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Northern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:North_interact2_CASA5.7.png&diff=29456File:North interact2 CASA5.7.png2020-10-02T21:37:21Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29455AntennaeBand7 Imaging 5.72020-10-02T21:32:39Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Northern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:North_pcal1_phase_CASA5.7.png&diff=29454File:North pcal1 phase CASA5.7.png2020-10-02T20:53:01Z<p>Dkim: Dkim uploaded a new version of File:North pcal1 phase CASA5.7.png</p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:North_pcal1_phase_CASA5.7.png&diff=29453File:North pcal1 phase CASA5.7.png2020-10-02T20:48:44Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29452AntennaeBand7 Imaging 5.72020-10-02T20:47:44Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase_CASA5.7.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Northern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:North_selfchan_CASA5.7.png&diff=29451File:North selfchan CASA5.7.png2020-10-02T20:43:20Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29450AntennaeBand7 Imaging 5.72020-10-02T20:42:24Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan_CASA5.7.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Northern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:South_interact_CASA5.7.png&diff=29449File:South interact CASA5.7.png2020-10-02T20:40:31Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:North_interact_CASA5.7.png&diff=29448File:North interact CASA5.7.png2020-10-02T20:40:04Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29447AntennaeBand7 Imaging 5.72020-10-02T20:36:10Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact_CASA5.7.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Northern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:South_CO3_2_vel_CASA5.7.png&diff=29446File:South CO3 2 vel CASA5.7.png2020-10-02T19:21:32Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:North_CO3_2_vel_CASA5.7.png&diff=29445File:North CO3 2 vel CASA5.7.png2020-10-02T19:20:41Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29444AntennaeBand7 Imaging 5.72020-10-02T19:19:53Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel_CASA5.7.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel_CASA5.7.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Northern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:South_cont_clean_CASA5.7.png&diff=29443File:South cont clean CASA5.7.png2020-10-02T19:02:57Z<p>Dkim: Dkim uploaded a new version of File:South cont clean CASA5.7.png</p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:North_cont_clean_CASA5.7.png&diff=29442File:North cont clean CASA5.7.png2020-10-02T19:02:11Z<p>Dkim: Dkim uploaded a new version of File:North cont clean CASA5.7.png</p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Antennae_North-AMPvsCH_CASA5.7.png&diff=29441File:Antennae North-AMPvsCH CASA5.7.png2020-10-02T18:42:02Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Antennae_South-AMPvsCH_CASA5.7.png&diff=29440File:Antennae South-AMPvsCH CASA5.7.png2020-10-02T18:41:09Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7&diff=29439AntennaeBand7 Imaging 5.72020-10-02T18:32:44Z<p>Dkim: </p>
<hr />
<div>*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Imaging 6.1]]'''<br />
* '''This guide is designed for CASA 5.7. If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.<br />
* '''This tutorial picks up where [[AntennaeBand7_Calibration 5.7]] leaves off: with fully calibrated, split science target measurement sets. If you wish to skip the Calibration guide: obtain the calibrated data from [[AntennaeBand7#Obtaining_the_Data]]; extract it using <tt>tar -xzvf FILENAME</tt>; and <tt>cd</tt> into the extracted directory.'''<br />
* '''Details of the ALMA data are provided at [[AntennaeBand7]]'''.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Imaging Mosaics ==<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the basic concepts of deconvolution and clean, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/wilner_vla16.pdf<br />
</pre><br />
<br />
Mosaics like other kinds of images are created in the CASA task {{tclean}}. To invoke mosaic mode, you simply set the parameter '''gridder='mosaic''''. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created: the primary beam response function. The corresponding image of the mosaic response function will be called ''<imagename>.pb''.<br />
<br />
<!-- <br />
Well-sampled mosaics like the patterns observed for the Northern and Southern Antennae mosaics shown on the [[AntennaeBand7#ALMA_Data_Overview | Overview]] page are well-suited to joint deconvolution. However, if you have a poorly-sampled, or very irregular mosaic you may need to use the slower '''ftmachine='ft'''' which combines data in the image plane, similar to what is done in other packages like ''MIRIAD''.<br />
--><br />
<br />
Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the '''phasecenter''' parameter. Otherwise it will default to the first pointing included in the '''field''' parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field id 12. Note that during the final '''split''' in the calibration section that selected only the Antennae fields, the field ids were renumbered, so that the original centers (shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]]) have changed: field id 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the {{tclean}} help for syntax).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
If you want to learn more about mosaicing, pause here and <br />
review, for example, https://science.nrao.edu/science/meetings/2016/15th-synthesis-imaging-workshop/documents/bsmMosaicking2016.pdf<br />
</pre><br />
<br />
== Continuum Imaging ==<br />
<figure id="Antennae_South-AMPvsCH.png"><br />
[[File:Antennae_South-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]<br />
</figure><br />
<figure id="Antennae_North-AMPvsCH.png"><br />
[[File:Antennae_North-AMPvsCH_CASA5.7.png|200px|thumb|right|<caption>Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]<br />
</figure><br />
<br />
We will make 345 GHz continuum images for the two regions covered by the mosaics. We use the task {{clean}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (<xr id="Antennae_South-AMPvsCH.png"/>), and from 70 to 100 in the northern mosaic (<xr id="Antennae_North-AMPvsCH.png"/>). <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North-AMPvsCH.png')<br />
plotms(vis='Antennae_North.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_North-AMPvsCH.png', showgui = True)<br />
</source><br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South-AMPvsCH.png')<br />
plotms(vis='Antennae_South.cal.ms',xaxis='channel',yaxis='amp',<br />
avgtime='1e8',avgscan=True,plotfile='Antennae_South-AMPvsCH.png', showgui = True)<br />
</source><br />
<br />
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.<br />
<br />
Next we create continuum images from the line-free channels. <br />
<br />
==== Northern Continuum Mosaic ====<br />
<br />
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''. <br />
<br />
Other essential {{tclean}} parameters for this case include:<br />
*'''vis='Antennae_North.cal.ms' ''': The calibrated dataset on the science target. {{tclean}} will always use the CORRECTED DATA column (if it exists).<br />
*'''imagename='Antennae_North.Cont.Dirty' ''': The base name of the output images:<br />
** <imagename>.image # the final restored image<br />
** <imagename>.pb # the primary beam response<br />
** <imagename>.image.pbcor # the primary beam-corrected image (if '''pbcor=True''')<br />
** <imagename>.weight # the primary beam coverage ('''gridder=’mosaic’ or 'awproject' ''' only)<br />
** <imagename>.model # the model image<br />
** <imagename>.residual # the residual image<br />
** <imagename>.psf # the synthesized (dirty) beam<br />
*'''spw='0:1~50;120~164' ''': To specify only the line-free channels of spectral window 0.<br />
*'''specmode='mfs' ''': Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging. <br />
*'''restfreq='345.79599GHz' ''': The rest frequency of CO(3-2) can be found with [http://www.splatalogue.online/ splatalogue].<br />
*'''niter=0''': Maximum number of tclean iterations. ('''niter=0 will do no cleaning''')<br />
<br />
In CASA 5.4 and later, {{tclean}} calls with '''gridder''' = ''''mosaic'''' have an additional parameter '''mosweight''' with a default of '''True'''. When '''mosweight''' = '''True''', the gridder weights each field in the mosaic independently. The '''mosweight''' parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting. For more information on '''mosweight''', please see the {{tclean}} documentation. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.Cont.Dirty*')<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Dirty',<br />
field='',phasecenter=12,<br />
specmode='mfs',<br />
deconvolver='hogbom',<br />
restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=300,cell='0.2arcsec',<br />
interactive=False,niter=0)<br />
</source><br />
<br />
The reported beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. <br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Dirty.image')<br />
</source><br />
<br />
<!-- COMMENT OUT VIEWER VIDEO. UNCOMMENT WHEN A MORE UP-TO-DATE VIDEO IS AVAILABLE.<br />
<pre style="background-color: #E0FFFF;"><br />
If you are unfamiliar with the CASA viewer it is a good idea to pause here and watch the demo at <br />
http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html<br />
</pre> --><br />
<br />
<figure id="North_cont_clean.png"><br />
[[Image:North_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Northern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
Yes, there is definitely a detection in the vicinity of the Northern nucleus (see <xr id="North_contstat.png"/> and <xr id="Antennae_North.Cont.Clean.image.png"/> below). Using the square region icon, and drawing a box near but not including the emission, we find the rms noise is about 0.5 mJy/beam in the dirty image.<br />
<br />
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum | TWHya casaguide]] for a more complete description of interactive clean and mask creation. <br />
<br />
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''<br />
*'''threshold='0.4mJy' ''': Stop cleaning if the maximum residual is below this value (the dirty rms noise)<br />
*'''interactive=True''': Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms',imagename='Antennae_North.Cont.Clean',<br />
field='',phasecenter=12,<br />
deconvolver='hogbom',<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~50;120~164',<br />
gridder='mosaic', mosweight=True,<br />
imsize=500,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The residuals are "noise-like" after only ~30 iterations (see <xr id="North_cont_clean.png"/>), so hit the red X symbol in the interactive window to stop cleaning here. <br />
<br />
Note that if you run the {{tclean}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean}} command to guard against this, but sometimes this is what you want.<br />
<br />
==== Southern Continuum Mosaic ====<br />
<br />
<figure id="South_cont_clean.png"><br />
[[Image:South_cont_clean_CASA5.7.png|200px|thumb|right|<caption>Residual for Southern continuum mosaic after 100 iterations.</caption>]]<br />
</figure><br />
<br />
For the southern mosaic we modify the '''phasecenter''', mosaic '''imsize''', and the line-free channels ('''spw''') to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the [[AntennaeBand7#ALMA_Data_Overview | Overview]]. We expect the beam to be about the same and use the same '''cell''' size. Again, you can use the provided mask or make your own.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.Cont.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms',imagename='Antennae_South.Cont.Clean',<br />
field='',phasecenter=15,<br />
specmode='mfs',restfreq='345.79599GHz',<br />
spw='0:1~30;120~164',<br />
gridder='mosaic', mosweight=True, deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',<br />
interactive=True, <br />
niter=1000, threshold='0.4mJy')<br />
</source><br />
<br />
The beam size reported in the logger for the Southern mosaic: 1.13"x 0.67", and P.A.= 61 deg; which is a little better than the beam for the North owing to better uv-coverage.<br />
<br />
Stop after ~50 iterations (<xr id="South_cont_clean.png"/>).<br />
<br />
==== Image Statistics ====<br />
<br />
<figure id="North_contstat.png"><br />
[[File:North_contstat.png|200px|thumb|right|<caption>Example polygon for rms determination using the viewer.</caption>]]<br />
</figure><br />
<br />
<br />
You can determine statistics for the images using the task {{imstat}}:<br />
<source lang="python"><br />
# In CASA<br />
imstat('Antennae_North.Cont.Clean.image')<br />
imstat('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
From this we find, that for the Northern continuum image the peak is 3.86 mJy/beam and the rms is 0.49 mJy/beam. For the Southern continuum we find a peak of 4.70 mJy/beam and an rms of 0.47 mJy/beam. <br />
<br />
However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. <br />
<br />
It is often easier to use either the {{viewer}} directly or {{imview}} (a task wrapper for the {{viewer}}; see '''help imview''' for more info) to display the image and then interactively use the region tools to get the statistics.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.Cont.Clean.image')<br />
</source><br />
<br />
Adjust colorscale using the middle mouse button (or reassign to a different mouse button by clicking on "plus" symbol icon). Next, select the polygon tool by clicking on its symbol with a mouse button. Then draw a region that avoids edges and emission (see <xr id="North_contstat.png"/>), then double click inside the polygon to have the statistic printed to the screen. You may measure an rms that differs by a few percent from the value reported by imstat.<br />
<br />
<source lang="python">exit<br />
# In CASA<br />
viewer('Antennae_South.Cont.Clean.image')<br />
</source><br />
<br />
<figure id="Antennae_North.Cont.Clean.image.png"><br />
[[File:Antennae_North.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.Cont.Clean.image.png"><br />
[[File:Antennae_South.Cont.Clean.image_CASA5.7.png|200px|thumb|right|<caption>345 GHz continuum image of the southern mosaic.</caption>]]<br />
</figure><br />
<br />
Again, you may measure an rms slightly different than what we got from using {{imstat}} with no constraints. <br />
<br />
How does this compare to theory? You can find out using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator]. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation. <br />
<br />
Next make hardcopy plots of the continuum images using {{imview}}. To make the contrast a bit better, set the data range from -1 x sigma to the peak determined above.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00049,0.00386]},<br />
zoom=1, out='Antennae_North.Cont.Clean.image.png')<br />
imview(raster={'file': 'Antennae_South.Cont.Clean.image',<br />
'colorwedge':True,'range':[-0.00047,0.00470]},<br />
zoom=1, out='Antennae_South.Cont.Clean.image.png')<br />
</source><br />
<br />
==Continuum subtraction ==<br />
<br />
In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task {{uvcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
uvcontsub(vis='Antennae_North.cal.ms',fitspw='0:1~50;120~164',fitorder = 1)<br />
# In CASA<br />
uvcontsub(vis='Antennae_South.cal.ms',fitspw='0:1~30;120~164',fitorder = 1)<br />
</source><br />
<br />
Here, '''fitspw''' gives the line-free channels for each mosaic and '''fitorder=1'''. Higher order fits are not recommended. If you do not have line-free channels on both sides of the line '''fitorder=0''' is recommended. The output MS will have ''.contsub'' appended to the name.<br />
<br />
In CASA 5.7, you will see a warning that uvcontsub is using the original Visibility Iterator, which is the underlying iteration and retrieval mechanism used when processing visibility data. <br />
A new version of the Visibility Iterator has been developed and deployed in several other calibration tasks in CASA 5.0 and later (see [https://science.nrao.edu/enews/casa_005/ CASA eNews] for more information). <br />
We can ignore this warning. <br />
<br />
<pre style="background-color: #fffacd;"><br />
WARN calibrater Forcing use of OLD VisibilityIterator.<br />
</pre><br />
<br />
== CO(3-2) Imaging ==<br />
<br />
<figure id="North_CO3_2_vel.png"><br />
[[Image:North_CO3_2_vel.png|thumb|<caption>Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<figure id="South_CO3_2_vel.png"><br />
[[Image:South_CO3_2_vel.png|thumb|<caption>Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]<br />
</figure><br />
<br />
Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for <br />
those dealing with the spectral setup: '''specmode''', '''start''', '''width''', '''nchan''', '''restfreq''', and '''outframe''' parameters. <br />
When making spectral images you have three choices for the '''specmode''' parameter: '''mfs''', '''cube''', and '''cubedata'''. <br />
As noted above, setting '''specmode='mfs'''' gives an output image with only one channel, and is used for continuum imaging. The other '''specmode''' options create output data cubes with one or more channels.<br />
<br />
Data are taken using constant frequency channels. <br />
For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. <br />
For '''specmode='cube'''', the desired '''start''' and '''width''' also need to be given in velocity units for the desired output frame. <br />
<br />
It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify '''outframe''' the output cube will also be in TOPO, which is not very useful for scientific analysis. <br />
The Doppler Shift is taken out during the regridding to the desired outframe in {{tclean}} or alternatively it can be done separately by the {{cvel}} task which would need to be run before {{tclean}}. <br />
<br />
To see what velocity parameters you want to set in {{tclean}}, it is useful to make a plot in {{plotms}} in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf North_CO3_2_vel.png')<br />
plotms(vis='Antennae_North.cal.ms.contsub/',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='North_CO3_2_vel.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf South_CO3_2_vel.png')<br />
plotms(vis='Antennae_South.cal.ms.contsub',xaxis='velocity',yaxis='amp',<br />
avgtime='1e8',avgscan=True,transform=True,freqframe='LSRK',<br />
restfreq='345.79599GHz',plotfile='South_CO3_2_vel.png', showgui = True) <br />
</source><br />
<br />
==== Northern Mosaic ====<br />
<br />
As before, it is very important that you make a clean mask. There are many ways to do this ranging from the complicated to simple. For this example we provide a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. You can choose to use and edit the provided mask or create your own mask.<br />
<br />
Notable parameters included in the {{tclean}} call are:<br />
*'''specmode='cube' ''','''outframe='LSRK' ''','''restfreq='345.79599GHz' '''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.<br />
*'''nchan=60''','''start='1300km/s' ''','''width='10km/s' ''': To produce a data cube with 60 channels ("nchan"=60), starting at 1300km/s and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.<br />
*'''imsize=500''','''cell='0.13arcsec' ''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic. <br />
*'''weighting='briggs' ''','''robust=0.5''': Weighting to apply to visibilities. We use Briggs' weighting and robustness parameter 0.5 (in between natural and uniform weighting).<br />
*'''niter=20000''': Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive {{tclean}} window. <br />
*'''threshold='5.0mJy' ''': Stop cleaning if the maximum residual is below this value. <br />
The threshold is set to roughly the rms of a single line-free channel for each dataset. <br />
*'''savemodel='modelcolumn'''': This saves the clean model to the ms file. We will need this for self-calibration later. <br />
<br />
<figure id="North_interact.png"><br />
[[Image:North_interact.png|200px|thumb|right|<caption>Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_North.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic', mosweight=True,<br />
deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
<xr id="North_interact.png"/> shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure the check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "erase button" can help you fix mistakes. If necessary adjust. It is often useful to adjust the colorscale with the "plus" symbol icon. To make it go a bit faster, you can increase '''iteration''' interactively, to 200 or 300, but don't overdo it.<br />
<br />
These data are pretty severely ''dynamic range'' limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based '''threshold''' because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of '''iterations''' is given to help you decide when to quit. NOTE: the '''threshold''' that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this '''threshold'''.<br />
<br />
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact. <br />
<br />
Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level. <br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_North.CO3_2Line.Clean.image')<br />
</source><br />
<br />
==== Southern Mosaic ====<br />
<figure id="South_interact.png"><br />
[[Image:South_interact.png|200px|thumb|right|<caption>Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
Repeat process for Southern mosaic.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:<br />
rmtables('Antennae_South.CO3_2Line.Clean'+ext)<br />
<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
Clean about 8,000 iterations before stopping.<br />
<br />
Inspect the resulting data cube:<br />
<source lang="python"><br />
# In CASA<br />
viewer('Antennae_South.CO3_2Line.Clean.image')<br />
</source><br />
<br />
For each mosaic use the '''viewer''' polygon tool as described above for the continuum, to find the image statistics in both a line-free channel and the channel with the strongest emission. <br />
<br />
The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively.<br />
However in a bright channel this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit. <br />
<br />
Using the [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator], a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5 for an expected rms noise of about 3.6 mJy. So in line-free channels we are doing close to theoretical.<br />
<br />
== Self Calibration == <br />
<br />
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if ''savemodel'' = ''modelcolumn''. This model can be used to self-calibrate the data using {{gaincal}}. That is why it is important to make the model as good as you can by making clean masks. <br />
<br />
Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval ('''solint'''). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset. <br />
<br />
Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission. <br />
<br />
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.<br />
<br />
==== Northern Mosaic ====<br />
<br />
<figure id="north_selfchan_data.png"><br />
[[Image:north_selfchan.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column of field 12 of the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12' '''. Below we make a uv-plot of the spectral line emission from this field to chose only the strongest channels to include in the self-calibration. ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.'' This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='data',plotfile='North_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic. <br />
<br />
You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel = 'modelcolumn'''' in the {{tclean}} call, the default model was replaced ''only where {{tclean}} had a model to replace it with'', namely, over the channels we imaged. In future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels. <br />
<br />
<figure id="North_selfchan_model.png"><br />
[[Image:North_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column of field 12 of the northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',field='12',<br />
avgtime='1e8',avgscan=True,ydatacolumn='model',plotfile='North_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
Next remind ourselves of the timing of the various observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_North.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='12',<br />
avgchannel='167',coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.<br />
<br />
<figure id="north_pcal1_phase.png"><br />
[[Image:north_pcal1_phase.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Northern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_North.cal.ms.contsub',caltable='north_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='12',<br />
refant='DV09',spw='0:82~89',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
Plot the calibration solutions. Note that when '''iteraxis''' is set, {{plotms}} appends the axes being iterated over to the output filename specified in '''plotfile'''; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='north_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='north_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
Apply the solutions to all fields and channels with {{applycal}}, which will overwrite the corrected data column:<br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_North.cal.ms.contsub',field='',<br />
gaintable=['north_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
Re-image the data with the selfcal applied. Remember that {{tclean}} always uses the corrected data column if it exists:<br />
<br />
<figure id="North_interact2.png"><br />
[[Image:North_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_North.cal.ms.contsub',<br />
imagename='Antennae_North.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=12,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=500,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_North.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=20000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.<br />
<br />
Compare the un-selfcal'ed and selfcal'ed data to determine if there has been improvement.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_North.CO3_2Line.Clean.image',<br />
'range': [-0.07,0.4]},<br />
{'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.07,0.4]}])<br />
<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 43}) doesn't work with two images<br />
--><br />
<br />
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images". Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator. <br />
To make the figure shown in <xr id="north_ch43compare.png"/>, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.<br />
<br />
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel. <br />
<br />
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms. <br />
<br />
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement. <br />
<br />
<figure id="north_ch43compare.png"><br />
[[Image:north_ch43compare.png|600px|thumb|center|<caption>Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).<br />
</div><br />
<br />
==== Southern Mosaic ====<br />
<br />
<figure id="south_selfchan.png"><br />
[[Image:south_selfchan.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the data column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="South_selfchan_model.png"><br />
[[Image:South_selfchan_model.png|200px|thumb|right|<caption>Plot of the CO(3-2) emission from the model column for Field 7 of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'. <br />
<br />
From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour. <br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='data',<br />
plotfile='South_selfchan_data.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='channel',yaxis='amp',<br />
field='7',avgtime='1e8',avgscan=True,ydatacolumn='model',<br />
plotfile='South_selfchan_model.png', showgui = True)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='Antennae_South.cal.ms.contsub',spw='',xaxis='time',yaxis='amp',field='7',<br />
avgchannel='167',avgscan=True,coloraxis='scan',ydatacolumn='data', showgui = True)<br />
</source><br />
<br />
<figure id="south_pcal1_phase.png"><br />
[[Image:south_pcal1_phase.png|200px|thumb|right|<caption>Phase-only self-calibration solutions for the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
gaincal(vis='Antennae_South.cal.ms.contsub',caltable='south_self_1.pcal',<br />
solint='3600s',combine='scan',gaintype='T',field='7',<br />
refant='DV09',spw='0:70~85',minblperant=4,<br />
calmode='p',minsnr=2)<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis='south_self_1.pcal',xaxis='time',yaxis='phase',<br />
spw='',field='',antenna='',<br />
iteraxis='antenna',gridrows=5,gridcols=3,plotrange=[0,0,-80,80],<br />
plotfile='south_pcal1_phase.png', showgui = True)<br />
<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
applycal(vis='Antennae_South.cal.ms.contsub',field='',<br />
gaintable=['south_self_1.pcal'],calwt=False)<br />
</source><br />
<br />
<figure id="South_interact2.png"><br />
[[Image:South_interact2.png|200px|thumb|right|<caption>Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')<br />
tclean(vis='Antennae_South.cal.ms.contsub',<br />
imagename='Antennae_South.CO3_2Line.Clean.pcal1',<br />
spw='0',field='',phasecenter=15,<br />
specmode='cube',outframe='LSRK',restfreq='345.79599GHz',<br />
nchan=70,start='1200km/s',width='10km/s',<br />
gridder='mosaic',mosweight=True,deconvolver='hogbom',<br />
imsize=750,cell='0.13arcsec',pblimit=0.2,<br />
restoringbeam='common',<br />
interactive=True,mask='Antennae_South.CO3_2Line.Clean.mask',<br />
weighting='briggs',robust=0.5,<br />
niter=40000, threshold='5.0mJy',<br />
savemodel='modelcolumn')<br />
</source><br />
<br />
After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.<br />
<br />
As for the Northern mosaic, you can compare the before and after self-cal images (look, for example, at channel 31):<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster=[{'file': 'Antennae_South.CO3_2Line.Clean.image',<br />
'range': [-0.05,0.2]},<br />
{'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.05,0.2]}])<br />
</source><br />
<br />
<!--<br />
zoom={'channel': 31})<br />
doesn't work for multiple images<br />
--><br />
<br />
<figure id="South_ch31compare.png"><br />
[[Image:South_ch31compare.png|600px|thumb|center|<caption>Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]<br />
</figure><br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).<br />
</div><br />
<br />
== Image Analysis ==<br />
<br />
==== Moment Maps ====<br />
<br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png|200px|thumb|right|<caption>The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]<br />
</figure><br />
<figure id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"><br />
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png|200px|thumb|right|<caption>The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]<br />
</figure><br />
<br />
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion. <br />
<br />
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.004],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 33~63.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'range': [-0.04,0.4]},<br />
contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
'levels': [0.0035],'unit': 5})<br />
</source><br />
<br />
We find a channel range for significant emission of 12~64.<br />
<br />
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.<br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[0],chans='33~63',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
moments=[0], chans='12~64', <br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')<br />
</source><br />
<br />
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments}} appends the appropriate file name suffix to the value of '''outfile'''. <br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='33~63', <br />
mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',<br />
outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', <br />
moments=[1,2], chans='12~64',<br />
mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',<br />
outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')<br />
</source><br />
<br />
Next we can create the six moment maps<br />
(<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png"/>,<br />
<xr id="Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png"/>)<br />
from these images using '''imview'''.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
'colorwedge':True,'scaling': -0.5},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')<br />
<br />
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')<br />
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
'colorwedge':True},<br />
zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png') <br />
</source><br />
<br />
==== Exporting Images to Fits ====<br />
<br />
If you want to analyze the data using another software package it is easy to convert from CASA format to FITS. <br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_North.Cont.Clean.image',<br />
fitsimage='Antennae_North.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
exportfits(imagename='Antennae_South.Cont.Clean.image',<br />
fitsimage='Antennae_South.Cont.Clean.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')<br />
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',<br />
fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')<br />
</source><br />
<br />
Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting '''velocity=True''' and/or '''dropstokes=True'''.<br />
<br />
==Comparison with previous SMA CO(3-2) data==<br />
<br />
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). <xr id="alma_sma_compare.png"/> shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.<br />
<br />
<figure id="alma_sma_compare.png"><br />
[[Image: alma_sma_compare.png|500px|thumb|center|<caption>The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).</caption>]]<br />
</figure><br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Uid_A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1.CASA5.7.png&diff=29432File:Uid A002 X1ff7b0 X1c8.bandpass.DV02.spw0.t1.CASA5.7.png2020-10-02T16:03:50Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Calibration_5.7&diff=29431AntennaeBand7 Calibration 5.72020-10-02T16:02:56Z<p>Dkim: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide is written for CASA 5.7 and uses Python 2. The same functionality is implemented in Python 3 using CASA 6.1 at [[AntennaeBand7 Calibration 6.1]]'''<br />
<br />
*'''This guide requires CASA 5.7.0 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are provided at [[AntennaeBand7]]<br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see: [[AntennaeBand7_Imaging 5.7]]'''.<br />
<br />
==Overview==<br />
<br />
This part of the Antennae Band 7 CASA guide will step through the calibration of the visibility data. We will begin by flagging (marking as bad) data known to be useless before any inspection; for example, data where one telescope blocks the line of sight of another. We will then apply telescope-generated calibration tables to partially correct for atmospheric effects. After inspecting the data, we will flag some additional data that exhibit pathologies. Using observations of the calibrators Titan and 3c279, it will be shown how to derive the phase and amplitude response of individual antennas as a function of time and frequency ("phase", "amplitude", and "bandpass" calibrations). We will apply these solutions to the data and then extract the calibrated source data into a file appropriate for imaging in the [[AntennaeBand7_Imaging | Antennae Band 7 imaging guide]].<br />
<br />
The general procedure in this guide follows the other ALMA CASA guides: [[NGC3256Band3]] and [[TWHydraBand7]].<br />
<br />
==Unpack the Data==<br />
<br />
This guide requires CASA 5.7.0 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]. <br />
<br />
Once you have downloaded the data, unpack the file in a terminal outside CASA using<br />
<br />
<source lang="bash"><br />
<br />
tar -xvzf Antennae_Band7_UnCalibratedMSandTablesForReduction.tgz<br />
<br />
</source><br />
<br />
then change directory to the new directory <br />
<br />
<source lang="bash"><br />
<br />
cd Antennae_Band7_UnCalibratedMSandTablesForReduction<br />
<br />
</source><br />
<br />
You may wish to type<br />
<br />
<source lang="bash"><br />
<br />
ls<br />
<br />
</source><br />
<br />
to look at the files present. You should see a set of files with extension ".ms". These are CASA measurement set (MS) files. The data have already been converted to MS format from the native ALMA format using the CASA task {{importasdm}}. In addition to the data, we provide you with calibration tables containing system temperature (Tsys), water vapor radiometer (WVR), and antenna position information. For Early Science, these tables will either be pre-applied or supplied with the data.<br />
<br />
To begin, start CASA by typing<br />
<br />
<source lang="bash"><br />
<br />
casa<br />
<br />
</source><br />
<br />
Be sure that you are using the version indicated at the top of this page.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 5.7.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casadef<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '5.7.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
--><br />
<br />
==Initial Inspection==<br />
<br />
First we will take stock of what we have. If you have not already done so, begin by reviewing the description of the observations here: [[AntennaeBand7]]. The 10 data sets each target either the Northern or the Southern Mosaic, as follows:<br />
<br />
Northern Mosaic:<br />
*uid___A002_X1ff7b0_Xb.ms<br />
*uid___A002_X207fe4_X3a.ms<br />
*uid___A002_X207fe4_X3b9.ms<br />
*uid___A002_X2181fb_X49.ms<br />
<br />
Southern Mosaic:<br />
*uid___A002_X1ff7b0_X1c8.ms<br />
*uid___A002_X207fe4_X1f7.ms<br />
*uid___A002_X207fe4_X4d7.ms<br />
*uid___A002_X215db8_X18.ms<br />
*uid___A002_X215db8_X1d5.ms<br />
*uid___A002_X215db8_X392.ms<br />
<br />
The first step is to get basic information about the data: targets observed, time range, spectral setup, and so on. We do this using the task {{listobs}}, which will output a detailed summary of each dataset. Enter the following commands into CASA:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Define a python list holding the names of all of our data sets<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
# Initialize user-input string. (for Python testing)<br />
dummy_string = ''<br />
<br />
# Loop over each element in the list and create summary file using listobs<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.listobs.txt')<br />
listobs(vis=asdm+'.ms', listfile=asdm+'.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note that after cutting and pasting a 'for' loop like this you often have to press return twice to execute. You may also want to take care to paste a line at a time if you are having trouble copy and pasting. Even better, you can use "cpaste" to paste blocks of code. To do so type "cpaste" at the CASA prompt, paste your commands, and then type "--" and hit return on the final (otherwise empty) line. This should look something like this:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
CASA <8>: cpaste<br />
Pasting code; enter '--' alone on the line to stop.<br />
:basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
: "uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
: "uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
: "uid___A002_X215db8_X392"]<br />
:<br />
:for asdm in basename_all:<br />
: print asdm<br />
:--<br />
uid___A002_X1ff7b0_Xb<br />
uid___A002_X207fe4_X3a<br />
uid___A002_X207fe4_X3b9<br />
uid___A002_X2181fb_X49<br />
uid___A002_X1ff7b0_X1c8<br />
uid___A002_X207fe4_X1f7<br />
uid___A002_X207fe4_X4d7<br />
uid___A002_X215db8_X18<br />
uid___A002_X215db8_X1d5<br />
uid___A002_X215db8_X392<br />
<br />
CASA <9>: <br />
<br />
</pre><br />
<br />
cpaste should be ''much'' more robust than copying-and-pasting directly into the shell but if you have trouble, just carefully paste one line at a time directly into CASA and hit return until the desired command executes.<br />
<br />
These commands define a python list called "basename_all", which contains the name of all 10 MS files. The "for" loop executes for each element in basename_all, calling listobs and directing the output to a file called, e.g., "uid___A002_X1ff7b0_Xb.listobs.txt" for the first measurement set. You can browse through the listobs output as you would normally look at a text file (use emacs, vi, or another editor). You can also send the output to the terminal from inside of CASA. To do so type:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
or<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('more uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
CASA knows a few basic shell commands like 'cat', 'ls', and 'rm' but for more complex commands you will need to run them inside 'os.system("command")'. For more information see http://casa.nrao.edu/ .<br />
<br />
Here is an example of the (abridged) output from {{listobs}} for the first dataset in the list, uid___A002_X1ff7b0_Xb.ms, which targets the Northern Mosaic. You would see this if you had specified '''verbose''' to be False in the listobs call:<br />
<br />
<pre style="background-color: #fffacd;"><br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_Xb.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA(11 antennas)<br />
Data records: 181357 Total integration time = 4931.71 seconds<br />
Observed from 28-May-2011/01:25:27.6 to 28-May-2011/02:47:39.3 (UTC)<br />
<br />
Fields: 26<br />
ID Code Name RA Decl Epoch SrcId nRows <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 39116 <br />
1 none Titan 12:42:43.94813 -01.43.38.3190 J2000 1 10626 <br />
2 none NGC4038 - Antennae *12:01:53.17008 -18.52.37.9200 J2000 2 4818 <br />
3 none NGC4038 - Antennae *12:01:51.90301 -18.51.49.9437 J2000 2 6435 <br />
4 none NGC4038 - Antennae *12:01:52.43086 -18.51.49.9437 J2000 2 6424 <br />
5 none NGC4038 - Antennae *12:01:52.95871 -18.51.49.9437 J2000 2 5478 <br />
6 none NGC4038 - Antennae *12:01:53.48656 -18.51.49.9436 J2000 2 6435 <br />
7 none NGC4038 - Antennae *12:01:54.01441 -18.51.49.9436 J2000 2 6446 <br />
8 none NGC4038 - Antennae *12:01:52.16693 -18.51.56.4319 J2000 2 6435 <br />
9 none NGC4038 - Antennae *12:01:52.69478 -18.51.56.4318 J2000 2 6424 <br />
10 none NGC4038 - Antennae *12:01:53.22263 -18.51.56.4318 J2000 2 6446 <br />
11 none NGC4038 - Antennae *12:01:53.75049 -18.51.56.4318 J2000 2 6446 <br />
12 none NGC4038 - Antennae *12:01:51.90301 -18.52.02.9201 J2000 2 6435 <br />
13 none NGC4038 - Antennae *12:01:52.43086 -18.52.02.9200 J2000 2 6424 <br />
14 none NGC4038 - Antennae *12:01:52.95871 -18.52.02.9200 J2000 2 4818 <br />
15 none NGC4038 - Antennae *12:01:53.48656 -18.52.02.9200 J2000 2 4829 <br />
16 none NGC4038 - Antennae *12:01:54.01441 -18.52.02.9199 J2000 2 4829 <br />
17 none NGC4038 - Antennae *12:01:52.16694 -18.52.09.4082 J2000 2 4829 <br />
18 none NGC4038 - Antennae *12:01:52.69479 -18.52.09.4082 J2000 2 4829 <br />
19 none NGC4038 - Antennae *12:01:53.22264 -18.52.09.4082 J2000 2 3872 <br />
20 none NGC4038 - Antennae *12:01:53.75049 -18.52.09.4081 J2000 2 4829 <br />
21 none NGC4038 - Antennae *12:01:51.90301 -18.52.15.8964 J2000 2 4829 <br />
22 none NGC4038 - Antennae *12:01:52.43087 -18.52.15.8964 J2000 2 4829 <br />
23 none NGC4038 - Antennae *12:01:52.95872 -18.52.15.8963 J2000 2 4818 <br />
24 none NGC4038 - Antennae *12:01:53.48657 -18.52.15.8963 J2000 2 4818 <br />
25 none NGC4038 - Antennae *12:01:54.01442 -18.52.15.8963 J2000 2 4840 <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 354971.074 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 354916.143 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11 'name'='station' <br />
ID= 0-3: 'DV02'='A015', 'DV04'='J505', 'DV06'='T704', 'DV07'='A004', <br />
ID= 4-7: 'DV08'='A072', 'DV09'='A008', 'DV10'='A009', 'DV11'='A016', <br />
ID= 8-10: 'PM01'='T702', 'PM02'='A017', 'PM03'='J504'<br />
================================================================================<br />
<br />
</pre><br />
<br />
And here is an extract from the full '''verbose''' {{listobs}} for uid___A002_X1ff7b0_X1c8.ms, which targets the Southern Mosaic (note that we have snipped out the record of individual scans):<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_X1c8.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA<br />
Data records: 175615 Total integration time = 4927.1 seconds<br />
Observed from 28-May-2011/02:50:18.2 to 28-May-2011/04:12:25.3 (UTC)<br />
<br />
<snip><br />
<br />
Fields: 33<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 12232 <br />
1 none Titan 12:42:44.82765 -01.43.41.4224 J2000 1 10615 <br />
2 none 3c279 12:56:11.16600 -05.47.21.5250 J2000 2 27764 <br />
3 none Antennae 12:01:53.17008 -18.52.37.9200 J2000 3 4829 <br />
4 none Antennae 12:01:52.18699 -18.53.30.3952 J2000 3 3883 <br />
5 none Antennae 12:01:52.64413 -18.53.26.6494 J2000 3 3883 <br />
6 none Antennae 12:01:53.10127 -18.53.22.9035 J2000 3 3872 <br />
7 none Antennae 12:01:53.55841 -18.53.19.1577 J2000 3 4818 <br />
8 none Antennae 12:01:54.01554 -18.53.15.4119 J2000 3 4829 <br />
9 none Antennae 12:01:54.47268 -18.53.11.6661 J2000 3 4829 <br />
10 none Antennae 12:01:54.92982 -18.53.07.9203 J2000 3 3872 <br />
11 none Antennae 12:01:55.38696 -18.53.04.1744 J2000 3 3883 <br />
12 none Antennae 12:01:55.84409 -18.53.00.4286 J2000 3 4840 <br />
13 none Antennae 12:01:56.30123 -18.52.56.6828 J2000 3 4818 <br />
14 none Antennae 12:01:52.18700 -18.53.22.9033 J2000 3 4829 <br />
15 none Antennae 12:01:52.64414 -18.53.19.1575 J2000 3 4818 <br />
16 none Antennae 12:01:53.10128 -18.53.15.4116 J2000 3 4818 <br />
17 none Antennae 12:01:53.55842 -18.53.11.6658 J2000 3 4840 <br />
18 none Antennae 12:01:54.01555 -18.53.07.9200 J2000 3 3872 <br />
19 none Antennae 12:01:54.47269 -18.53.04.1742 J2000 3 4829 <br />
20 none Antennae 12:01:54.92983 -18.53.00.4284 J2000 3 4829 <br />
21 none Antennae 12:01:55.38697 -18.52.56.6825 J2000 3 4829 <br />
22 none Antennae 12:01:55.84410 -18.52.52.9367 J2000 3 4829 <br />
23 none Antennae 12:01:51.72988 -18.53.19.1572 J2000 3 4818 <br />
24 none Antennae 12:01:52.18702 -18.53.15.4114 J2000 3 4829 <br />
25 none Antennae 12:01:52.64415 -18.53.11.6656 J2000 3 4829 <br />
26 none Antennae 12:01:53.10129 -18.53.07.9197 J2000 3 2266 <br />
27 none Antennae 12:01:53.55843 -18.53.04.1739 J2000 3 2266 <br />
28 none Antennae 12:01:54.01557 -18.53.00.4281 J2000 3 3212 <br />
29 none Antennae 12:01:54.47270 -18.52.56.6823 J2000 3 3234 <br />
30 none Antennae 12:01:54.92984 -18.52.52.9365 J2000 3 3212 <br />
31 none Antennae 12:01:55.38698 -18.52.49.1906 J2000 3 2266 <br />
32 none Antennae 12:01:55.84411 -18.52.45.4448 J2000 3 3223 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 356845.586 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 356900.518 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11:<br />
ID Name Station Diam. Long. Lat. <br />
0 DV02 A015 12.0 m -067.45.15.3 -22.53.26.0 <br />
1 DV04 J505 12.0 m -067.45.18.0 -22.53.22.8 <br />
2 DV06 T704 12.0 m -067.45.16.2 -22.53.22.1 <br />
3 DV07 A004 12.0 m -067.45.15.9 -22.53.28.0 <br />
4 DV08 A072 12.0 m -067.45.12.6 -22.53.24.0 <br />
5 DV09 A008 12.0 m -067.45.15.4 -22.53.26.8 <br />
6 DV10 A009 12.0 m -067.45.16.1 -22.53.26.1 <br />
7 DV11 A016 12.0 m -067.45.16.4 -22.53.25.1 <br />
8 PM01 T702 12.0 m -067.45.18.6 -22.53.24.1 <br />
9 PM02 A017 12.0 m -067.45.15.9 -22.53.26.8 <br />
10 PM03 J504 12.0 m -067.45.17.0 -22.53.23.0 <br />
</pre><br />
<br />
This output shows that three sources were observed in each data set: 3c279, Titan, and the Antennae.<br />
<br />
* The '''Antennae''' are our science target. Note that the source name changes between the Northern Mosaic, where it is "NGC4038 - Antennae", and the Southern Mosaic, where it is just "Antennae". Also note that the source corresponds to a number of individual fields (see the Field ID column). These are the individual mosaic pointings. There are 23 for the Northern Mosaic and 29 for the Southern Mosaic.<br />
* '''Titan''' is observed once and will be used to set the absolute flux scale of the data.<br />
* '''3c279''' plays two roles: it will serve as our bandpass calibrator, to characterize the frequency response of the antennas, and because it is fairly close on the sky to the Antennae (18.6 degrees away) it will serve as our secondary calibrator (also referred to as the "phase calibrator" or "gain calibrator"), to track changes in the phase and amplitude response of the telescopes over time. Observations of 3c279 are interleaved with observations of the Antennae.<br />
<br />
The output also shows that the data contain many spectral windows. Using the labeling scheme in the listobs above these are:<br />
<br />
* '''spw 0''' targets ~185 GHz and holds water vapor radiometer data<br />
* '''spw 1''' and '''spw 3''' hold our science data. These are "Frequency Domain Mode" (FDM) data with small (0.49 MHz) channel width and wide (1.875 GHz) total bandwidth. As a result these have a lot of channels (3840). spw 1 holds the lower sideband (LSB) data and includes the CO(3-2) line. We will focus on these data. For the CO(3-2) line the channel width corresponds to 0.426 km/s and the bandwidth of spw 1 to 1634 km/s.<br />
* '''spw 2''' and '''spw 4''' hold frequency-averaged versions of spw 1 and 3 ("Channel 0" for those familiar with AIPS). These are used for some quick automated inspection. We will not use them here but we will carry out an equivalent inspection using spw 1.<br />
* '''spw 5''' and '''spw 7''' hold lower a resolution processing ("Time Domain Mode", TDM) of the data from the same part of the spectrum (baseband) as spws 1 and 3. These data have only 128 channels across 2 GHz bandwidth and so have a much coarser channel spacing than the FDM data. These were used to generate the calibration tables that we include in the tarball but will not otherwise appear in this guide.<br />
<br />
The final column of the listobs output in the logger (not shown above) gives the scan intent. Later we will use this information to flag the pointing scans and the hot and ambient load calibration scans.<br />
<br />
We'll now have a look at the configuration of the antennas used to take the data using the task {{plotants}} (<xr id="Uid_A002_X1ff7b0_Xb.ANT_5.7.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb.ANT_5.7.png"><br />
[[File:Uid_A002_X1ff7b0_Xb.ANT_5.7.png|200px|thumb|right|<caption> Position of antennas in dataset uid_A002_X1ff7b0_Xb obtained using task plotants. </caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
<br />
for asdm in basename_all:<br />
print "Antenna configuration for : "+asdm<br />
plotants(vis=asdm+'.ms', figfile=asdm+'.plotants.png')<br />
clearstat()<br />
dummy_string = raw_input("Hit <Enter> to see the antenna configuration for the next data set.")<br />
</source> <br />
<br />
This will loop through all 10 data sets, show you the antenna position for each, and save that as a file named, e.g., "uid___A002_X1ff7b0_Xb.plotants.png" for the first data set. The "raw_input" command asks CASA to wait for your input before proceeding. If you would prefer to just browse the .png files after the fact you can remove this. Notice that the antenna setup changes, but only slightly, over the course of the 10 data sets.<br />
<br />
==How to Deal With 10 Measurement Sets==<br />
<br />
It should already be clear from the initial inspection that dealing with 10 data sets at the same time can be a bit problematic. This is especially tricky in our case because the Antennae data contain two distinct sets of observations: the Northern and Southern Mosaics. The source name changes between these two scripts and there are different numbers of fields in the mosaic.<br />
<br />
''As a general rule one would reduce each individual observation separately or at the very least only group data observed in a uniform way and very close in time.'' <br />
<br />
Unfortunately, a CASA Guide stepping through the reduction for each of 10 data sets would quickly become unwieldy. Therefore we will use a few tricks to reduce the Antennae data in a kind of batch mode. You have already seen the first trick: we can define a python list holding the names of each data set and then loop over this list to execute the same command on each data set. For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print asdm<br />
</source><br />
<br />
You only need to define your list of MS files once per CASA session. Then "basename_all" will be a variable in the casapy shell. You can check if it exists by typing "print basename_all". In the interests of allowing you to easily exit and restart CASA and pick this guide up at any point we will redefine "basename_all" in each section of the guide. Feel free to skip this step if you've already defined it in your session.<br />
<br />
This page will step you through the reduction of the whole Antennae Band 7 SV data set using these 'for' loops. We will not be able to show every diagnostic plot but we give an example of each and the syntax to generate the rest. Also please be aware that even on a very fast machine this whole process can take a while, we are simply dealing with a lot of data.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
One potential "gotcha" is that the source name changes between the two data sets. Therefore at several points we will break apart our loop to iterate separately over the Northern and Southern Mosaics, where the source can be referred unambiguously. Another subtle point is that 3c279 appears with two distinct field IDs in the Southern Mosaic, but only one in the Northern Mosaic. We will largely avoid this by referring to the source by its name but if you tried to use field ID numbers and mingled the two data sets this could cause confusion.<br />
</pre><br />
<br />
==''A Priori'' Flagging==<br />
<br />
Even before we look in detail, we know that there are some data that we wish to exclude. We will start by flagging "shadowed" data where one antenna blocks the line of sight of another. We will also flag scans that were used to carry out pointing and atmospheric calibration, identified by their scan intent. Finally, we'll flag the autocorrelation data (the correlation of the signal from an antenna with itself) as we are only interested in cross-correlation data to make an interferometric image.<br />
<br />
Start by defining our list of MS files:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
You may want to reset the flagging if you have tried this step before and are starting over though this is not necessary on your first time through. Do so using {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print "Resetting flags for "+asdm<br />
flagdata(vis=asdm+'.ms', mode='unflag', flagbackup=False)<br />
</source><br />
<br />
Then flag shadowed data using the command {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print "Flagging shadowed data for "+asdm<br />
flagdata(vis=asdm+'.ms',mode = 'shadow', flagbackup = False)<br />
</source><br />
<br />
In the {{flagdata}} task we choose:<br />
<br />
* '''vis''' = asdm+'.ms' : each measurement set<br />
* '''mode''' = 'shadow': flag shadowed data<br />
* '''flagbackup''' = False: Do not automatically back up the flag files. We will save all of the ''a priori'' flags together using {{flagmanager}} at the end of this subsection and save some space and time.<br />
<br />
The relevant calibration information has already been extracted from the pointing and atmospheric scans and we will not need them below. Now flag the pointing scans using {{flagdata}} in 'manualflag' mode and selecting on 'intent':<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print "Flagging calibration scans for "+asdm<br />
flagdata(vis=asdm+'.ms', mode='manual', intent='*POINTING*', flagbackup = False)<br />
</source><br />
<br />
Note that because the atmospheric calibration scans contain only TDM spectral windows, they will be removed automatically when we separate out the FDM data below.<br />
<br />
Now flag the autocorrelation data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print "Flagging autocorrelation data for "+asdm<br />
flagdata(vis=asdm+'.ms',autocorr=True,flagbackup=False)<br />
</source><br />
<br />
Finally store the current flags information using {{flagmanager}}: <br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print "Backing up 'a priori' flags for "+asdm<br />
flagmanager(vis = asdm+'.ms', mode = 'save', versionname = 'Apriori')<br />
</source><br />
<br />
Where '''versionname''' is just the name we assign to the current flagging state in the data. We can now roll back the flags to match the current version, called 'Apriori', whenever we want. There is no reason to do this now, but the syntax would be:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print "Restoring up 'a priori' flags for "+asdm<br />
flagmanager(vis = asdm+'.ms', mode = 'restore', versionname = 'Apriori')<br />
</source><br />
<br />
<br />
It would have been possible to set {{flagdata}} to '''flagbackup'''=True so that it stores the flags at each of the flagging step automatically, but this way it is a bit more efficient with regard to time and disk space. More important, lumping all the ''a priori'' flagging together gives us a natural point to roll back to if we get in trouble.<br />
<br />
<br />
The flagmanager task will also allow you to view the saved flagging versions,<br />
including those created by running flagdata with flagbackup=True.<br />
<br />
For example try <br />
<br />
<source lang="python"><br />
# In CASA<br />
flagmanager(vis='uid___A002_X2181fb_X49.ms', mode='list')<br />
</source><br />
<br />
The output in the logger should list the Apriori flagging that we have applied.<br />
It will also indicate versions associated with any flagdata command where you<br />
did not set flagbackup=False. Other tasks, for example applycal, will also create<br />
flag version tables.<br />
<br />
==Create and Apply Tsys, WVR, and Antenna Position Calibration Tables==<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
===Tsys===<br />
<br />
The Tsys calibration gives a first-order correction for the atmospheric opacity as a function of time and frequency and associates weights with each visibility that persists through imaging.<br />
<br />
Use gencal to create the Tsys calibration tables from the spectral windows with CALIBRATE_ATMOSPHERE intents in listobs (i.e. the TDM spectral windows with 128 channels), these are spectral windows 5 and 7.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#Removing existing Tsys information<br />
os.system('rm -rf *tdm.tsys')<br />
for asdm in basename_all:<br />
print "Creating TDM Tsys Table for "+asdm<br />
gencal(vis=asdm+'.ms',caltable=asdm+'.tdm.tsys',spw='5,7',caltype='tsys')<br />
</source><br />
<br />
Later in the applycal stage this TDM Tsys table will be interpolated to the FDM (3840 channels per spw) science spectral windows 1 and 3.<br />
<br />
Next we inspect the Tsys tables for the spectral window '''spw''' = 5 with the task {{plotms}}. In previous CASA versions, we used {{plotcal}} for this task, but most of '''plotcal''''s functionality is now included in {{plotms}}, and '''plotcal''' will be deprecated in a future CASA release. We want to check that Tsys data have reasonable values and identify any unexpected features as a function of either time or frequency. To get an idea of sensible Tsys under average atmospheric observations consult the ALMA sensitivity calculator, accessible from http://www.almascience.org (via the "Documents & Tools" link).<br />
<br />
We start by plotting the Tsys for all the antennas and polarizations (XX and YY) as a function of time for each. <!--Here and throughout we focus on spw 1, which contains CO(3-2): --><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Note that right now, plotms can't select individual channels when plotting caltables (as was possible with plotcal). In addition, when iteraxis is set, plotms appends the axes being iterated over to the output filename specified in plotfile; this can make for rather unwieldy filenames (particularly when iteraxis='antenna'!) but is useful for the ALMA pipeline. <br />
</pre><br />
<br />
<figure id="uid___A002_X1ff7b0_Xb.tsys_vs_time.page1_CASA5.7.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tsys_vs_time.page1_CASA5.7.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 8 antennas. Note the high y-axis values for DV04. The two different colors indicate the two polarizations (XX and YY).</caption>]]<br />
</figure><br />
<figure id="uid___A002_X1ff7b0_Xb.tsys_vs_time.page2_CASA5.7.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tsys_vs_time.page2_CASA5.7.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print "Plotting Tsys vs. time for "+asdm<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='0~7',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page1.png',overwrite=True)<br />
#dummy_string = raw_input("First eight antennas for "+asdm+" . Hit <Enter> to continue.")<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='8~15',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page2.png',overwrite=True)<br />
#dummy_string = raw_input("Remaining antennas for "+asdm+" . Hit <Enter> to continue.")<br />
</source><br />
<br />
This sequence loops over all of our files and plots Tsys as a function of time for channel 50 in spectral window 5. In the call to {{plotms}}:<br />
<br />
* '''gridrows'''=4 and '''gridcols'''=2 sets up a 4 x 2 panel grid. <br />
* '''iteraxis'''='antenna' tells {{plotms}} to make a separate plot for each antenna.<br />
* '''spw'''='5:50~50' selects spw '5' channel 50-50. This allows us to cleanly separate time variations from frequency variations. '''Note that this is a functionality in plotcal but not yet in {{plotms}}, and plotms is actually showing all channels from spw 5 at this time.'''<br />
<br />
Because 8 panels (2 panels for each antenna - LSB and USB) is not enough to show all antennas on one page, there are two {{plotms}} calls: one for the first 8 antennas ('''antenna'''='0~7'), and then for the remaining antennas ('''antenna'''='8~15').<br />
<br />
The 'raw_input' commands will wait for you to hit Enter before issuing the next plot command. In the example above these are commented out (the leading "#" means that CASA will ignore them). If you would like to interactively cycle through the plots, uncomment them by removing the "#". Otherwise, the '''plotfile''' parameter directs the output to .png files for later inspection. The easiest way to look at the 20 plots produced here is to simply inspect the .png files using your favorite viewer. As noted above, here plotms is adding the antenna information to the filenames because we set '''iteraxis''' = 'antenna', so check your directory for the impressively long filenames to view them. <br />
<br />
The Tsys values in <xr id="uid___A002_X1ff7b0_Xb.tsys_vs_time.page1_CASA5.7.png"/> and <xr id="uid___A002_X1ff7b0_Xb.tsys_vs_time.page2_CASA5.7.png"/> look reliable, with typical values ~150 K except for some large values of Tsys at ~400 and 500 K for DV04. We will flag the data for that antenna later. <br />
<br />
<figure id="uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.DV02.spw05_CASA5.7.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.DV02.spw05_CASA5.7.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 4 antennas. Note the high y-axis values for DV04 and the mesospheric line near 343.2 GHz.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.DV08.spw05_CASA5.7.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.DV08.spw05_CASA5.7.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Next 4 antennas.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.PM01.spw05_CASA5.7.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.PM01.spw05_CASA5.7.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X215db8_X392.tdm.tsys.Antennae.DV11.spw05_CASA5.7.png"><br />
[[File:uid___A002_X215db8_X392.tdm.tsys.Antennae.DV11.spw05_CASA5.7.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid___A002_X215db8_X392. Note the pathological behavior for DV12.</caption>]]<br />
</figure><br />
<br />
We will also want to look at Tsys as a function of frequency. <br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
os.system('rm -rf cal_plots/Tsys_plots/'+asdm+'.tdm.tsys*')<br />
tsysfields=['3c279','Titan','*Antennae*']<br />
caltable=asdm+'.tdm.tsys'<br />
for field in tsysfields:<br />
plotbandpass(caltable=caltable,yaxis='amp',field=field,xaxis='freq',<br />
showatm=True,overlay='time',<br />
figfile='cal_plots/Tsys_plots/'+caltable+'.'+field,<br />
buildpdf=False,interactive=False,chanrange='8~120',subplot=42)<br />
</source><br />
<br />
You will see the following statement in the logger, but this is fine: <br />
<br />
<pre style="background-color: #fffacd;"><br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
</pre><br />
<br />
Now have a look at the Tsys vs. frequency plots or see <xr id="uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.DV02.spw05_CASA5.7.png"/>, <xr id="uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.DV08.spw05_CASA5.7.png"/>, and <xr id="uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.PM01.spw05_CASA5.7.png"/> for examples on the first data set. You can see the effect of a close pair of atmospheric ozone absorption lines at about 343.2 GHz that makes Tsys larger near that frequency in all antennas. Applying the Tsys calibration tables will minimize the contribution of these atmospheric lines. Again DV04 stands out with its very high Tsys. Although not present in the first data sets, Antenna DV12 exhibits periodic spikes in Tsys vs. frequency for one polarization (see <xr id="uid___A002_X215db8_X392.tdm.tsys.Antennae.DV11.spw05_CASA5.7.png"/> for an example from a later data set). It may or may not be possible to calibrate that behavior out. We will make a note to look carefully at DV12 further on in the calibration process.<br />
<br />
===WVR===<br />
The WVR calibration uses observations of the wings of the 183 GHz atmospheric water line to correct for phase variations as a function of time. As noted in the tsys section, this run of gencal will append to existing WVR produced tables. To avoid this, preexisting wvrgcal data is removed. <br />
<source lang="python"><br />
#In CASA<br />
#Removing existing WVR information<br />
os.system('rm -rf *.wvrgcal')<br />
for asdm in basename_all:<br />
wvrgcal(vis=asdm+'.ms',caltable=asdm+'.wvrgcal',toffset=-1)<br />
</source><br />
<br />
===Antenna Positions===<br />
<br />
In general, the most appropriate antenna positions for the dataset will be determined and updated if needed during QA2. If the antenna positions need to be updated after QA2, we inform the PIs of the affected datasets and provide instructions on how to update the antenna positions. For the data in this guide, we do need to update the antenna positions. <br />
<br />
The antenna position table reflects refinements in the measured positions of the antennas from those stored in the data. {{gencal}} will now be used put antenna position data into each observation. Again, {{gencal}} will merely append to existing antenna position data, ruining any subsequent results. We start by removing any existing antenna position refinements, followed by defining the antenna names, then their refinements (both as arrays), finally running {{gencal}} to create the information CASA can refer to for antenna positions.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_Xb.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:21]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3a.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3b9.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X2181fb_X49.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV01,DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
-0.00004, 0.00026, 0.00019, #DV01-A137<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_X1c8.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X1f7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X4d7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X18.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X1d5.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X392.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
</source><br />
<br />
===Applycal===<br />
<br />
We are now ready to apply the Tsys and the WVR calibration tables to the data with {{applycal}}, which reads the specified gain calibration tables, applies them to the (raw) data column, and writes the calibrated results into the corrected column. Again, we loop through all the datasets. It is important to only apply Tsys and WVR corrections obtained close in time to the data being corrected, so in addition to looping over data sets we define the list of unique source names and loop over these. Then by setting '''gainfield''' and '''field''' to the same value we ensure that Tsys and WVR calibrations are only applied to the source for which they are measured. Because the source has a different name in the Northern Mosaic and the Southern Mosaic, we will carry out two loops. We will only correct '''spw''' 1 and 3, our science windows, because we will drop the other data in a moment.<br />
<br />
The applycal task now has much more flexibility for interpolating and applying calibrations derived in one spectral window to another, even if they do not share the same spectral shape (number of channels and channel width). This new functionality is used below to interpolate the TDM (128 channel) Tsys measurements to the FDM (3840 channel) spectral windows. This is controlled through the spectral window mapping parameter *spwmap*. Because this can be a bit confusing, we've written a "helper" function that will tell you what you should put for the Tsys calibration table part of spwmap. We only need to run it on one of the datasets because they are all the same in this regard<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysspwmap(vis='uid___A002_X207fe4_X3a.ms',tsystable='uid___A002_X207fe4_X3a.tdm.tsys')<br />
</source><br />
<br />
This will print to your screen: [0, 5, 5, 7, 5, 5, 5, 7]. Recall that the TDM spectral windows are spw=5 and 7 and the FDM spectral windows are 1 and 3. This spwmap tells applycal to use the Tsys information in spectral window 5 for spectral window 1; and to use the information in spectral window 7 for spectral window 3. Beyond that, it is only important that there are placeholders for the other spectral windows, its also useful to note that you need not give placeholders for spectral window ids larger than the largest spectral window you need to use, in this case 7.<br />
<br />
You will also need to put in placeholders for other tables that you give the gaintables. So if the Tsys table is 2nd in the list, spwmap=[[],[0,5,5,7,5,5,5,7],[]]<br />
<br />
Now run the applycal commands.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# A new list of file names that contain only data from the Northern Mosaic<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names_north = ['Titan','3c279','NGC*']<br />
<br />
for asdm in basename_north:<br />
print "Apply Tsys, WVR, and Antenna Position calibrations to "+asdm<br />
for field in field_names_north:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=['',field,field],<br />
interp=['','linear,spline','nearest'], <br />
gaintable=[asdm+'.antpos',asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]],<br />
flagbackup=False, calwt=True)<br />
<br />
# A new list of file names that contain only data from the Southern Mosaic<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names_south = ['Titan','3c279','Ant*']<br />
<br />
for asdm in basename_south:<br />
print "Apply Tsys, WVR, and Antenna Position calibrations to "+asdm<br />
for field in field_names_south:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=["",field,field],<br />
interp=['','linear,spline','nearest'],<br />
gaintable=[asdm+".antpos",asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]], <br />
flagbackup=False, calwt=True)<br />
</source><br />
<br />
where:<br />
<br />
*'''field''': the field ''to'' which we will apply the calibration, <br />
*'''gainfield''': the field ''from'' which we wish to take the calibration table<br />
*'''interp''' = 'nearest' : apply the nearest solution from the calibration table rather than interpolating.<br />
<br />
As you browse through the whole data set, you will probably note some problems along the same lines as the DV04 issue we saw above. We'll apply these as additional data flagging in just a moment.<br />
<br />
==Inspect Data==<br />
We are not quite done with the original ".ms" data sets yet. Before going further it will be useful to use {{plotms}} to show the effects of applying the calibration. In the process we'll take a quick look at each antenna and search for pathologies in the data.<br />
<br />
For this basic inspection, we want to compare the phase and amplitude as a function of frequency and time in the DATA and CORRECTED columns of each measurement set. The CORRECTED column has had the Tsys and WVR calibrations applied and so we expect lower phase scatter and flatter amplitude response as a function of time and frequency. We are looking for antenna-based issues, so cycling through a set of baselines that includes each antenna once will be a good start. We'll focus these plots on the phase+bandpass calibrator, 3c279, and on baselines that include antenna DV11, which we will make our reference antenna in just a bit.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
Each CASA Measurement Set has up to three "columns" of data: DATA, CORRECTED, and MODEL (though it is possible<br />
for a MS to hold only a DATA column if it has not been processed at all). <br />
<br />
A column entry exists for each data point (baseline, frequency, time). <br />
<br />
The DATA column holds the current raw data, though using split as we just did we can change the definition of<br />
"raw" data. <br />
<br />
The CORRECTED column holds the result of applying one or more calibration tables (e.g., via applycal) to the<br />
DATA column and so represents a corrected version of the DATA column. <br />
<br />
The MODEL column is now deprecated (though it is still possible to use it by explicitly setting usescratch=True).<br />
Instead, the model is stored in the header of the ms. This is a great step forward in terms of saving space and time <br />
to create scratch columns <br />
<br />
To get an intuitive feel for the columns you may wish to explore using plotms (which can plot different data <br />
columns, as seen below) or the browsetable task.<br />
<br />
</pre><br />
<br />
<figure id="uid___A002_X215db8_X392.amp_vs_freq_CASA5.7.png"><br />
[[File:uid___A002_X215db8_X392.amp_vs_freq_CASA5.7.png|200px|thumb|right|<caption> Example of Amplitude vs. Frequency before correction for the first Northern Mosaic data set.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X215db8_X392.amp_vs_freq_corrected_CASA5.7.png"><br />
[[File:uid___A002_X215db8_X392.amp_vs_freq_corrected_CASA5.7.png|200px|thumb|right|<caption> Same baseline as Figure 8 but now after correction using WVR and Tsys calibrations.</caption>]]<br />
</figure><br />
<br />
First, we plot amplitude as a function of frequency for 3c279. We start by plotting the DATA column, set color to indicate the two correlations (i.e., the XX and YY polarizations), and ask plotms to iterate over baseline. By setting '''antenna''' to 'DV11&*' we select only baselines that include DV11. We ask plotms to average all data over a very long timescale, '''avgtime''' = 1e8 seconds ~ 3 years or much longer than the time spanned by the whole data set. By setting '''avgscan''' = True we allow {{plotms}} to average across scan boundaries. The result is a plot of average amplitude per channel vs. frequency.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
asdm=basename_all[0]<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='amp',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Notice the green arrows along the bottom of the {{plotms}} window. We asked {{plotms}} to iterate over baseline. As you click the arrows, the plot will rotate from baseline to baseline, always with DV11 so that each antenna shows up once. To see the effect of the calibration, go to the "Axes" tab along the left of the {{plotms}} window and pull down the Data Column menu under the Y Axis. Set this from DATA to CORRECTED and you should see the effects of the calibration. You may need to ensure that the "Force Reload" box is checked before clicking "Plot" (both buttons lie at the bottom of the panel). For the most part things get better (flatter), but as we noted before DV04 is problematic.<br />
<br />
<figure id="plotms_amp_vs_time_north_CASA5.7.png"><br />
[[File:plotms_amp_vs_time_north_CASA5.7.png|200px|thumb|right|<caption> Example of phase vs. time.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_time_south_CASA5.7.png"><br />
[[File:plotms_amp_vs_time_south_CASA5.7.png|200px|thumb|right|<caption> Example of phase vs. frequency.</caption>]]<br />
</figure><br />
<br />
You can now make analogous calls to examine the phase vs. frequency, amplitude vs. time, and phase vs. time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='phase',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='amp',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='phase',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Where:<br />
<br />
* '''spw''' is set to cover only channels 1200~1300 for the time plots in order to isolate time dependent variations from frequency-dependent behavior. Those 101 channels represent only a small part of the total spw 1 bandpass.<br />
* '''avgchannel''' set to a large number causes the plots of phase and amplitude vs. time to average data at all frequencies into a single point for each measurement.<br />
* '''coloraxis''' corr sets the colors to correspond to the two polarizations of the data.<br />
<br />
In each case, you will want to examine each baseline, alternating between the DATA and CORRECTED columns.<br />
<br />
This is a lot of data inspection and that's only for one of 10 data sets! You can iterate across the data by hand, updating "asdm" to refer to each data set in order and cycling between baselines and DATA/CORRECTED. It is also possible to script CASA to show you the key plots in succession (see the next block down). However you approach the infrastructure, you are looking for:<br />
<br />
* Improved scatter and lower variability in phase and amplitude vs. frequency and time. This indicates that the WVR and Tsys calibrations helped. <br />
* Sudden jumps in phase or amplitude as a function of either time or frequency. These may indicate problems with the antenna during that observation.<br />
* Large gradients, especially full wraps, in phase as a function of frequency. This may indicate a problem in the delays, the signal path length to the telescopes.<br />
* Unusual magnitude, scatter, or patterns in any plot - though this may be better explored using plots that show all data together, which we'll make in a moment.<br />
* Missing data. For example, if the phase calibrator drops out for a period of time we will not be able to calibrate and will need to flag the data.<br />
<br />
As you look through, note individual potentially problematic antennas. If ''all'' antennas in a data set appear problematic it may be that your "reference" antenna, DV11 in the example above, is the source of the problem. In this case swap this reference antenna for another and see whether the problem is isolated to your original reference antenna.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
A brief aside on structure:<br />
<br />
This section (Data Inspection) and the next (Apply Flags) are closely linked. We will present them as two<br />
separate steps. The idea here is that you look through your data, note problems, and then write commands to<br />
flag problematic data. This mimics one approach to writing data reduction scripts for CASA, where you will<br />
group all flagging together into one convenient place. Other CASA guides take a different approach, interleaving <br />
flagging and plotting. There is no "right" answer here. Find an approach to data inspection that works for you.<br />
<br />
</pre><br />
<br />
If you do wish to semi-automate the plot generation, the following sequence will cycle between data and corrected plots for each data set in turn. Type "stop" at any input call to break out.<br />
<br />
<!--<br />
'''Note:''' In loops like this involving {{plotms}}, hitting enter before the last dataset completes loading may cause {{plotms}} to stop refreshing the plot window at each step, or cause the window to disappear altogether. This will be fixed in an upcoming CASA release. Right now, you may need to exit CASA and restart to bring up the {{plotms}} window again, but you should be able to continue in the script where you left off.<br />
--><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
user_input = ""<br />
for asdm in basename_all:<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
# Extract antenna list for this data set.<br />
tb.open(asdm+'.ms/ANTENNA', nomodify=True)<br />
ants = tb.getcol('NAME')<br />
tb.close<br />
# Define the reference antenna to make baselines with<br />
ref_ant = 'DV11'<br />
# Loop over antennas<br />
for ant in ants:<br />
# Check if the user wants to stop<br />
if user_input == "stop":<br />
break<br />
# Skip correlation of reference antenna with itself (autocorrelations are flagged anyhow) <br />
if ant == ref_ant:<br />
continue<br />
# Define the baseline with the reference antenna for current antenna<br />
ant_str = ref_ant+'&'+ant<br />
print "Showing baseline "+ant_str+" for data set "+asdm<br />
print "Use this to inspect effect of applying wvrcal and Tsys calibrations."<br />
# Loop over phase and amplitude as axes<br />
for y_axis in ["amp", "phase"]:<br />
# Make 'before' plot for frequency x-axis<br />
print "... "+y_axis+" vs. frequency for DATA:" <br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = raw_input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for frequency x-axis<br />
print "... "+y_axis+" vs. frequency for CORRECTED:"<br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = raw_input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'before' plot for time x-axis<br />
print "... "+y_axis+" vs. time for DATA:" <br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = raw_input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for time y-axis<br />
print "... "+y_axis+" vs. time for CORRECTED:"<br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = raw_input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<figure id="plotms_amp_vs_uvdist_north.png"><br />
[[File:plotms_amp_vs_uvdist_north_CASA5.7.png|200px|thumb|right|<caption> Example of amplitude vs. uv-distance for 3c279 in the first northern mosaic data set.</caption>]]<br />
</figure><br />
<br />
<figure id="plotms_amp_vs_freq_3c279.png"><br />
[[File:plotms_amp_vs_freq_3c279_CASA5.7.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for 3c279 in the second northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Titan.png"><br />
[[File:plotms_amp_vs_freq_Titan_CASA5.7.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for Titan in the second northern mosaic data set. Note the strong line (this is CO 3-2)!</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Antennae.png"><br />
[[File:plotms_amp_vs_freq_Antennae_CASA5.7.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for the Antennae in the second northern mosaic data set. The CO(3-2) line is visible.</caption>]]<br />
</figure><br />
<br />
A detailed explanation of the procedure is a bit outside the scope of this guide (for more on python see http://www.python.org/ and for more on the CASA toolkit see http://casa.nrao.edu/), but the basic process is to loop over each data set, baseline with the reference antenna (here DV11), and y-axis of interest (phase or amplitude) then plot the effect of the calibration vs. frequency and time for each combination. Running this to step through the data will give you about 200 "before and after" plots from which you could note a subset of problematic cases to be followed up by hand. Many other strategies to inspect the data are also viable.<br />
<br />
With the Tsys and WVR calibrations applied successfully and the ''a priori'' flagging taken care of we will now {{split}} out the corrected data. We will keep only the corrected data, specified via '''datacolumn''', and only spectral window 1, which contains the FDM (high spectral resolution) observations of the CO(3-2) line. Setting '''keepflags'''=False tells {{split}} not to carry over any fully flagged rows from the original data set to the new MS. We give the new MS files the extension ".wvrtsys.ms" to indicate that they have been corrected for WVR and Tsys effects. Because split will not overwrite existing files, we remove any previous versions of the new MS before beginning.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm -rf '+asdm+'.wvrtsys.ms')<br />
print "Splitting out corrected data for "+asdm<br />
split(vis=asdm+'.ms', outputvis=asdm+'.wvrtsys.ms', <br />
datacolumn='corrected', spw='1', keepflags=False)<br />
</source><br />
<br />
Be patient, {{split}} may take awhile. The WVR and Tsys-corrected data now sit in the DATA column of the new measurement sets, which have only one spectral window (now labeled spectral window 0 though it was spectral window 1 in the original data). You may wish to run {{listobs}} to illustrate the changes:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.wvrtsys.listobs.txt')<br />
listobs(vis=asdm+'.wvrtsys.ms', listfile=asdm+'.wvrtsys.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note the new spectral window information:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
2011-08-05 01:07:08 INFO listobs Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
2011-08-05 01:07:08 INFO listobs SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
2011-08-05 01:07:08 INFO listobs 0 3840 TOPO 344845.586 488.28125 1875000 344908.33 XX YY <br />
<br />
</pre><br />
<br />
<br />
Next we will do a bit more inspection using {{plotms}} to look at whole data sets. This will help us identify missing data or look for egregious outliers.<br />
<br />
First we plot amplitude versus time (see <xr id="plotms_amp_vs_time_north_CASA5.7.png"/> and <xr id="plotms_amp_vs_time_south_CASA5.7.png"/>), averaging over all channels (by setting '''avgchannel''' to the very large value 10,000). We colorize by field so that scans on Titan are red, the bandpass and phase calibrator 3c279 is black (and orange in the Southern Mosaic where it has two field IDs), and the Antennae mosaic appears as a range of colors (one per pointing).<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='amp', <br />
avgchannel='3840',coloraxis='field', showgui = True)<br />
user_input = raw_input("Examining amplitude vs. time for "+asdm+" . Hit <Enter> to proceed.[type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
Here look for:<br />
<br />
* Missing data. The source needs to be flanked by phase calibrator scans, if those are missing for any reason we need to flag the appropriate time range.<br />
* Dramatic outliers. Does the source suddenly get very bright or the otherwise bright calibrator appear anomalously faint for a brief time? This likely indicates problematic data that should be identified and flagged. You can use the "select" (box with green plus along the bottom row in plotms) and "locate" (magnifying glass) buttons in {{plotms}} to isolate and identify problem data (it will print to the log).<br />
* Smooth variation with time. A sudden jump may indicate a problem and often the safest approach is to flag data near a discontinuity.<br />
<br />
Look through the amplitudes vs. time for each data set (remember that we've already examined the phases vs. time and amplitude vs. time for individual baselines above).<br />
<br />
There are two other very useful "averaging" plots worth making. First, we plot amplitude as a function of u-v distance (projected antenna separation). Discontinuities and spikes in this plot are often from non-astrophysical sources. In the phase analog to the plot, the effects of atmospheric decorrelation can be assessed from increased scatter at longer u-v distances. While using the moon Titan as our flux calibrator, we may want to watch for flaring amplitudes at short u-v distances. These may indicate that Saturn is contaminating our beam. For a perfect, bright point source, we expect flat amplitudes as a function of u-v distance at the source amplitudes. <xr id="plotms_amp_vs_uvdist_north.png"/> shows an example of this plot, generated via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='3c279',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Examining amplitude vs. UV Distance for 3c279 for "+asdm+" . Hit <Enter> to proceed.")<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='Titan',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
user_input = raw_input("Examining amplitude vs. UV Distance for Titan for "+asdm+" . Hit <Enter> to proceed [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
<br />
<br />
It can also be useful to examine the average amplitude as a function of frequency for each target. This allows one to check for lingering atmospheric effects, unexpected line emission or absorption in the calibrators, or decreased sensitivity due to "roll-off" of the telescope sensitivity at the band edges. These plots are created by the sequence of commands below, where we have broken up the script to loop separately over the Northern and Southern Mosaics to reflect the different source names.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names = ["3c279","Titan","NGC*"]<br />
<br />
for asdm in basename_north:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Examining amplitude vs. frequency for "+field+" in "+asdm+". Hit <Enter> to proceed.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names = ["3c279","Titan","Ant*"]<br />
<br />
for asdm in basename_south:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Examining amplitude vs. frequency for "+field+" in "+asdm+" . Hit <Enter> to proceed.")<br />
<br />
</source><br />
<br />
<br />
For this command notice that we can see the CO(3-2) line in the Antennae even before calibration (see <xr id="plotms_amp_vs_freq_Antennae.png"/>) and that Titan also shows evidence of a strong line (also <xr id="plotms_amp_vs_freq_Titan.png"/>)! This will need to be flagged before we can use Titan to calibrate the flux scale of our data.<br />
<br />
This suite of plots (along with the earlier inspection of the Tsys tables) gives us the tools we need to identify problematic data through the data sets. We use this to generate a set of inspection-driven {{flagdata}} commands for each data set. We apply these before the bandpass and gain calibration.<br />
<br />
==Apply Flagging==<br />
Based on this inspection and the other plots we have made, we now flag problematic portions of the data. We break up the flags by reason for flagging in order to illustrate the process. As you reduce your own data it may be more efficient to group flags by data set and make use of the flagcmd command. Except for the "post-calibration" flagging, the inspection plots that we just looked through have already revealed all of the problems that we flag. We structure the guide so that the flagging is grouped in one place.<br />
<br />
As before, we may wish to reset our flags before beginning (particularly if one iterates this process) via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms',mode='unflag', flagbackup = False)<br />
</source><br />
<br />
Remember that we dropped the flagged data when splitting out after the WVR and Tsys calibration, so this should not undo your "A Priori" flagging of shadowed data, autocorrelations, etc.. In any case this unflagging step is not necessary during the first iteration.<br />
<br />
* '''Edge Channels'''<br />
<br />
ALMA's sensitivity decreases near the edge of the baseband and it is often useful to check for a 'roll-off' in sensitivity near the edge of the band. This will appear as a downturn in amplitude as a function of channel near the edge of the window in the uncalibrated data, as a flaring due to increased noise at the spw edges in the calibrated data. It will also be visible in the amplitude part of the bandpass calibration table. Because our FDM spw does not cover the full baseband, we do not see a strong roll off in our data (see <xr id="amp_vs_channel_example.png"/>), where there is only a mild hint of a roll-off at the high end) but we do flag a (very) few channels at the high and low-frequency edge of the data set to be safe.<br />
<br />
<figure id="amp_vs_channel_example.png"><br />
[[File:amp_vs_channel_example.png|200px|thumb|right|<caption> Amplitude vs. channel for one uncalibrated antenna pair. This kind of plot can be inspected to get an idea of the presence or magnitude of any roll-off in sensitivity near the edges of the spectral window.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:0~7,0:3831~3839', flagbackup = False)<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:3260~3320', flagbackup = False)<br />
</source><br />
<br />
* '''Problematic Tsys measurements'''<br />
<br />
Above we noted issues with the Tsys measurements for both DV04 and DV12. We flag the affected data. Each of these issues should be visible in the Tsys plots you made above (e.g., see <xr id="uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.DV02.spw05_CASA5.7.png"/> and <xr id="uid___A002_X1ff7b0_Xb.tdm.tsys.Antennae.DV08.spw05_CASA5.7.png"/>).<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04',flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X1d5"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X392"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
</source><br />
<br />
* '''Unreliable Short-Spacing Measurements on Titan'''<br />
<br />
<figure id="amp_vs_uv_titan_obs.png"><br />
[[File:amp_vs_uv_titan_obs.png|200px|thumb|right|<caption> Observed amplitude vs. uv-distance for observations of Titan in the first data set. Note the scatter for low projected antenna separations. We will flag these short-spacing data, which may reflect contamination by Saturn, and use only the more extended baselines for flux calibration.</caption>]]<br />
</figure><br />
<br />
Saturn may contaminate the short u-v spacings from Titan. In any case these often show significant scatter (<xr id="amp_vs_uv_titan_obs.png"/>), so we flag them. There are still enough baselines to determine a good amplitude calibration for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~40', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
</source><br />
<br />
* '''Delay Issues''' <br />
<br />
<figure id="phase_vs_freq_DV13.png"><br />
[[File:phase_vs_freq_DV13.png|200px|thumb|right|<caption> Phase vs. frequency for DV13 in a data set where this antenna shows evidence of imperfect delay calibration.</caption>]]<br />
</figure><br />
<br />
DV13 and a few other antennas show signatures of an imperfect delay calibration. This is most easily identified via strong "wrapping" of phase as a function of frequency (see <xr id="phase_vs_freq_DV13.png"/>). Such effects can be calibrated out with mild delay issues largely accounted for by the bandpass solution. The phase wrapping in DV13 seems weak enough that we will trust the calibrations to remove it. For a more extreme example see the CASA guide describing the calibration of [[NGC3256Band3]].<br />
<br />
* '''Missing Phase Calibrator Observations'''<br />
<br />
<figure id="amp_vs_time_missing_scans.png"><br />
[[File:amp_vs_time_missing_scans.png|200px|thumb|right|<caption> Amplitude vs. time colored by field for a data set where the final visit to the phase calibrator is missing. We will flag the last set of source data to ensure that each visit to the source is flanked in time by visits to the phase calibrator.</caption>]]<br />
</figure><br />
<br />
As a general rule, we want to be sure that observations of the phase calibrator (3c279) bracket each source observation. Two of the data sets do not include a final phase calibrator observation (see <xr id="amp_vs_time_missing_scans.png"/>) and for those two cases we flag the affected source observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='00:53:47~01:08:00',flagbackup = False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV10',timerange='19:46:20~20:34:40',flagbackup=False)<br />
</source><br />
<br />
* '''Unexpected Scatter or Discontinuity in the Data'''<br />
<br />
For several antennas we find sudden jumps in the phase of the phase calibrator as a function of time. These are visible in the plots of uncalibrated phase vs. time for single baselines above, and we show an example in <xr id="phase_vs_time_DV09.png"/>. It will not be possible to effectively interpolate the phase between measurements when we see these discontinuities. The safest approach is to flag the source data across these jumps. We do so here (though note that the last two flaggings are borderline cases).<br />
<br />
<figure id="phase_vs_time_DV09.png"><br />
[[File:phase_vs_time_DV09.png|200px|thumb|right|<caption> Phase vs. time for DV09 on a problematic day. It may prove problematic to calibrate the data near this discontinuity so we flag data near this time.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09', timerange='21:24:09~21:35:35', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09',timerange='23:30:52~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM01',timerange='23:16:50~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM03',timerange='23:16:50~24:10:00',flagbackup=False)<br />
</source><br />
<br />
* '''Outliers Visible After Calibration'''<br />
<br />
<figure id="amp_vs_uvdist_outliers.png"><br />
[[File:amp_vs_uvdist_outliers.png|200px|thumb|right|<caption> Amplitude vs. u-v distance ''after'' calibration. Note the outlying data. We track these down using the select (box with green "+") and locate (magnifying glass) features inside plotms and identify several problematic baselines across our data. ''Note that you cannot make this plot at this point in the guide, these pathologies become evident after calibration, requiring an iterative approach to reduction.''</caption>]]<br />
</figure><br />
<br />
Often issues with the data may become evident after calibration (i.e., after the next few steps that we apply). These data can appear as outliers in diagnostic plots for the calibrated data or even show up in the imaging stages. Once these are identified, best practice is to apply this new flagging then redo the calibration (if the issue is very minor, then re-calibrating may not be necessary).<br />
<br />
<source lang="python"><br />
# In CASA<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='21:18:00~21:22:15', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV01&DV04', flagbackup=False)<br />
</source><br />
<br />
Now that we've applied our flagging, back up the flags as version "User" using {{flagmanager}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis=asdm+'.wvrtsys.ms',mode='save',versionname ='User')<br />
</source><br />
<br />
Applying this flagging will remove the most egregious pathologies from the data. We are now ready to calibrate the data.<br />
<br />
==Bandpass Calibration==<br />
<br />
We begin by calibrating the phase and amplitude response of each antenna as a function of frequency, called "bandpass calibration." We have already seen that the data contain smooth but systematic variations in both phase and amplitude as a function of frequency. We can see this again in a more compact form by plotting phase as a function of frequency for all baselines associated with each antenna (<xr id="plotms_phase_vs_freq_example.png"/>).<br />
<br />
<figure id="plotms_phase_vs_freq_example.png"><br />
[[File:Xb_phase_vs_freq_CASA5.7.png|200px|thumb|right|<caption> Phase vs. frequency for the bandpass calibrator, 3c279 in the first data set. We plot all baselines with DV02, averaged over time, and show only the 'XX' correlation.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='freq', yaxis='phase', <br />
selectdata=True, field='3c279', correlation='XX',<br />
avgtime='1e8', avgscan=True, antenna='*&*',<br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = raw_input("Plotting phase vs. frequency for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
Each plot shows phase as a function of frequency for all baselines with one antenna for 3c279. We plot only the 'XX' correlation, colorizing by baseline. With '''iteraxis''' set to antenna the green arrows at the bottom of {{plotms}} will cycle through antennas. By using '''avgscan''' and a large '''avgtime''' we average all scans and integrations. <br />
<br />
The phase (and amplitude) also varies as a function of time, as we saw before. Here are the similar plots for phase vs. time (see <xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb-phasecont.png"><br />
[[File:Xb_phase_vs_time_CASA5.7.png|200px|thumb|right|<caption> Phase vs. time for the bandpass calibrator, 3c279. Averaged over channel. Only baselines with antenna DV02, and corr='XX'</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='phase', <br />
selectdata=True, field='3c279', <br />
spw='0:1200~1300', antenna='*&*',correlation='XX',<br />
avgchannel='1000', avgscan=True, <br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = raw_input("Plotting phase vs. time for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
<xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/> shows that the phase varies with time. We need to take this temporal variation into account when we solve for the frequency variations. Therefore we carry out the bandpass calibration in two steps. First, we use {{gaincal}} to solve for the variation of phase as a function of time for 3c279 on very short timescales. We set {{gaincal}} to derive a separate phase solution for each antenna every integration by setting '''solint''' to 'int'. We solve, averaging together only a small fraction of the total bandpass (channels 1100-1300) to avoid the effects of the phase vs. frequency behavior. We will then apply this solution to remove time-dependent behavior when we solve for the frequency response of the antennas with {{bandpass}}.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
An integration is the smallest time quantum of observation in the data, usually a few seconds. <br />
You can check the integration length for each scan in listobs. <br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
for asdm in basename_all:<br />
print "Running a short solution interval phase calibration for "+asdm<br />
os.system('rm -rf '+asdm+'.bpphase.gcal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
selectdata=True,field = '3c279',spw = '0:1100~1300',<br />
caltable = asdm+'.bpphase.gcal',<br />
solint = 'int',refant = 'DV11',calmode='p')<br />
</source><br />
<br />
Now we use {{bandpass}} to solve for the frequency response of each antenna. To do this, we average all data in time by setting '''solint''' to 'inf' (that is, 'infinite'). We allow combination across scans and the different field IDs found for 3c279 by setting '''combine''' to "scan,field". We apply the phase vs. time calibration that we just derived on-the-fly using the parameter "gaintable".<br />
<br />
<source lang="python"><br />
for asdm in basename_all:<br />
print "Running a bandpass calibration for "+asdm<br />
os.system('rm -rf '+asdm+'.bandpass.bcal')<br />
bandpass(vis = asdm+'.wvrtsys.ms',<br />
field = '3c279',<br />
gaintable = asdm+'.bpphase.gcal',<br />
caltable = asdm+'.bandpass.bcal',<br />
bandtype='B',<br />
solint = 'inf',combine = 'scan,field', solnorm=True,refant = 'DV11',<br />
minblperant=3,minsnr=2,fillgaps=62)<br />
</source><br />
<br />
in these calls:<br />
<br />
*'''caltable''' specifies the output calibration table<br />
*'''gaintable''' specifies any calibration tables to be applied "on the fly" to the data before solving.<br />
*'''solint''' sets the time interval for which solutions are derived for each antenna.<br />
*'''refant''' set the reference antenna, here DV11, which is defined to have zero correction by construction.<br />
*'''calmode''' 'p' sets {{gaincal}} to calibrate the phase only, other options are 'a'mplitude or 'ap' - amplitude and phase.<br />
*'''minblperant''' sets the minimum baselines required per antenna for a successful solution.<br />
*'''minsnr''' sets the minimum signal-to-noise ratio required for a successful solution.<br />
*'''bandtype''' here 'B' tells {{bandpass}} to solve for the phase and frequency response of each antenna in each channel, averaging data in time across the solution interval.<br />
*'''fillgaps''' tells {{bandpass}} to interpolate across channel gaps 1 channel wide.<br />
*'''solnorm''' tells {{bandpass}} to normalize the bandpass amplitude and phase corrections to have magnitude unity. The absolute scale of the calibration will come from our later {{gaincal}} solutions.<br />
<br />
Do not worry about the message "Insufficient unflagged antennas" when running the {{bandpass}} task. This indicates that {{bandpass}} is failing on the flagged edge channels, which is expected.<br />
<br />
It is now a good idea to plot both sets of solutions to look for irregularities, especially:<br />
<br />
* discontinuities in the phase vs. time solution<br />
* rapid wrapping of phase in either phase vs. time or bandpass solution<br />
* large roll-off in the amplitude response near the band edge in the bandpass solution<br />
* large scatter in any solution.<br />
<br />
We loop through and using analysis utils, again generating .png files of each calibration. '''For what systems is this true?''' As the bandpass plots take a while you may want to go have a cup of coffee and inspect them using your favorite image viewer. Otherwise, switch the '''interactive''' parameter to True to see them in real time instead.<br />
<br />
<figure id="uid___A002_X1ff7b0_X1c8.bpphase.page1.png"><br />
[[File:uid___A002_X1ff7b0_X1c8.bpphase.page1.png|200px|thumb|right|<caption> Short interval phase vs. time solution carried out and applied during bandpass calibration, here for the first set of antennas for the first data set. This solution removes any systematic variations in phase vs. time.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1.CASA3.4.png"><br />
[[File:Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1.CASA5.7.png|200px|thumb|right|<caption> Bandpass amplitude solution for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X1ff7b0_Xb.bcal_phase.page1.png"><br />
[[File:uid___A002_X1ff7b0_Xb.bcal_phase.page1.png|200px|thumb|right|<caption> Phase vs. frequency calibration from the bandpass calibration for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<br />
<!--<br />
Again this warning:<br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
--><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
os.system('rm -rf cal_plots/*bandpass*.png')<br />
for asdm in basename_all:<br />
plotbandpass(caltable=asdm+'.bandpass.bcal',<br />
field='',xaxis='freq',yaxis='both',<br />
figfile='cal_plots/'+asdm+'.bandpass.png',<br />
showatm=True,interactive=False,subplot=42)<br />
</source><br />
<br />
==Absolute Flux Calibration==<br />
<br />
The bandpass calibration will account for the phase and amplitude response of our antennas as a function of frequency. We now solve for the absolute flux scale of the data by referencing to Titan and in the next section we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
Before using Titan to set the flux, there is an important systematic to account for. When we looked at the integrated spectra of our targets above, remember that Titan showed a whopping spectral line, in fact the same CO(3-2) line that we wish to observe in the Antennae. We will set the flux of Titan (and thus all of our data) by referencing to a model in casa that does not account for this line. Therefore we need to flag the part of the Titan observations contaminated by the line before we calibrate (you can see the affected channel range in <xr id="Antennae-TitanLine.png"/>). We run the following additional flagging step:<br />
<br />
<figure id="Antennae-TitanLine.png"><br />
[[File:Antennae-TitanLine.png|200px|thumb|right|<caption> Uncalibrated amplitude vs. channel plot for the flux calibrator, Titan (uid___A002_X1ff7b0_Xb dataset). Averaged over time, corr='XX', and colorized by baseline.</caption>]]<br />
</figure><br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print "Flagging CO(3-2) in Titan for "+asdm<br />
flagdata(vis=asdm+'.wvrtsys.ms',flagbackup=False, <br />
field='Titan', spw='0:1100~1700')<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis =asdm+'.wvrtsys.ms',mode = 'save',versionname = 'Calibration')<br />
</source><br />
<br />
Next, we will use the {{setjy}} task to read the predicted complex visibilities for Titan into the MODEL column of each data set.<br />
<br />
<source lang="python"><br />
# in CASA<br />
for asdm in basename_all:<br />
print "Reading model for Titan into "+asdm<br />
setjy(vis = asdm+'.wvrtsys.ms',field = 'Titan',<br />
usescratch=True,scalebychan=True,<br />
standard = 'Butler-JPL-Horizons 2012')<br />
</source><br />
<br />
{{setjy}} will output the flux of Titan to the CASA logger and it is worth recording this information. The flux of Titan at these frequencies is about 3.3 Jy. For example, for dataset uid___A002_X1ff7b0_Xb.wvrtsys.ms:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Titan: spw0 Flux:[I=3.2637,Q=0.0,U=0.0,V=0.0] +/- [I=0.0,Q=0.0,U=0.0,V=0.0] Jy @ 344.85GHz<br />
</pre><br />
<br />
Now we are going to take a look at the Titan model for one dataset:<br />
<br />
<source lang="python"><br />
# in CASA<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
</source><br />
<br />
<figure id="2012_titan_model_5.7.png">[[File:Titan_model_amp_vs_uvdist_CASA5.7.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2012'.</caption>]]</figure><br />
<figure id="2010_titan_model.png">[[File:2010_titan_model.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2010'.</caption>]]</figure><br />
<br />
<br/><br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
The setjy invocation made in this section uses the flux density standard '''standard='Butler-JPL-Horizons 2012' '''. Previous versions of this guide used an older flux density standard '''standard='Butler-JPL-Horizons 2010' '''. <xr id="2012_titan_model_5.7.png"/> and <xr id="2010_titan_model.png"/> show the differences in the Titan models produced using these two standards. <br />
</div><br />
<br />
==Gain (Phase and Amplitude) Calibration==<br />
<br />
With the flux now properly scaled, we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
We begin by running a short-solution interval {{gaincal}} to solve for phase variation on short timescales during observations of our two calibrators, with '''solint''' set to "int". By applying this on-the-fly, we can remove any decorrelation in the data due to phase scatter when we solve for the amplitude calibration. However, there is no benefit to using this short-timescale solution to calibrate the source because we only have information on the gain during calibrator visits (though see the Imaging portion of this guide). Instead we will solve for the gains to apply to the source using a longer '''solint''' in just a moment.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print "Carrying out short timescale phase solution for "+asdm<br />
os.system('rm -rf '+asdm+'.intphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.intphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='int',minsnr=2.0, minblperant=4)<br />
</source><br />
<br />
Now we derive the longer timescale phase calibration table using '''solint''' set to "inf", but not allowing scan combination. This calibration has higher signal to noise due to combining more data, and for the purposes of correcting the source, it is just as precise as the short timescale solution.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print "Carrying out longer timescale phase solution for "+asdm<br />
os.system('rm -rf '+asdm+'.scanphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.scanphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='inf',minsnr=2.0,minblperant=4)<br />
</source><br />
<br />
Now we apply the short-timescale phase solution and carry out a scan length ('''solint''' set to "inf") calibration of the data using '''calmode''' of 'ap'.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print "Solving for longer (scan) interval amplitude solution for "+asdm<br />
os.system('rm -rf '+asdm+'.amp.cal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
gaintable =[asdm+'.bandpass.bcal',asdm+'.intphase.gcal'],<br />
caltable = asdm+'.amp.cal',<br />
calmode='ap',<br />
field = 'Titan,3c279',<br />
spw='0:40~3800',<br />
refant = 'DV11',solint = 'inf', minblperant=4)<br />
</source><br />
<br />
This "amp.cal" solution gives us the amplitude variations as a function of time, but they are not yet pinned to a realistic scale except in the case of Titan, where we have solved using the model input by {{setjy}}. We will set the flux of our secondary calibrator 3c279 with reference to Titan using {{fluxscale}}.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print "Scaling amplitude calibration to match Titan for "+asdm<br />
os.system('rm -rf '+asdm+'.flux.cal')<br />
fluxscale(vis = asdm+'.wvrtsys.ms',<br />
caltable = asdm+'.amp.cal',<br />
fluxtable = asdm+'.flux.cal',<br />
reference = 'Titan',<br />
transfer = '3c279')<br />
</source><br />
<br />
This new correctly-scaled flux table ".flux.cal" replaces the previous ".amp.cal" table as the correct amplitude calibration table to apply to the data, i.e., the ".flux.cal" contains both the time variability of the amplitude solved for in ".amp.cal" and the correct flux scaling set with {{fluxscale}}.<br />
<br />
Fluxscale will output the derived flux for 3c279 to the CASA logger. This information is worth noting. We find that the flux of 3c279 is 10.79 Jy, by averaging the fluxes obtained from the ten available datasets. If we check this value against reported flux measurements in the SMA calibrator list [http://sma1.sma.hawaii.edu/callist/callist.html], we find that a flux of 10.79 Jy agrees within a few per cent of a linear interpolation between the two 0.85 mm measurements closest in time to the ALMA observations: (23 May 2011, SMA 11.644 ± 0.583; 01 July 2011, 9.748 ± 0.488).<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used the older, Butler-JPL-Horizons 2010, flux density standard when you ran {{setjy}} earlier in this tutorial, the derived flux values for 3c279 will be slightly lower. The flux of 3c279, when averaged over all 10 measurement sets, will be 10.41 Jy.<br />
</div><br />
<br />
Now we plot the final phase and amplitude calibration tables for each data set. A well-behaved calibration table will show smooth variations as a function of time. Sudden jumps or wild variations among the antenna amplitude gains should prompt further investigation and possibly additional flagging.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print "Plotting solutions for "+asdm<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis='antenna',antenna='0~7',plotrange=[0,0,-180,180],<br />
gridrows=4,gridcols=1,showgui=False,<br />
plotfile=asdm+'.scanphase.page1.png')<br />
# dummy_string = raw_input("Hit <Enter> to see next plot.")<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis = 'antenna', antenna='8~15', plotrange=[0,0,-180,180],<br />
showgui=False, gridrows=4, gridcols=1, <br />
plotfile=asdm+'.scanphase.page2.png')<br />
# dummy_string = raw_input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='0~7', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page1.png')<br />
# dummy_string = raw_input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='8~15', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page2.png')<br />
# dummy_string = raw_input("Hit <Enter> to see next plot.")<br />
<br />
</source><br />
<br />
==Apply the Calibrations and Inspect ==<br />
Now we will use {{applycal}} to apply the bandpass, phase, and amplitude calibration tables that we generated in the previous sections to the data. We apply the solutions separately to the bandpass and secondary ("phase") calibrator 3c279, the flux calibrator Titan, and the target source. In most data sets, the bandpass and secondary calibrator will not be the same and this step would include one additional {{applycal}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
for asdm in basename_north: <br />
print "Applying calibrations for "+asdm<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='NGC*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_south: <br />
print "Applying calibrations for "+asdm<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Ant*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
</source><br />
<br />
Here:<br />
* '''vis''' and '''field''' specify the measurement set and field to calibrate.<br />
* '''gaintable''' specifies the tables to apply to the data. There may be several tables applied all at once, here we apply the bandpass, phase, and flux calibrations.<br />
* '''interp''' specifies the type of interpolation used to match calibration tables to the data. If there are several gaintables then interp may be either a single value (e.g., "linear" or "nearest") or a list of values with size equal to the list of gaintables. In the case where interp is a list, applycal will match each element to the corresponding gaintable (e.g., first gaintable with first interp parameter).<br />
* '''gainfield''' specifies field from which to draw the calibration. As with interp, this can be a list of size matched to gaintable, so that the first element of gainfield will be the field used for the first table. For example, in the above commands the bandpass calibration (the first table) will always be applied from '3c279' (the first gainfield).<br />
* '''calwt''' indicates that the weights, which were derived from the Tsys measurements, should also be calibrated. Note that '''calwt''' is True by default.<br />
<br />
Once calibrations are applied, it is important to go back and inspect the calibrated data. New problematic antennas or baselines may be visible after calibration. Repeat the steps above, focusing on the CORRECTED data column. Bear in mind that for any point source calibrators we now expect to find phase scattering around zero and to find flat amplitudes as a function of u-v distance. Look for outliers and other signatures of problematic data. As a general rule, you will want to incorporate these data into your overall flagging script then rerun the whole calibration process, so that reduction is iterative. If the data only represent a minor problem, however, it may not be terribly harmful to flag them after the fact so that they do not interfere with imaging but trust that the calibrations are mostly unaffected.<br />
<br />
As an example of this inspection, we cycle through the corrected amplitudes and phases of 3c279 and Titan as a function u-v distance, to check that the phases are close to zero and the amplitudes are constant. <br />
<br />
<figure id="xb-checkcal-pha-cha.png"><br />
[[File:Xb_phase_vs_chan_CASA5.7.png|200px|thumb|right|<caption> Calibrated phase vs. channel plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<figure id="xb-checkcal-amp-time.png"><br />
[[File:Xb_amp_vs_time_CASA5.7.png|200px|thumb|right|<caption> Calibrated amplitude vs. time plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print "Examining calibrated data for "+asdm<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='phase',<br />
ydatacolumn='corrected', field='3c279',<br />
avgchannel='3840', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
<br />
<br />
for asdm in basename_all:<br />
print "Examining calibrated data for "+asdm<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
In <xr id="xb-checkcal-pha-cha.png"/> and <xr id="xb-checkcal-amp-time.png"/> we plot phase vs. channel and amp vs. time for 3c279 for the uid___A002_X1ff7b0_Xb dataset. <br />
<br />
Finally we can use {{plotms}} to examine the corrected amplitude and phase of Antennae galaxies as a function of time and uv-distance (plots not shown):<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
for asdm in basename_north:<br />
print "Examining calibrated data for "+asdm<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
avgtime='1e8', avgscan=True, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
for asdm in basename_south:<br />
print "Examining calibrated data for "+asdm<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
avgtime='1e8', avgscan=True,avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = raw_input("Hit <Enter> for next plot.")<br />
</source><br />
<br />
==Split and Concatenate Data for Northern and Southern Mosaics==<br />
The individual data sets are now calibrated. We can safely split out the calibrated data for our science target and drop the calibrators. As we do so, we will smooth the data in frequency, averaging together groups of 23 channels by setting '''width=23''' in {{split}}. The new data will have a channel width corresponding to about ~10 km/s, very similar to the SMA data being verified. The factor of >20 drop in data volume will also make the imaging steps ''much'' more tractable.<br />
<br />
Note that you will see a warning that the last output channel in the new spw 0 will be dropped, as it has less than 23 channels over which to average:<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO MSTransformDataHandler The last output channel of spw 0 has only 22 input channels.<br />
WARN MSTransformManager Not enough input channels to populate output channel n# 166 from SPW 0.<br />
WARN MSTransformManager The channel will be dropped in order to have an uniform grid.<br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_north:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'NGC*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
<br />
for asdm in basename_south:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'Ant*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
</source><br />
<br />
For convenience we concatenate all data for the Northern Mosaic into a single big MS and place all data for the Southern Mosaic into another file. To do this, we construct a list that holds the names of all the Southern Mosaic MS files and another that holds the name of all the Northern Mosaic MS files then feed these into the {{concat}} task. <br />
<br />
Before we do this, we'll take a brief aside to remove Pointing information from the calibrated data. Normally, the pointing information would apply important corrections to be used while imaging the data. However, some aspects of this are still under development and the pointing information in these data interacts poorly with CASA. We will remove the pointing information using the CASA toolkit Table tool (tb). ''This kind of operation is dangerous and should not be a regular feature of your CASA reduction.''<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print "Manually removing pointing table from "+asdm+".cal.ms ... Please be careful!"<br />
tb.open(asdm+'.cal.ms/POINTING',nomodify=False)<br />
a = tb.rownumbers()<br />
tb.removerows(a)<br />
tb.close()<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
cal_south_vis = [vis+'.cal.ms' for vis in basename_south]<br />
cal_north_vis = [vis+'.cal.ms' for vis in basename_north]<br />
<br />
os.system('rm -rf Antennae_South.cal.ms')<br />
concat(vis=cal_south_vis, concatvis='Antennae_South.cal.ms', timesort=True)<br />
<br />
os.system('rm -rf Antennae_North.cal.ms')<br />
concat(vis=cal_north_vis, concatvis='Antennae_North.cal.ms', timesort=True)<br />
</source><br />
<br />
The syntax used to construct the 'cal_south_vis' variable loops over basename_south and makes a list after adding '.cal.ms' to each member. To see the list 'print cal_south_vis'.<br />
<br />
==Continue on to Imaging of the Science Target==<br />
Now you can continue on to the [http://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_5.7 imaging guide].<br />
{{Checked 5.7.0}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Calibration_6.1&diff=29412AntennaeBand7 Calibration 6.12020-10-01T19:24:24Z<p>Dkim: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide is written for CASA 6.1 and uses Python 3. The same functionality is implemented in Python 2 using CASA 5.7 at [[AntennaeBand7 Calibration 5.7]]'''<br />
<br />
*'''This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are provided at [[AntennaeBand7]]<br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see: [[AntennaeBand7_Imaging 6.1]]'''.<br />
<br />
==Overview==<br />
<br />
This part of the Antennae Band 7 CASA guide will step through the calibration of the visibility data. We will begin by flagging (marking as bad) data known to be useless before any inspection; for example, data where one telescope blocks the line of sight of another. We will then apply telescope-generated calibration tables to partially correct for atmospheric effects. After inspecting the data, we will flag some additional data that exhibit pathologies. Using observations of the calibrators Titan and 3c279, it will be shown how to derive the phase and amplitude response of individual antennas as a function of time and frequency ("phase", "amplitude", and "bandpass" calibrations). We will apply these solutions to the data and then extract the calibrated source data into a file appropriate for imaging in the [[AntennaeBand7_Imaging | Antennae Band 7 imaging guide]].<br />
<br />
The general procedure in this guide follows the other ALMA CASA guides: [[NGC3256Band3]] and [[TWHydraBand7]].<br />
<br />
==Unpack the Data==<br />
<br />
This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]. <br />
<br />
Once you have downloaded the data, unpack the file in a terminal outside CASA using<br />
<br />
<source lang="bash"><br />
<br />
tar -xvzf Antennae_Band7_UnCalibratedMSandTablesForReduction.tgz<br />
<br />
</source><br />
<br />
then change directory to the new directory <br />
<br />
<source lang="bash"><br />
<br />
cd Antennae_Band7_UnCalibratedMSandTablesForReduction<br />
<br />
</source><br />
<br />
You may wish to type<br />
<br />
<source lang="bash"><br />
<br />
ls<br />
<br />
</source><br />
<br />
to look at the files present. You should see a set of files with extension ".ms". These are CASA measurement set (MS) files. The data have already been converted to MS format from the native ALMA format using the CASA task {{importasdm}}. In addition to the data, we provide you with calibration tables containing system temperature (Tsys), water vapor radiometer (WVR), and antenna position information. For Early Science, these tables will either be pre-applied or supplied with the data.<br />
<br />
To begin, start CASA by typing<br />
<br />
<source lang="bash"><br />
<br />
casa<br />
<br />
</source><br />
<br />
Be sure that you are using the version indicated at the top of this page.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 6.1. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casalith<br />
version = casalith.version_string()<br />
print("You are using {}".format(version))<br />
if (version < '6.1'):<br />
print ("YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE.")<br />
print ("PLEASE UPDATE IT BEFORE PROCEEDING.")<br />
else:<br />
print ("Your version of CASA is appropriate for this guide.")<br />
</source><br />
<br />
==Initial Inspection==<br />
<br />
First we will take stock of what we have. If you have not already done so, begin by reviewing the description of the observations here: [[AntennaeBand7]]. The 10 data sets each target either the Northern or the Southern Mosaic, as follows:<br />
<br />
Northern Mosaic:<br />
*uid___A002_X1ff7b0_Xb.ms<br />
*uid___A002_X207fe4_X3a.ms<br />
*uid___A002_X207fe4_X3b9.ms<br />
*uid___A002_X2181fb_X49.ms<br />
<br />
Southern Mosaic:<br />
*uid___A002_X1ff7b0_X1c8.ms<br />
*uid___A002_X207fe4_X1f7.ms<br />
*uid___A002_X207fe4_X4d7.ms<br />
*uid___A002_X215db8_X18.ms<br />
*uid___A002_X215db8_X1d5.ms<br />
*uid___A002_X215db8_X392.ms<br />
<br />
The first step is to get basic information about the data: targets observed, time range, spectral setup, and so on. We do this using the task {{listobs}}, which will output a detailed summary of each dataset. Enter the following commands into CASA:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Define a python list holding the names of all of our data sets<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
# Initialize user-input string. (for Python testing)<br />
dummy_string = ''<br />
<br />
# Loop over each element in the list and create summary file using listobs<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.listobs.txt')<br />
listobs(vis=asdm+'.ms', listfile=asdm+'.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note that after cutting and pasting a 'for' loop like this you often have to press return twice to execute. You may also want to take care to paste a line at a time if you are having trouble copy and pasting. Even better, you can use "cpaste" to paste blocks of code. To do so type "cpaste" at the CASA prompt, paste your commands, and then type "--" and hit return on the final (otherwise empty) line. This should look something like this:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
CASA <8>: cpaste<br />
Pasting code; enter '--' alone on the line to stop.<br />
:basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
: "uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
: "uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
: "uid___A002_X215db8_X392"]<br />
:<br />
:for asdm in basename_all:<br />
: print (asdm)<br />
:--<br />
uid___A002_X1ff7b0_Xb<br />
uid___A002_X207fe4_X3a<br />
uid___A002_X207fe4_X3b9<br />
uid___A002_X2181fb_X49<br />
uid___A002_X1ff7b0_X1c8<br />
uid___A002_X207fe4_X1f7<br />
uid___A002_X207fe4_X4d7<br />
uid___A002_X215db8_X18<br />
uid___A002_X215db8_X1d5<br />
uid___A002_X215db8_X392<br />
<br />
CASA <9>: <br />
<br />
</pre><br />
<br />
cpaste should be ''much'' more robust than copying-and-pasting directly into the shell but if you have trouble, just carefully paste one line at a time directly into CASA and hit return until the desired command executes.<br />
<br />
These commands define a python list called "basename_all", which contains the name of all 10 MS files. The "for" loop executes for each element in basename_all, calling listobs and directing the output to a file called, e.g., "uid___A002_X1ff7b0_Xb.listobs.txt" for the first measurement set. You can browse through the listobs output as you would normally look at a text file (use emacs, vi, or another editor). You can also send the output to the terminal from inside of CASA. To do so type:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
or<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('more uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
CASA knows a few basic shell commands like 'cat', 'ls', and 'rm' but for more complex commands you will need to run them inside 'os.system("command")'. For more information see http://casa.nrao.edu/ .<br />
<br />
Here is an example of the (abridged) output from {{listobs}} for the first dataset in the list, uid___A002_X1ff7b0_Xb.ms, which targets the Northern Mosaic. You would see this if you had specified '''verbose''' to be False in the listobs call:<br />
<br />
<pre style="background-color: #fffacd;"><br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_Xb.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA(11 antennas)<br />
Data records: 181357 Total integration time = 4931.71 seconds<br />
Observed from 28-May-2011/01:25:27.6 to 28-May-2011/02:47:39.3 (UTC)<br />
<br />
Fields: 26<br />
ID Code Name RA Decl Epoch SrcId nRows <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 39116 <br />
1 none Titan 12:42:43.94813 -01.43.38.3190 J2000 1 10626 <br />
2 none NGC4038 - Antennae *12:01:53.17008 -18.52.37.9200 J2000 2 4818 <br />
3 none NGC4038 - Antennae *12:01:51.90301 -18.51.49.9437 J2000 2 6435 <br />
4 none NGC4038 - Antennae *12:01:52.43086 -18.51.49.9437 J2000 2 6424 <br />
5 none NGC4038 - Antennae *12:01:52.95871 -18.51.49.9437 J2000 2 5478 <br />
6 none NGC4038 - Antennae *12:01:53.48656 -18.51.49.9436 J2000 2 6435 <br />
7 none NGC4038 - Antennae *12:01:54.01441 -18.51.49.9436 J2000 2 6446 <br />
8 none NGC4038 - Antennae *12:01:52.16693 -18.51.56.4319 J2000 2 6435 <br />
9 none NGC4038 - Antennae *12:01:52.69478 -18.51.56.4318 J2000 2 6424 <br />
10 none NGC4038 - Antennae *12:01:53.22263 -18.51.56.4318 J2000 2 6446 <br />
11 none NGC4038 - Antennae *12:01:53.75049 -18.51.56.4318 J2000 2 6446 <br />
12 none NGC4038 - Antennae *12:01:51.90301 -18.52.02.9201 J2000 2 6435 <br />
13 none NGC4038 - Antennae *12:01:52.43086 -18.52.02.9200 J2000 2 6424 <br />
14 none NGC4038 - Antennae *12:01:52.95871 -18.52.02.9200 J2000 2 4818 <br />
15 none NGC4038 - Antennae *12:01:53.48656 -18.52.02.9200 J2000 2 4829 <br />
16 none NGC4038 - Antennae *12:01:54.01441 -18.52.02.9199 J2000 2 4829 <br />
17 none NGC4038 - Antennae *12:01:52.16694 -18.52.09.4082 J2000 2 4829 <br />
18 none NGC4038 - Antennae *12:01:52.69479 -18.52.09.4082 J2000 2 4829 <br />
19 none NGC4038 - Antennae *12:01:53.22264 -18.52.09.4082 J2000 2 3872 <br />
20 none NGC4038 - Antennae *12:01:53.75049 -18.52.09.4081 J2000 2 4829 <br />
21 none NGC4038 - Antennae *12:01:51.90301 -18.52.15.8964 J2000 2 4829 <br />
22 none NGC4038 - Antennae *12:01:52.43087 -18.52.15.8964 J2000 2 4829 <br />
23 none NGC4038 - Antennae *12:01:52.95872 -18.52.15.8963 J2000 2 4818 <br />
24 none NGC4038 - Antennae *12:01:53.48657 -18.52.15.8963 J2000 2 4818 <br />
25 none NGC4038 - Antennae *12:01:54.01442 -18.52.15.8963 J2000 2 4840 <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 354971.074 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 354916.143 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11 'name'='station' <br />
ID= 0-3: 'DV02'='A015', 'DV04'='J505', 'DV06'='T704', 'DV07'='A004', <br />
ID= 4-7: 'DV08'='A072', 'DV09'='A008', 'DV10'='A009', 'DV11'='A016', <br />
ID= 8-10: 'PM01'='T702', 'PM02'='A017', 'PM03'='J504'<br />
================================================================================<br />
<br />
</pre><br />
<br />
And here is an extract from the full '''verbose''' {{listobs}} for uid___A002_X1ff7b0_X1c8.ms, which targets the Southern Mosaic (note that we have snipped out the record of individual scans):<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_X1c8.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA<br />
Data records: 175615 Total integration time = 4927.1 seconds<br />
Observed from 28-May-2011/02:50:18.2 to 28-May-2011/04:12:25.3 (UTC)<br />
<br />
<snip><br />
<br />
Fields: 33<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 12232 <br />
1 none Titan 12:42:44.82765 -01.43.41.4224 J2000 1 10615 <br />
2 none 3c279 12:56:11.16600 -05.47.21.5250 J2000 2 27764 <br />
3 none Antennae 12:01:53.17008 -18.52.37.9200 J2000 3 4829 <br />
4 none Antennae 12:01:52.18699 -18.53.30.3952 J2000 3 3883 <br />
5 none Antennae 12:01:52.64413 -18.53.26.6494 J2000 3 3883 <br />
6 none Antennae 12:01:53.10127 -18.53.22.9035 J2000 3 3872 <br />
7 none Antennae 12:01:53.55841 -18.53.19.1577 J2000 3 4818 <br />
8 none Antennae 12:01:54.01554 -18.53.15.4119 J2000 3 4829 <br />
9 none Antennae 12:01:54.47268 -18.53.11.6661 J2000 3 4829 <br />
10 none Antennae 12:01:54.92982 -18.53.07.9203 J2000 3 3872 <br />
11 none Antennae 12:01:55.38696 -18.53.04.1744 J2000 3 3883 <br />
12 none Antennae 12:01:55.84409 -18.53.00.4286 J2000 3 4840 <br />
13 none Antennae 12:01:56.30123 -18.52.56.6828 J2000 3 4818 <br />
14 none Antennae 12:01:52.18700 -18.53.22.9033 J2000 3 4829 <br />
15 none Antennae 12:01:52.64414 -18.53.19.1575 J2000 3 4818 <br />
16 none Antennae 12:01:53.10128 -18.53.15.4116 J2000 3 4818 <br />
17 none Antennae 12:01:53.55842 -18.53.11.6658 J2000 3 4840 <br />
18 none Antennae 12:01:54.01555 -18.53.07.9200 J2000 3 3872 <br />
19 none Antennae 12:01:54.47269 -18.53.04.1742 J2000 3 4829 <br />
20 none Antennae 12:01:54.92983 -18.53.00.4284 J2000 3 4829 <br />
21 none Antennae 12:01:55.38697 -18.52.56.6825 J2000 3 4829 <br />
22 none Antennae 12:01:55.84410 -18.52.52.9367 J2000 3 4829 <br />
23 none Antennae 12:01:51.72988 -18.53.19.1572 J2000 3 4818 <br />
24 none Antennae 12:01:52.18702 -18.53.15.4114 J2000 3 4829 <br />
25 none Antennae 12:01:52.64415 -18.53.11.6656 J2000 3 4829 <br />
26 none Antennae 12:01:53.10129 -18.53.07.9197 J2000 3 2266 <br />
27 none Antennae 12:01:53.55843 -18.53.04.1739 J2000 3 2266 <br />
28 none Antennae 12:01:54.01557 -18.53.00.4281 J2000 3 3212 <br />
29 none Antennae 12:01:54.47270 -18.52.56.6823 J2000 3 3234 <br />
30 none Antennae 12:01:54.92984 -18.52.52.9365 J2000 3 3212 <br />
31 none Antennae 12:01:55.38698 -18.52.49.1906 J2000 3 2266 <br />
32 none Antennae 12:01:55.84411 -18.52.45.4448 J2000 3 3223 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 356845.586 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 356900.518 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11:<br />
ID Name Station Diam. Long. Lat. <br />
0 DV02 A015 12.0 m -067.45.15.3 -22.53.26.0 <br />
1 DV04 J505 12.0 m -067.45.18.0 -22.53.22.8 <br />
2 DV06 T704 12.0 m -067.45.16.2 -22.53.22.1 <br />
3 DV07 A004 12.0 m -067.45.15.9 -22.53.28.0 <br />
4 DV08 A072 12.0 m -067.45.12.6 -22.53.24.0 <br />
5 DV09 A008 12.0 m -067.45.15.4 -22.53.26.8 <br />
6 DV10 A009 12.0 m -067.45.16.1 -22.53.26.1 <br />
7 DV11 A016 12.0 m -067.45.16.4 -22.53.25.1 <br />
8 PM01 T702 12.0 m -067.45.18.6 -22.53.24.1 <br />
9 PM02 A017 12.0 m -067.45.15.9 -22.53.26.8 <br />
10 PM03 J504 12.0 m -067.45.17.0 -22.53.23.0 <br />
</pre><br />
<br />
This output shows that three sources were observed in each data set: 3c279, Titan, and the Antennae.<br />
<br />
* The '''Antennae''' are our science target. Note that the source name changes between the Northern Mosaic, where it is "NGC4038 - Antennae", and the Southern Mosaic, where it is just "Antennae". Also note that the source corresponds to a number of individual fields (see the Field ID column). These are the individual mosaic pointings. There are 23 for the Northern Mosaic and 29 for the Southern Mosaic.<br />
* '''Titan''' is observed once and will be used to set the absolute flux scale of the data.<br />
* '''3c279''' plays two roles: it will serve as our bandpass calibrator, to characterize the frequency response of the antennas, and because it is fairly close on the sky to the Antennae (18.6 degrees away) it will serve as our secondary calibrator (also referred to as the "phase calibrator" or "gain calibrator"), to track changes in the phase and amplitude response of the telescopes over time. Observations of 3c279 are interleaved with observations of the Antennae.<br />
<br />
The output also shows that the data contain many spectral windows. Using the labeling scheme in the listobs above these are:<br />
<br />
* '''spw 0''' targets ~185 GHz and holds water vapor radiometer data<br />
* '''spw 1''' and '''spw 3''' hold our science data. These are "Frequency Domain Mode" (FDM) data with small (0.49 MHz) channel width and wide (1.875 GHz) total bandwidth. As a result these have a lot of channels (3840). spw 1 holds the lower sideband (LSB) data and includes the CO(3-2) line. We will focus on these data. For the CO(3-2) line the channel width corresponds to 0.426 km/s and the bandwidth of spw 1 to 1634 km/s.<br />
* '''spw 2''' and '''spw 4''' hold frequency-averaged versions of spw 1 and 3 ("Channel 0" for those familiar with AIPS). These are used for some quick automated inspection. We will not use them here but we will carry out an equivalent inspection using spw 1.<br />
* '''spw 5''' and '''spw 7''' hold lower a resolution processing ("Time Domain Mode", TDM) of the data from the same part of the spectrum (baseband) as spws 1 and 3. These data have only 128 channels across 2 GHz bandwidth and so have a much coarser channel spacing than the FDM data. These were used to generate the calibration tables that we include in the tarball but will not otherwise appear in this guide.<br />
<br />
The final column of the listobs output in the logger (not shown above) gives the scan intent. Later we will use this information to flag the pointing scans and the hot and ambient load calibration scans.<br />
<br />
We'll now have a look at the configuration of the antennas used to take the data using the task {{plotants}} (<xr id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"><br />
[[File:Uid_A002_X1ff7b0_Xb.ANT_6.1.png|200px|thumb|right|<caption> Position of antennas in dataset uid_A002_X1ff7b0_Xb obtained using task plotants. </caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Antenna configuration for : "+asdm)<br />
plotants(vis=asdm+'.ms', figfile=asdm+'.plotants.png')<br />
clearstat()<br />
dummy_string = input("Hit <Enter> to see the antenna configuration for the next data set.")<br />
</source> <br />
<br />
This will loop through all 10 data sets, show you the antenna position for each, and save that as a file named, e.g., "uid___A002_X1ff7b0_Xb.plotants.png" for the first data set. The "input" command asks CASA to wait for your input before proceeding. If you would prefer to just browse the .png files after the fact you can remove this. Notice that the antenna setup changes, but only slightly, over the course of the 10 data sets.<br />
<br />
==How to Deal With 10 Measurement Sets==<br />
<br />
It should already be clear from the initial inspection that dealing with 10 data sets at the same time can be a bit problematic. This is especially tricky in our case because the Antennae data contain two distinct sets of observations: the Northern and Southern Mosaics. The source name changes between these two scripts and there are different numbers of fields in the mosaic.<br />
<br />
''As a general rule one would reduce each individual observation separately or at the very least only group data observed in a uniform way and very close in time.'' <br />
<br />
Unfortunately, a CASA Guide stepping through the reduction for each of 10 data sets would quickly become unwieldy. Therefore we will use a few tricks to reduce the Antennae data in a kind of batch mode. You have already seen the first trick: we can define a python list holding the names of each data set and then loop over this list to execute the same command on each data set. For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print (asdm)<br />
</source><br />
<br />
You only need to define your list of MS files once per CASA session. Then "basename_all" will be a variable in the casapy shell. You can check if it exists by typing "print (basename_all)". In the interests of allowing you to easily exit and restart CASA and pick this guide up at any point we will redefine "basename_all" in each section of the guide. Feel free to skip this step if you've already defined it in your session.<br />
<br />
This page will step you through the reduction of the whole Antennae Band 7 SV data set using these 'for' loops. We will not be able to show every diagnostic plot but we give an example of each and the syntax to generate the rest. Also please be aware that even on a very fast machine this whole process can take a while, we are simply dealing with a lot of data.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
One potential "gotcha" is that the source name changes between the two data sets. Therefore at several points we will break apart our loop to iterate separately over the Northern and Southern Mosaics, where the source can be referred unambiguously. Another subtle point is that 3c279 appears with two distinct field IDs in the Southern Mosaic, but only one in the Northern Mosaic. We will largely avoid this by referring to the source by its name but if you tried to use field ID numbers and mingled the two data sets this could cause confusion.<br />
</pre><br />
<br />
==''A Priori'' Flagging==<br />
<br />
Even before we look in detail, we know that there are some data that we wish to exclude. We will start by flagging "shadowed" data where one antenna blocks the line of sight of another. We will also flag scans that were used to carry out pointing and atmospheric calibration, identified by their scan intent. Finally, we'll flag the autocorrelation data (the correlation of the signal from an antenna with itself) as we are only interested in cross-correlation data to make an interferometric image.<br />
<br />
Start by defining our list of MS files:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
You may want to reset the flagging if you have tried this step before and are starting over though this is not necessary on your first time through. Do so using {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Resetting flags for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='unflag', flagbackup=False)<br />
</source><br />
<br />
Then flag shadowed data using the command {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging shadowed data for "+asdm)<br />
flagdata(vis=asdm+'.ms',mode = 'shadow', flagbackup = False)<br />
</source><br />
<br />
In the {{flagdata}} task we choose:<br />
<br />
* '''vis''' = asdm+'.ms' : each measurement set<br />
* '''mode''' = 'shadow': flag shadowed data<br />
* '''flagbackup''' = False: Do not automatically back up the flag files. We will save all of the ''a priori'' flags together using {{flagmanager}} at the end of this subsection and save some space and time.<br />
<br />
The relevant calibration information has already been extracted from the pointing and atmospheric scans and we will not need them below. Now flag the pointing scans using {{flagdata}} in 'manualflag' mode and selecting on 'intent':<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging calibration scans for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='manual', intent='*POINTING*', flagbackup = False)<br />
</source><br />
<br />
Note that because the atmospheric calibration scans contain only TDM spectral windows, they will be removed automatically when we separate out the FDM data below.<br />
<br />
Now flag the autocorrelation data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging autocorrelation data for "+asdm)<br />
flagdata(vis=asdm+'.ms',autocorr=True,flagbackup=False)<br />
</source><br />
<br />
Finally store the current flags information using {{flagmanager}}: <br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Backing up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'save', versionname = 'Apriori')<br />
</source><br />
<br />
Where '''versionname''' is just the name we assign to the current flagging state in the data. We can now roll back the flags to match the current version, called 'Apriori', whenever we want. There is no reason to do this now, but the syntax would be:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Restoring up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'restore', versionname = 'Apriori')<br />
</source><br />
<br />
<br />
It would have been possible to set {{flagdata}} to '''flagbackup'''=True so that it stores the flags at each of the flagging step automatically, but this way it is a bit more efficient with regard to time and disk space. More important, lumping all the ''a priori'' flagging together gives us a natural point to roll back to if we get in trouble.<br />
<br />
<br />
The flagmanager task will also allow you to view the saved flagging versions,<br />
including those created by running flagdata with flagbackup=True.<br />
<br />
For example try <br />
<br />
<source lang="python"><br />
# In CASA<br />
flagmanager(vis='uid___A002_X2181fb_X49.ms', mode='list')<br />
</source><br />
<br />
The output in the logger should list the Apriori flagging that we have applied.<br />
It will also indicate versions associated with any flagdata command where you<br />
did not set flagbackup=False. Other tasks, for example applycal, will also create<br />
flag version tables.<br />
<br />
==Create and Apply Tsys, WVR, and Antenna Position Calibration Tables==<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
===Tsys===<br />
<br />
The Tsys calibration gives a first-order correction for the atmospheric opacity as a function of time and frequency and associates weights with each visibility that persists through imaging.<br />
<br />
Use gencal to create the Tsys calibration tables from the spectral windows with CALIBRATE_ATMOSPHERE intents in listobs (i.e. the TDM spectral windows with 128 channels), these are spectral windows 5 and 7.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#Removing existing Tsys information<br />
os.system('rm -rf *tdm.tsys')<br />
for asdm in basename_all:<br />
print ("Creating TDM Tsys Table for "+asdm)<br />
gencal(vis=asdm+'.ms',caltable=asdm+'.tdm.tsys',spw='5,7',caltype='tsys')<br />
</source><br />
<br />
Later in the applycal stage this TDM Tsys table will be interpolated to the FDM (3840 channels per spw) science spectral windows 1 and 3.<br />
<br />
Next we inspect the Tsys tables for the spectral window '''spw''' = 5 with the task {{plotms}}. In previous CASA versions, we used {{plotcal}} for this task, but most of '''plotcal''''s functionality is now included in {{plotms}}, and '''plotcal''' will be deprecated in a future CASA release. We want to check that Tsys data have reasonable values and identify any unexpected features as a function of either time or frequency. To get an idea of sensible Tsys under average atmospheric observations consult the ALMA sensitivity calculator, accessible from http://www.almascience.org (via the "Documents & Tools" link).<br />
<br />
We start by plotting the Tsys for all the antennas and polarizations (XX and YY) as a function of time for each. <!--Here and throughout we focus on spw 1, which contains CO(3-2): --><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Note that right now, plotms can't select individual channels when plotting caltables (as was possible with plotcal). In addition, when iteraxis is set, plotms appends the axes being iterated over to the output filename specified in plotfile; this can make for rather unwieldy filenames (particularly when iteraxis='antenna'!) but is useful for the ALMA pipeline. <br />
</pre><br />
<br />
<figure id="Xb.Tsys_vs_time.page1.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page1.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 8 antennas. Note the high y-axis values for DV04. The two different colors indicate the two polarizations (XX and YY).</caption>]]<br />
</figure><br />
<figure id="Xb.Tsys_vs_time.page2.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page2.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting Tsys vs. time for "+asdm)<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='0~7',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page1.png',overwrite=True)<br />
#dummy_string = input("First eight antennas for "+asdm+" . Hit <Enter> to continue.")<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='8~15',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page2.png',overwrite=True)<br />
#dummy_string = input("Remaining antennas for "+asdm+" . Hit <Enter> to continue.")<br />
</source><br />
<br />
This sequence loops over all of our files and plots Tsys as a function of time for channel 50 in spectral window 5. In the call to {{plotms}}:<br />
<br />
* '''gridrows'''=4 and '''gridcols'''=2 sets up a 4 x 2 panel grid. <br />
* '''iteraxis'''='antenna' tells {{plotms}} to make a separate plot for each antenna.<br />
* '''spw'''='5:50~50' selects spw '5' channel 50-50. This allows us to cleanly separate time variations from frequency variations. '''Note that this is a functionality in plotcal but not yet in {{plotms}}, and plotms is actually showing all channels from spw 5 at this time.'''<br />
<br />
Because 8 panels (2 panels for each antenna - LSB and USB) is not enough to show all antennas on one page, there are two {{plotms}} calls: one for the first 8 antennas ('''antenna'''='0~7'), and then for the remaining antennas ('''antenna'''='8~15').<br />
<br />
The 'input' commands will wait for you to hit Enter before issuing the next plot command. In the example above these are commented out (the leading "#" means that CASA will ignore them). If you would like to interactively cycle through the plots, uncomment them by removing the "#". Otherwise, the '''plotfile''' parameter directs the output to .png files for later inspection. The easiest way to look at the 20 plots produced here is to simply inspect the .png files using your favorite viewer. As noted above, here plotms is adding the antenna information to the filenames because we set '''iteraxis''' = 'antenna', so check your directory for the impressively long filenames to view them. <br />
<br />
The Tsys values in <xr id="Xb.Tsys_vs_time.page1.6.1.png"/> and <xr id="Xb.Tsys_vs_time.page2.6.1.png"/> look reliable, with typical values ~150 K except for some large values of Tsys at ~400 and 500 K for DV04. We will flag the data for that antenna later. <br />
<br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV02.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 4 antennas. Note the high y-axis values for DV04 and the mesospheric line near 343.2 GHz.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV08.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Next 4 antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"><br />
[[File:uid___A002_X215db8_X392.tdm.tsys.3c279.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid___A002_X215db8_X392. Note the pathological behavior for DV12.</caption>]]<br />
</figure><br />
<br />
We will also want to look at Tsys as a function of frequency. <br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
os.system('rm -rf cal_plots/Tsys_plots/'+asdm+'.tdm.tsys*')<br />
tsysfields=['3c279','Titan','*Antennae*']<br />
caltable=asdm+'.tdm.tsys'<br />
for field in tsysfields:<br />
plotbandpass(caltable=caltable,yaxis='amp',field=field,xaxis='freq',<br />
showatm=True,overlay='time',<br />
figfile='cal_plots/Tsys_plots/'+caltable+'.'+field,<br />
buildpdf=False,interactive=False,chanrange='8~120',subplot=42)<br />
</source><br />
<br />
You will see the following statement in the logger, but this is fine: <br />
<br />
<pre style="background-color: #fffacd;"><br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
</pre><br />
<br />
Now have a look at the Tsys vs. frequency plots or see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/>, <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"/>, and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/> for examples on the first data set. You can see the effect of a close pair of atmospheric ozone absorption lines at about 343.2 GHz that makes Tsys larger near that frequency in all antennas. Applying the Tsys calibration tables will minimize the contribution of these atmospheric lines. Again DV04 stands out with its very high Tsys. Although not present in the first data sets, Antenna DV12 exhibits periodic spikes in Tsys vs. frequency for one polarization (see <xr id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"/> for an example from a later data set). It may or may not be possible to calibrate that behavior out. We will make a note to look carefully at DV12 further on in the calibration process.<br />
<br />
===WVR===<br />
The WVR calibration uses observations of the wings of the 183 GHz atmospheric water line to correct for phase variations as a function of time. As noted in the tsys section, this run of gencal will append to existing WVR produced tables. To avoid this, preexisting wvrgcal data is removed. <br />
<source lang="python"><br />
#In CASA<br />
#Removing existing WVR information<br />
os.system('rm -rf *.wvrgcal')<br />
for asdm in basename_all:<br />
wvrgcal(vis=asdm+'.ms',caltable=asdm+'.wvrgcal',toffset=-1)<br />
</source><br />
<br />
===Antenna Positions===<br />
<br />
In general, the most appropriate antenna positions for the dataset will be determined and updated if needed during QA2. If the antenna positions need to be updated after QA2, we inform the PIs of the affected datasets and provide instructions on how to update the antenna positions. For the data in this guide, we do need to update the antenna positions. <br />
<br />
The antenna position table reflects refinements in the measured positions of the antennas from those stored in the data. {{gencal}} will now be used put antenna position data into each observation. Again, {{gencal}} will merely append to existing antenna position data, ruining any subsequent results. We start by removing any existing antenna position refinements, followed by defining the antenna names, then their refinements (both as arrays), finally running {{gencal}} to create the information CASA can refer to for antenna positions.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_Xb.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:21]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3a.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3b9.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X2181fb_X49.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV01,DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
-0.00004, 0.00026, 0.00019, #DV01-A137<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_X1c8.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X1f7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X4d7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X18.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X1d5.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X392.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
</source><br />
<br />
===Applycal===<br />
<br />
We are now ready to apply the Tsys and the WVR calibration tables to the data with {{applycal}}, which reads the specified gain calibration tables, applies them to the (raw) data column, and writes the calibrated results into the corrected column. Again, we loop through all the datasets. It is important to only apply Tsys and WVR corrections obtained close in time to the data being corrected, so in addition to looping over data sets we define the list of unique source names and loop over these. Then by setting '''gainfield''' and '''field''' to the same value we ensure that Tsys and WVR calibrations are only applied to the source for which they are measured. Because the source has a different name in the Northern Mosaic and the Southern Mosaic, we will carry out two loops. We will only correct '''spw''' 1 and 3, our science windows, because we will drop the other data in a moment.<br />
<br />
The applycal task now has much more flexibility for interpolating and applying calibrations derived in one spectral window to another, even if they do not share the same spectral shape (number of channels and channel width). This new functionality is used below to interpolate the TDM (128 channel) Tsys measurements to the FDM (3840 channel) spectral windows. This is controlled through the spectral window mapping parameter *spwmap*. Because this can be a bit confusing, we've written a "helper" function that will tell you what you should put for the Tsys calibration table part of spwmap. We only need to run it on one of the datasets because they are all the same in this regard<br />
<br />
<source lang="python"><br />
# In CASA<br />
from casarecipes.almahelpers import tsysspwmap<br />
tsysspwmap(vis='uid___A002_X207fe4_X3a.ms',tsystable='uid___A002_X207fe4_X3a.tdm.tsys')<br />
</source><br />
<br />
This will print to your screen: [0, 5, 5, 7, 5, 5, 5, 7]. Recall that the TDM spectral windows are spw=5 and 7 and the FDM spectral windows are 1 and 3. This spwmap tells applycal to use the Tsys information in spectral window 5 for spectral window 1; and to use the information in spectral window 7 for spectral window 3. Beyond that, it is only important that there are placeholders for the other spectral windows, its also useful to note that you need not give placeholders for spectral window ids larger than the largest spectral window you need to use, in this case 7.<br />
<br />
You will also need to put in placeholders for other tables that you give the gaintables. So if the Tsys table is 2nd in the list, spwmap=[[],[0,5,5,7,5,5,5,7],[]]<br />
<br />
Now run the applycal commands.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# A new list of file names that contain only data from the Northern Mosaic<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names_north = ['Titan','3c279','NGC*']<br />
<br />
for asdm in basename_north:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_north:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=['',field,field],<br />
interp=['','linear,spline','nearest'], <br />
gaintable=[asdm+'.antpos',asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]],<br />
flagbackup=False, calwt=True)<br />
<br />
# A new list of file names that contain only data from the Southern Mosaic<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names_south = ['Titan','3c279','Ant*']<br />
<br />
for asdm in basename_south:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_south:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=["",field,field],<br />
interp=['','linear,spline','nearest'],<br />
gaintable=[asdm+".antpos",asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]], <br />
flagbackup=False, calwt=True)<br />
</source><br />
<br />
where:<br />
<br />
*'''field''': the field ''to'' which we will apply the calibration, <br />
*'''gainfield''': the field ''from'' which we wish to take the calibration table<br />
*'''interp''' = 'nearest' : apply the nearest solution from the calibration table rather than interpolating.<br />
<br />
As you browse through the whole data set, you will probably note some problems along the same lines as the DV04 issue we saw above. We'll apply these as additional data flagging in just a moment.<br />
<br />
==Inspect Data==<br />
We are not quite done with the original ".ms" data sets yet. Before going further it will be useful to use {{plotms}} to show the effects of applying the calibration. In the process we'll take a quick look at each antenna and search for pathologies in the data.<br />
<br />
For this basic inspection, we want to compare the phase and amplitude as a function of frequency and time in the DATA and CORRECTED columns of each measurement set. The CORRECTED column has had the Tsys and WVR calibrations applied and so we expect lower phase scatter and flatter amplitude response as a function of time and frequency. We are looking for antenna-based issues, so cycling through a set of baselines that includes each antenna once will be a good start. We'll focus these plots on the phase+bandpass calibrator, 3c279, and on baselines that include antenna DV11, which we will make our reference antenna in just a bit.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
Each CASA Measurement Set has up to three "columns" of data: DATA, CORRECTED, and MODEL (though it is possible<br />
for a MS to hold only a DATA column if it has not been processed at all). <br />
<br />
A column entry exists for each data point (baseline, frequency, time). <br />
<br />
The DATA column holds the current raw data, though using split as we just did we can change the definition of<br />
"raw" data. <br />
<br />
The CORRECTED column holds the result of applying one or more calibration tables (e.g., via applycal) to the<br />
DATA column and so represents a corrected version of the DATA column. <br />
<br />
The MODEL column is now deprecated (though it is still possible to use it by explicitly setting usescratch=True).<br />
Instead, the model is stored in the header of the ms. This is a great step forward in terms of saving space and time <br />
to create scratch columns <br />
<br />
To get an intuitive feel for the columns you may wish to explore using plotms (which can plot different data <br />
columns, as seen below) or the browsetable task.<br />
<br />
</pre><br />
<br />
<figure id="plotms_amp_vs_freq_example-data.png"><br />
[[File:plotms_amp_vs_freq_example-data_6.1.png|200px|thumb|right|<caption> Example of Amplitude vs. Frequency before correction for the 3c 279.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_example-corr.png"><br />
[[File:plotms_amp_vs_freq_example-corr_6.1.png|200px|thumb|right|<caption> Same baseline as Figure 8 but now after correction using WVR and Tsys calibrations.</caption>]]<br />
</figure><br />
<br />
First, we plot amplitude as a function of frequency for 3c279. We start by plotting the DATA column, set color to indicate the two correlations (i.e., the XX and YY polarizations), and ask plotms to iterate over baseline. By setting '''antenna''' to 'DV11&*' we select only baselines that include DV11. We ask plotms to average all data over a very long timescale, '''avgtime''' = 1e8 seconds ~ 3 years or much longer than the time spanned by the whole data set. By setting '''avgscan''' = True we allow {{plotms}} to average across scan boundaries. The result is a plot of average amplitude per channel vs. frequency.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
asdm=basename_all[0]<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='amp',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Notice the green arrows along the bottom of the {{plotms}} window. We asked {{plotms}} to iterate over baseline. As you click the arrows, the plot will rotate from baseline to baseline, always with DV11 so that each antenna shows up once. To see the effect of the calibration, go to the "Axes" tab along the left of the {{plotms}} window and pull down the Data Column menu under the Y Axis. Set this from DATA to CORRECTED and you should see the effects of the calibration. You may need to ensure that the "Force Reload" box is checked before clicking "Plot" (both buttons lie at the bottom of the panel). For the most part things get better (flatter), but as we noted before DV04 is problematic.<br />
<br />
<figure id="plotms_amp_vs_time_north.png"><br />
[[File:plotms_amp_vs_time_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_time_south.png"><br />
[[File:plotms_amp_vs_time_south_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a southern mosaic data set.</caption>]]<br />
</figure><br />
<br />
You can now make analogous calls to examine the phase vs. frequency, amplitude vs. time, and phase vs. time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='phase',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='amp',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='phase',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Where:<br />
<br />
* '''spw''' is set to cover only channels 1200~1300 for the time plots in order to isolate time dependent variations from frequency-dependent behavior. Those 101 channels represent only a small part of the total spw 1 bandpass.<br />
* '''avgchannel''' set to a large number causes the plots of phase and amplitude vs. time to average data at all frequencies into a single point for each measurement.<br />
* '''coloraxis''' corr sets the colors to correspond to the two polarizations of the data.<br />
<br />
In each case, you will want to examine each baseline, alternating between the DATA and CORRECTED columns.<br />
<br />
This is a lot of data inspection and that's only for one of 10 data sets! You can iterate across the data by hand, updating "asdm" to refer to each data set in order and cycling between baselines and DATA/CORRECTED. It is also possible to script CASA to show you the key plots in succession (see the next block down). However you approach the infrastructure, you are looking for:<br />
<br />
* Improved scatter and lower variability in phase and amplitude vs. frequency and time. This indicates that the WVR and Tsys calibrations helped. <br />
* Sudden jumps in phase or amplitude as a function of either time or frequency. These may indicate problems with the antenna during that observation.<br />
* Large gradients, especially full wraps, in phase as a function of frequency. This may indicate a problem in the delays, the signal path length to the telescopes.<br />
* Unusual magnitude, scatter, or patterns in any plot - though this may be better explored using plots that show all data together, which we'll make in a moment.<br />
* Missing data. For example, if the phase calibrator drops out for a period of time we will not be able to calibrate and will need to flag the data.<br />
<br />
As you look through, note individual potentially problematic antennas. If ''all'' antennas in a data set appear problematic it may be that your "reference" antenna, DV11 in the example above, is the source of the problem. In this case swap this reference antenna for another and see whether the problem is isolated to your original reference antenna.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
A brief aside on structure:<br />
<br />
This section (Data Inspection) and the next (Apply Flags) are closely linked. We will present them as two<br />
separate steps. The idea here is that you look through your data, note problems, and then write commands to<br />
flag problematic data. This mimics one approach to writing data reduction scripts for CASA, where you will<br />
group all flagging together into one convenient place. Other CASA guides take a different approach, interleaving <br />
flagging and plotting. There is no "right" answer here. Find an approach to data inspection that works for you.<br />
<br />
</pre><br />
<br />
If you do wish to semi-automate the plot generation, the following sequence will cycle between data and corrected plots for each data set in turn. Type "stop" at any input call to break out.<br />
<br />
<!--<br />
'''Note:''' In loops like this involving {{plotms}}, hitting enter before the last dataset completes loading may cause {{plotms}} to stop refreshing the plot window at each step, or cause the window to disappear altogether. This will be fixed in an upcoming CASA release. Right now, you may need to exit CASA and restart to bring up the {{plotms}} window again, but you should be able to continue in the script where you left off.<br />
--><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
user_input = ""<br />
for asdm in basename_all:<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
# Extract antenna list for this data set.<br />
tb.open(asdm+'.ms/ANTENNA', nomodify=True)<br />
ants = tb.getcol('NAME')<br />
tb.close<br />
# Define the reference antenna to make baselines with<br />
ref_ant = 'DV11'<br />
# Loop over antennas<br />
for ant in ants:<br />
# Check if the user wants to stop<br />
if user_input == "stop":<br />
break<br />
# Skip correlation of reference antenna with itself (autocorrelations are flagged anyhow) <br />
if ant == ref_ant:<br />
continue<br />
# Define the baseline with the reference antenna for current antenna<br />
ant_str = ref_ant+'&'+ant<br />
print ("Showing baseline "+ant_str+" for data set "+asdm)<br />
print ("Use this to inspect effect of applying wvrcal and Tsys calibrations.")<br />
# Loop over phase and amplitude as axes<br />
for y_axis in ["amp", "phase"]:<br />
# Make 'before' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'before' plot for time x-axis<br />
print ("... "+y_axis+" vs. time for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for time y-axis<br />
print ("... "+y_axis+" vs. time for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<figure id="plotms_amp_vs_uvdist_north.png"><br />
[[File:plotms_amp_vs_uvdist_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. uv-distance for 3c279 in the first northern mosaic data set.</caption>]]<br />
</figure><br />
<br />
<figure id="plotms_amp_vs_freq_3c279.png"><br />
[[File:plotms_amp_vs_freq_3c279_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for 3c279 in the second northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Titan.png"><br />
[[File:plotms_amp_vs_freq_Titan_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for Titan in the second northern mosaic data set. Note the strong line (this is CO 3-2)!</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Antennae.png"><br />
[[File:plotms_amp_vs_freq_Antennae_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for the Antennae in the second northern mosaic data set. The CO(3-2) line is visible.</caption>]]<br />
</figure><br />
<br />
A detailed explanation of the procedure is a bit outside the scope of this guide (for more on python see http://www.python.org/ and for more on the CASA toolkit see http://casa.nrao.edu/), but the basic process is to loop over each data set, baseline with the reference antenna (here DV11), and y-axis of interest (phase or amplitude) then plot the effect of the calibration vs. frequency and time for each combination. Running this to step through the data will give you about 200 "before and after" plots from which you could note a subset of problematic cases to be followed up by hand. Many other strategies to inspect the data are also viable.<br />
<br />
With the Tsys and WVR calibrations applied successfully and the ''a priori'' flagging taken care of we will now {{split}} out the corrected data. We will keep only the corrected data, specified via '''datacolumn''', and only spectral window 1, which contains the FDM (high spectral resolution) observations of the CO(3-2) line. Setting '''keepflags'''=False tells {{split}} not to carry over any fully flagged rows from the original data set to the new MS. We give the new MS files the extension ".wvrtsys.ms" to indicate that they have been corrected for WVR and Tsys effects. Because split will not overwrite existing files, we remove any previous versions of the new MS before beginning.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm -rf '+asdm+'.wvrtsys.ms')<br />
print ("Splitting out corrected data for "+asdm)<br />
split(vis=asdm+'.ms', outputvis=asdm+'.wvrtsys.ms', <br />
datacolumn='corrected', spw='1', keepflags=False)<br />
</source><br />
<br />
Be patient, {{split}} may take awhile. The WVR and Tsys-corrected data now sit in the DATA column of the new measurement sets, which have only one spectral window (now labeled spectral window 0 though it was spectral window 1 in the original data). You may wish to run {{listobs}} to illustrate the changes:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.wvrtsys.listobs.txt')<br />
listobs(vis=asdm+'.wvrtsys.ms', listfile=asdm+'.wvrtsys.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note the new spectral window information:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
2011-08-05 01:07:08 INFO listobs Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
2011-08-05 01:07:08 INFO listobs SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
2011-08-05 01:07:08 INFO listobs 0 3840 TOPO 344845.586 488.28125 1875000 344908.33 XX YY <br />
<br />
</pre><br />
<br />
<br />
Next we will do a bit more inspection using {{plotms}} to look at whole data sets. This will help us identify missing data or look for egregious outliers.<br />
<br />
First we plot amplitude versus time (see <xr id="plotms_amp_vs_time_north.png"/> and <xr id="plotms_amp_vs_time_south.png"/>), averaging over all channels (by setting '''avgchannel''' to the very large value 10,000). We colorize by field so that scans on Titan are red, the bandpass and phase calibrator 3c279 is black (and orange in the Southern Mosaic where it has two field IDs), and the Antennae mosaic appears as a range of colors (one per pointing).<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='amp', <br />
avgchannel='3840',coloraxis='field', showgui = True)<br />
user_input = input("Examining amplitude vs. time for "+asdm+" . Hit <Enter> to proceed.[type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
Here look for:<br />
<br />
* Missing data. The source needs to be flanked by phase calibrator scans, if those are missing for any reason we need to flag the appropriate time range.<br />
* Dramatic outliers. Does the source suddenly get very bright or the otherwise bright calibrator appear anomalously faint for a brief time? This likely indicates problematic data that should be identified and flagged. You can use the "select" (box with green plus along the bottom row in plotms) and "locate" (magnifying glass) buttons in {{plotms}} to isolate and identify problem data (it will print to the log).<br />
* Smooth variation with time. A sudden jump may indicate a problem and often the safest approach is to flag data near a discontinuity.<br />
<br />
Look through the amplitudes vs. time for each data set (remember that we've already examined the phases vs. time and amplitude vs. time for individual baselines above).<br />
<br />
There are two other very useful "averaging" plots worth making. First, we plot amplitude as a function of u-v distance (projected antenna separation). Discontinuities and spikes in this plot are often from non-astrophysical sources. In the phase analog to the plot, the effects of atmospheric decorrelation can be assessed from increased scatter at longer u-v distances. While using the moon Titan as our flux calibrator, we may want to watch for flaring amplitudes at short u-v distances. These may indicate that Saturn is contaminating our beam. For a perfect, bright point source, we expect flat amplitudes as a function of u-v distance at the source amplitudes. <xr id="plotms_amp_vs_uvdist_north.png"/> shows an example of this plot, generated via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='3c279',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. UV Distance for 3c279 for "+asdm+" . Hit <Enter> to proceed.")<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='Titan',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
user_input = input("Examining amplitude vs. UV Distance for Titan for "+asdm+" . Hit <Enter> to proceed [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
<br />
<br />
It can also be useful to examine the average amplitude as a function of frequency for each target. This allows one to check for lingering atmospheric effects, unexpected line emission or absorption in the calibrators, or decreased sensitivity due to "roll-off" of the telescope sensitivity at the band edges. These plots are created by the sequence of commands below, where we have broken up the script to loop separately over the Northern and Southern Mosaics to reflect the different source names.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names = ["3c279","Titan","NGC*"]<br />
<br />
for asdm in basename_north:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+". Hit <Enter> to proceed.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names = ["3c279","Titan","Ant*"]<br />
<br />
for asdm in basename_south:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+" . Hit <Enter> to proceed.")<br />
<br />
</source><br />
<br />
<br />
For this command notice that we can see the CO(3-2) line in the Antennae even before calibration (see <xr id="plotms_amp_vs_freq_Antennae.png"/>) and that Titan also shows evidence of a strong line (also <xr id="plotms_amp_vs_freq_Titan.png"/>)! This will need to be flagged before we can use Titan to calibrate the flux scale of our data.<br />
<br />
This suite of plots (along with the earlier inspection of the Tsys tables) gives us the tools we need to identify problematic data through the data sets. We use this to generate a set of inspection-driven {{flagdata}} commands for each data set. We apply these before the bandpass and gain calibration.<br />
<br />
==Apply Flagging==<br />
Based on this inspection and the other plots we have made, we now flag problematic portions of the data. We break up the flags by reason for flagging in order to illustrate the process. As you reduce your own data it may be more efficient to group flags by data set and make use of the flagcmd command. Except for the "post-calibration" flagging, the inspection plots that we just looked through have already revealed all of the problems that we flag. We structure the guide so that the flagging is grouped in one place.<br />
<br />
As before, we may wish to reset our flags before beginning (particularly if one iterates this process) via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms',mode='unflag', flagbackup = False)<br />
</source><br />
<br />
Remember that we dropped the flagged data when splitting out after the WVR and Tsys calibration, so this should not undo your "A Priori" flagging of shadowed data, autocorrelations, etc.. In any case this unflagging step is not necessary during the first iteration.<br />
<br />
* '''Edge Channels'''<br />
<br />
ALMA's sensitivity decreases near the edge of the baseband and it is often useful to check for a 'roll-off' in sensitivity near the edge of the band. This will appear as a downturn in amplitude as a function of channel near the edge of the window in the uncalibrated data, as a flaring due to increased noise at the spw edges in the calibrated data. It will also be visible in the amplitude part of the bandpass calibration table. Because our FDM spw does not cover the full baseband, we do not see a strong roll off in our data (see <xr id="amp_vs_channel_example.png"/>), where there is only a mild hint of a roll-off at the high end) but we do flag a (very) few channels at the high and low-frequency edge of the data set to be safe.<br />
<br />
<figure id="amp_vs_channel_example.png"><br />
[[File:amp_vs_channel_example.png|200px|thumb|right|<caption> Amplitude vs. channel for one uncalibrated antenna pair. This kind of plot can be inspected to get an idea of the presence or magnitude of any roll-off in sensitivity near the edges of the spectral window.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:0~7,0:3831~3839', flagbackup = False)<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:3260~3320', flagbackup = False)<br />
</source><br />
<br />
* '''Problematic Tsys measurements'''<br />
<br />
Above we noted issues with the Tsys measurements for both DV04 and DV12. We flag the affected data. Each of these issues should be visible in the Tsys plots you made above (e.g., see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/> and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/>).<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04',flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X1d5"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X392"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
</source><br />
<br />
* '''Unreliable Short-Spacing Measurements on Titan'''<br />
<br />
<figure id="amp_vs_uv_titan_obs.png"><br />
[[File:amp_vs_uv_titan_obs.png|200px|thumb|right|<caption> Observed amplitude vs. uv-distance for observations of Titan in the first data set. Note the scatter for low projected antenna separations. We will flag these short-spacing data, which may reflect contamination by Saturn, and use only the more extended baselines for flux calibration.</caption>]]<br />
</figure><br />
<br />
Saturn may contaminate the short u-v spacings from Titan. In any case these often show significant scatter (<xr id="amp_vs_uv_titan_obs.png"/>), so we flag them. There are still enough baselines to determine a good amplitude calibration for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~40', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
</source><br />
<br />
* '''Delay Issues''' <br />
<br />
<figure id="phase_vs_freq_DV13.png"><br />
[[File:phase_vs_freq_DV13.png|200px|thumb|right|<caption> Phase vs. frequency for DV13 in a data set where this antenna shows evidence of imperfect delay calibration.</caption>]]<br />
</figure><br />
<br />
DV13 and a few other antennas show signatures of an imperfect delay calibration. This is most easily identified via strong "wrapping" of phase as a function of frequency (see <xr id="phase_vs_freq_DV13.png"/>). Such effects can be calibrated out with mild delay issues largely accounted for by the bandpass solution. The phase wrapping in DV13 seems weak enough that we will trust the calibrations to remove it. For a more extreme example see the CASA guide describing the calibration of [[NGC3256Band3]].<br />
<br />
* '''Missing Phase Calibrator Observations'''<br />
<br />
<figure id="amp_vs_time_missing_scans.png"><br />
[[File:amp_vs_time_missing_scans.png|200px|thumb|right|<caption> Amplitude vs. time colored by field for a data set where the final visit to the phase calibrator is missing. We will flag the last set of source data to ensure that each visit to the source is flanked in time by visits to the phase calibrator.</caption>]]<br />
</figure><br />
<br />
As a general rule, we want to be sure that observations of the phase calibrator (3c279) bracket each source observation. Two of the data sets do not include a final phase calibrator observation (see <xr id="amp_vs_time_missing_scans.png"/>) and for those two cases we flag the affected source observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='00:53:47~01:08:00',flagbackup = False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV10',timerange='19:46:20~20:34:40',flagbackup=False)<br />
</source><br />
<br />
* '''Unexpected Scatter or Discontinuity in the Data'''<br />
<br />
For several antennas we find sudden jumps in the phase of the phase calibrator as a function of time. These are visible in the plots of uncalibrated phase vs. time for single baselines above, and we show an example in <xr id="phase_vs_time_DV09.png"/>. It will not be possible to effectively interpolate the phase between measurements when we see these discontinuities. The safest approach is to flag the source data across these jumps. We do so here (though note that the last two flaggings are borderline cases).<br />
<br />
<figure id="phase_vs_time_DV09.png"><br />
[[File:phase_vs_time_DV09.png|200px|thumb|right|<caption> Phase vs. time for DV09 on a problematic day. It may prove problematic to calibrate the data near this discontinuity so we flag data near this time.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09', timerange='21:24:09~21:35:35', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09',timerange='23:30:52~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM01',timerange='23:16:50~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM03',timerange='23:16:50~24:10:00',flagbackup=False)<br />
</source><br />
<br />
* '''Outliers Visible After Calibration'''<br />
<br />
<figure id="amp_vs_uvdist_outliers.png"><br />
[[File:amp_vs_uvdist_outliers.png|200px|thumb|right|<caption> Amplitude vs. u-v distance ''after'' calibration. Note the outlying data. We track these down using the select (box with green "+") and locate (magnifying glass) features inside plotms and identify several problematic baselines across our data. ''Note that you cannot make this plot at this point in the guide, these pathologies become evident after calibration, requiring an iterative approach to reduction.''</caption>]]<br />
</figure><br />
<br />
Often issues with the data may become evident after calibration (i.e., after the next few steps that we apply). These data can appear as outliers in diagnostic plots for the calibrated data or even show up in the imaging stages. Once these are identified, best practice is to apply this new flagging then redo the calibration (if the issue is very minor, then re-calibrating may not be necessary).<br />
<br />
<source lang="python"><br />
# In CASA<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='21:18:00~21:22:15', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV01&DV04', flagbackup=False)<br />
</source><br />
<br />
Now that we've applied our flagging, back up the flags as version "User" using {{flagmanager}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis=asdm+'.wvrtsys.ms',mode='save',versionname ='User')<br />
</source><br />
<br />
Applying this flagging will remove the most egregious pathologies from the data. We are now ready to calibrate the data.<br />
<br />
==Bandpass Calibration==<br />
<br />
We begin by calibrating the phase and amplitude response of each antenna as a function of frequency, called "bandpass calibration." We have already seen that the data contain smooth but systematic variations in both phase and amplitude as a function of frequency. We can see this again in a more compact form by plotting phase as a function of frequency for all baselines associated with each antenna (<xr id="plotms_phase_vs_freq_example.png"/>).<br />
<br />
<figure id="plotms_phase_vs_freq_example.png"><br />
[[File:plotms_phase_vs_freq_example_6.1.png|200px|thumb|right|<caption> Phase vs. frequency for the bandpass calibrator, 3c279 in the first data set. We plot all baselines with DV02, averaged over time, and show only the 'XX' correlation.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='freq', yaxis='phase', <br />
selectdata=True, field='3c279', correlation='XX',<br />
avgtime='1e8', avgscan=True, antenna='*&*',<br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. frequency for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
Each plot shows phase as a function of frequency for all baselines with one antenna for 3c279. We plot only the 'XX' correlation, colorizing by baseline. With '''iteraxis''' set to antenna the green arrows at the bottom of {{plotms}} will cycle through antennas. By using '''avgscan''' and a large '''avgtime''' we average all scans and integrations. <br />
<br />
The phase (and amplitude) also varies as a function of time, as we saw before. Here are the similar plots for phase vs. time (see <xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb-phasecont.png"><br />
[[File:Uid_A002_X1ff7b0_Xb-phasecont_6.1.png|200px|thumb|right|<caption> Phase vs. time for the bandpass calibrator, 3c279. Averaged over channel. Only baselines with antenna DV02, and corr='XX'</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='phase', <br />
selectdata=True, field='3c279', <br />
spw='0:1200~1299', antenna='*&*',correlation='XX',<br />
avgchannel='100', avgscan=True, <br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. time for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
<xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/> shows that the phase varies with time. We need to take this temporal variation into account when we solve for the frequency variations. Therefore we carry out the bandpass calibration in two steps. First, we use {{gaincal}} to solve for the variation of phase as a function of time for 3c279 on very short timescales. We set {{gaincal}} to derive a separate phase solution for each antenna every integration by setting '''solint''' to 'int'. We solve, averaging together only a small fraction of the total bandpass (channels 1100-1300) to avoid the effects of the phase vs. frequency behavior. We will then apply this solution to remove time-dependent behavior when we solve for the frequency response of the antennas with {{bandpass}}.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
An integration is the smallest time quantum of observation in the data, usually a few seconds. <br />
You can check the integration length for each scan in listobs. <br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
for asdm in basename_all:<br />
print ("Running a short solution interval phase calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bpphase.gcal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
selectdata=True,field = '3c279',spw = '0:1100~1300',<br />
caltable = asdm+'.bpphase.gcal',<br />
solint = 'int',refant = 'DV11',calmode='p')<br />
</source><br />
<br />
Now we use {{bandpass}} to solve for the frequency response of each antenna. To do this, we average all data in time by setting '''solint''' to 'inf' (that is, 'infinite'). We allow combination across scans and the different field IDs found for 3c279 by setting '''combine''' to "scan,field". We apply the phase vs. time calibration that we just derived on-the-fly using the parameter "gaintable".<br />
<br />
<source lang="python"><br />
for asdm in basename_all:<br />
print ("Running a bandpass calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bandpass.bcal')<br />
bandpass(vis = asdm+'.wvrtsys.ms',<br />
field = '3c279',<br />
gaintable = asdm+'.bpphase.gcal',<br />
caltable = asdm+'.bandpass.bcal',<br />
bandtype='B',<br />
solint = 'inf',combine = 'scan,field', solnorm=True,refant = 'DV11',<br />
minblperant=3,minsnr=2,fillgaps=62)<br />
</source><br />
<br />
in these calls:<br />
<br />
*'''caltable''' specifies the output calibration table<br />
*'''gaintable''' specifies any calibration tables to be applied "on the fly" to the data before solving.<br />
*'''solint''' sets the time interval for which solutions are derived for each antenna.<br />
*'''refant''' set the reference antenna, here DV11, which is defined to have zero correction by construction.<br />
*'''calmode''' 'p' sets {{gaincal}} to calibrate the phase only, other options are 'a'mplitude or 'ap' - amplitude and phase.<br />
*'''minblperant''' sets the minimum baselines required per antenna for a successful solution.<br />
*'''minsnr''' sets the minimum signal-to-noise ratio required for a successful solution.<br />
*'''bandtype''' here 'B' tells {{bandpass}} to solve for the phase and frequency response of each antenna in each channel, averaging data in time across the solution interval.<br />
*'''fillgaps''' tells {{bandpass}} to interpolate across channel gaps 1 channel wide.<br />
*'''solnorm''' tells {{bandpass}} to normalize the bandpass amplitude and phase corrections to have magnitude unity. The absolute scale of the calibration will come from our later {{gaincal}} solutions.<br />
<br />
Do not worry about the message "Insufficient unflagged antennas" when running the {{bandpass}} task. This indicates that {{bandpass}} is failing on the flagged edge channels, which is expected.<br />
<br />
It is now a good idea to plot both sets of solutions to look for irregularities, especially:<br />
<br />
* discontinuities in the phase vs. time solution<br />
* rapid wrapping of phase in either phase vs. time or bandpass solution<br />
* large roll-off in the amplitude response near the band edge in the bandpass solution<br />
* large scatter in any solution.<br />
<br />
We loop through and using analysis utils, again generating .png files of each calibration. '''For what systems is this true?''' As the bandpass plots take a while you may want to go have a cup of coffee and inspect them using your favorite image viewer. Otherwise, switch the '''interactive''' parameter to True to see them in real time instead.<br />
<br />
<figure id="uid___A002_X1ff7b0_X1c8.bpphase.page1.png"><br />
[[File:uid___A002_X1ff7b0_X1c8.bpphase.page1_6.1.png|200px|thumb|right|<caption> Short interval phase vs. time solution carried out and applied during bandpass calibration, here for the first set of antennas for the first data set. This solution removes any systematic variations in phase vs. time.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1.CASA3.4.png"><br />
[[File:Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1_6.1.png|200px|thumb|right|<caption> Bandpass amplitude solution for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X1ff7b0_Xb.bcal_phase.page1.png"><br />
[[File:uid___A002_X1ff7b0_Xb.bcal_phase.page1.png|200px|thumb|right|<caption> Phase vs. frequency calibration from the bandpass calibration for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<br />
<!--<br />
Again this warning:<br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
--><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
os.system('rm -rf cal_plots/*bandpass*.png')<br />
for asdm in basename_all:<br />
plotbandpass(caltable=asdm+'.bandpass.bcal',<br />
field='',xaxis='freq',yaxis='both',<br />
figfile='cal_plots/'+asdm+'.bandpass.png',<br />
showatm=True,interactive=False,subplot=42)<br />
</source><br />
<br />
==Absolute Flux Calibration==<br />
<br />
The bandpass calibration will account for the phase and amplitude response of our antennas as a function of frequency. We now solve for the absolute flux scale of the data by referencing to Titan and in the next section we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
Before using Titan to set the flux, there is an important systematic to account for. When we looked at the integrated spectra of our targets above, remember that Titan showed a whopping spectral line, in fact the same CO(3-2) line that we wish to observe in the Antennae. We will set the flux of Titan (and thus all of our data) by referencing to a model in casa that does not account for this line. Therefore we need to flag the part of the Titan observations contaminated by the line before we calibrate (you can see the affected channel range in <xr id="Antennae-TitanLine.png"/>). We run the following additional flagging step:<br />
<br />
<figure id="Antennae-TitanLine.png"><br />
[[File:Antennae-TitanLine_6.1.png|200px|thumb|right|<caption> Uncalibrated amplitude vs. channel plot for the flux calibrator, Titan (uid___A002_X1ff7b0_Xb dataset). Averaged over time, corr='XX', and colorized by baseline.</caption>]]<br />
</figure><br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Flagging CO(3-2) in Titan for "+asdm)<br />
flagdata(vis=asdm+'.wvrtsys.ms',flagbackup=False, <br />
field='Titan', spw='0:1100~1700')<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis =asdm+'.wvrtsys.ms',mode = 'save',versionname = 'Calibration')<br />
</source><br />
<br />
Next, we will use the {{setjy}} task to read the predicted complex visibilities for Titan into the MODEL column of each data set.<br />
<br />
<source lang="python"><br />
# in CASA<br />
for asdm in basename_all:<br />
print ("Reading model for Titan into "+asdm)<br />
setjy(vis = asdm+'.wvrtsys.ms',field = 'Titan',<br />
usescratch=True,scalebychan=True,<br />
standard = 'Butler-JPL-Horizons 2012')<br />
</source><br />
<br />
{{setjy}} will output the flux of Titan to the CASA logger and it is worth recording this information. The flux of Titan at these frequencies is about 3.3 Jy. For example, for dataset uid___A002_X1ff7b0_Xb.wvrtsys.ms:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Titan: spw0 Flux:[I=3.2637,Q=0.0,U=0.0,V=0.0] +/- [I=0.0,Q=0.0,U=0.0,V=0.0] Jy @ 344.85GHz<br />
</pre><br />
<br />
Now we are going to take a look at the Titan model for one dataset:<br />
<br />
<source lang="python"><br />
# in CASA<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
</source><br />
<br />
<figure id="2012_titan_model_5.1.png">[[File:2012_titan_model_6.1.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2012'.</caption>]]</figure><br />
<figure id="2010_titan_model.png">[[File:2010_titan_model.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2010'.</caption>]]</figure><br />
<br />
<br/><br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
The setjy invocation made in this section uses the flux density standard '''standard='Butler-JPL-Horizons 2012' '''. Previous versions of this guide used an older flux density standard '''standard='Butler-JPL-Horizons 2010' '''. <xr id="2012_titan_model_5.1.png"/> and <xr id="2010_titan_model.png"/> show the differences in the Titan models produced using these two standards. <br />
</div><br />
<br />
==Gain (Phase and Amplitude) Calibration==<br />
<br />
With the flux now properly scaled, we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
We begin by running a short-solution interval {{gaincal}} to solve for phase variation on short timescales during observations of our two calibrators, with '''solint''' set to "int". By applying this on-the-fly, we can remove any decorrelation in the data due to phase scatter when we solve for the amplitude calibration. However, there is no benefit to using this short-timescale solution to calibrate the source because we only have information on the gain during calibrator visits (though see the Imaging portion of this guide). Instead we will solve for the gains to apply to the source using a longer '''solint''' in just a moment.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out short timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.intphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.intphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='int',minsnr=2.0, minblperant=4)<br />
</source><br />
<br />
Now we derive the longer timescale phase calibration table using '''solint''' set to "inf", but not allowing scan combination. This calibration has higher signal to noise due to combining more data, and for the purposes of correcting the source, it is just as precise as the short timescale solution.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out longer timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.scanphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.scanphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='inf',minsnr=2.0,minblperant=4)<br />
</source><br />
<br />
Now we apply the short-timescale phase solution and carry out a scan length ('''solint''' set to "inf") calibration of the data using '''calmode''' of 'ap'.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Solving for longer (scan) interval amplitude solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.amp.cal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
gaintable =[asdm+'.bandpass.bcal',asdm+'.intphase.gcal'],<br />
caltable = asdm+'.amp.cal',<br />
calmode='ap',<br />
field = 'Titan,3c279',<br />
spw='0:40~3800',<br />
refant = 'DV11',solint = 'inf', minblperant=4)<br />
</source><br />
<br />
This "amp.cal" solution gives us the amplitude variations as a function of time, but they are not yet pinned to a realistic scale except in the case of Titan, where we have solved using the model input by {{setjy}}. We will set the flux of our secondary calibrator 3c279 with reference to Titan using {{fluxscale}}.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Scaling amplitude calibration to match Titan for "+asdm)<br />
os.system('rm -rf '+asdm+'.flux.cal')<br />
fluxscale(vis = asdm+'.wvrtsys.ms',<br />
caltable = asdm+'.amp.cal',<br />
fluxtable = asdm+'.flux.cal',<br />
reference = 'Titan',<br />
transfer = '3c279')<br />
</source><br />
<br />
This new correctly-scaled flux table ".flux.cal" replaces the previous ".amp.cal" table as the correct amplitude calibration table to apply to the data, i.e., the ".flux.cal" contains both the time variability of the amplitude solved for in ".amp.cal" and the correct flux scaling set with {{fluxscale}}.<br />
<br />
Fluxscale will output the derived flux for 3c279 to the CASA logger. This information is worth noting. We find that the flux of 3c279 is 10.79 Jy, by averaging the fluxes obtained from the ten available datasets. If we check this value against reported flux measurements in the SMA calibrator list [http://sma1.sma.hawaii.edu/callist/callist.html], we find that a flux of 10.79 Jy agrees within a few per cent of a linear interpolation between the two 0.85 mm measurements closest in time to the ALMA observations: (23 May 2011, SMA 11.644 ± 0.583; 01 July 2011, 9.748 ± 0.488).<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used the older, Butler-JPL-Horizons 2010, flux density standard when you ran {{setjy}} earlier in this tutorial, the derived flux values for 3c279 will be slightly lower. The flux of 3c279, when averaged over all 10 measurement sets, will be 10.41 Jy.<br />
</div><br />
<br />
Now we plot the final phase and amplitude calibration tables for each data set. A well-behaved calibration table will show smooth variations as a function of time. Sudden jumps or wild variations among the antenna amplitude gains should prompt further investigation and possibly additional flagging.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting solutions for "+asdm)<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis='antenna',antenna='0~7',plotrange=[0,0,-180,180],<br />
gridrows=4,gridcols=1,showgui=False,<br />
plotfile=asdm+'.scanphase.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis = 'antenna', antenna='8~15', plotrange=[0,0,-180,180],<br />
showgui=False, gridrows=4, gridcols=1, <br />
plotfile=asdm+'.scanphase.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='0~7', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='8~15', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
<br />
</source><br />
<br />
==Apply the Calibrations and Inspect ==<br />
Now we will use {{applycal}} to apply the bandpass, phase, and amplitude calibration tables that we generated in the previous sections to the data. We apply the solutions separately to the bandpass and secondary ("phase") calibrator 3c279, the flux calibrator Titan, and the target source. In most data sets, the bandpass and secondary calibrator will not be the same and this step would include one additional {{applycal}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
for asdm in basename_north: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='NGC*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_south: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Ant*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
</source><br />
<br />
Here:<br />
* '''vis''' and '''field''' specify the measurement set and field to calibrate.<br />
* '''gaintable''' specifies the tables to apply to the data. There may be several tables applied all at once, here we apply the bandpass, phase, and flux calibrations.<br />
* '''interp''' specifies the type of interpolation used to match calibration tables to the data. If there are several gaintables then interp may be either a single value (e.g., "linear" or "nearest") or a list of values with size equal to the list of gaintables. In the case where interp is a list, applycal will match each element to the corresponding gaintable (e.g., first gaintable with first interp parameter).<br />
* '''gainfield''' specifies field from which to draw the calibration. As with interp, this can be a list of size matched to gaintable, so that the first element of gainfield will be the field used for the first table. For example, in the above commands the bandpass calibration (the first table) will always be applied from '3c279' (the first gainfield).<br />
* '''calwt''' indicates that the weights, which were derived from the Tsys measurements, should also be calibrated. Note that '''calwt''' is True by default.<br />
<br />
Once calibrations are applied, it is important to go back and inspect the calibrated data. New problematic antennas or baselines may be visible after calibration. Repeat the steps above, focusing on the CORRECTED data column. Bear in mind that for any point source calibrators we now expect to find phase scattering around zero and to find flat amplitudes as a function of u-v distance. Look for outliers and other signatures of problematic data. As a general rule, you will want to incorporate these data into your overall flagging script then rerun the whole calibration process, so that reduction is iterative. If the data only represent a minor problem, however, it may not be terribly harmful to flag them after the fact so that they do not interfere with imaging but trust that the calibrations are mostly unaffected.<br />
<br />
As an example of this inspection, we cycle through the corrected amplitudes and phases of 3c279 and Titan as a function u-v distance, to check that the phases are close to zero and the amplitudes are constant. <br />
<br />
<figure id="xb-checkcal-pha-cha.png"><br />
[[File:xb-checkcal-pha-cha_6.1.png|200px|thumb|right|<caption> Calibrated phase vs. channel plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<figure id="xb-checkcal-amp-time.png"><br />
[[File:xb-checkcal-amp-time_6.1.png|200px|thumb|right|<caption> Calibrated amplitude vs. time plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='phase',<br />
ydatacolumn='corrected', field='3c279',<br />
avgchannel='3840', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
In <xr id="xb-checkcal-pha-cha.png"/> and <xr id="xb-checkcal-amp-time.png"/> we plot phase vs. channel and amp vs. time for 3c279 for the uid___A002_X1ff7b0_Xb dataset. <br />
<br />
Finally we can use {{plotms}} to examine the corrected amplitude and phase of Antennae galaxies as a function of time and uv-distance (plots not shown):<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
for asdm in basename_north:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
avgtime='1e8', avgscan=True, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
for asdm in basename_south:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
avgtime='1e8', avgscan=True,avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
</source><br />
<br />
==Split and Concatenate Data for Northern and Southern Mosaics==<br />
The individual data sets are now calibrated. We can safely split out the calibrated data for our science target and drop the calibrators. As we do so, we will smooth the data in frequency, averaging together groups of 23 channels by setting '''width=23''' in {{split}}. The new data will have a channel width corresponding to about ~10 km/s, very similar to the SMA data being verified. The factor of >20 drop in data volume will also make the imaging steps ''much'' more tractable.<br />
<br />
Note that you will see a warning that the last output channel in the new spw 0 will be dropped, as it has less than 23 channels over which to average:<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO MSTransformDataHandler The last output channel of spw 0 has only 22 input channels.<br />
WARN MSTransformManager Not enough input channels to populate output channel n# 166 from SPW 0.<br />
WARN MSTransformManager The channel will be dropped in order to have an uniform grid.<br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_north:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'NGC*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
<br />
for asdm in basename_south:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'Ant*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
</source><br />
<br />
For convenience we concatenate all data for the Northern Mosaic into a single big MS and place all data for the Southern Mosaic into another file. To do this, we construct a list that holds the names of all the Southern Mosaic MS files and another that holds the name of all the Northern Mosaic MS files then feed these into the {{concat}} task. <br />
<br />
Before we do this, we'll take a brief aside to remove Pointing information from the calibrated data. Normally, the pointing information would apply important corrections to be used while imaging the data. However, some aspects of this are still under development and the pointing information in these data interacts poorly with CASA. We will remove the pointing information using the CASA toolkit Table tool (tb). ''This kind of operation is dangerous and should not be a regular feature of your CASA reduction.''<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Manually removing pointing table from "+asdm+".cal.ms ... Please be careful!")<br />
tb.open(asdm+'.cal.ms/POINTING',nomodify=False)<br />
a = tb.rownumbers()<br />
tb.removerows(a)<br />
tb.close()<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
cal_south_vis = [vis+'.cal.ms' for vis in basename_south]<br />
cal_north_vis = [vis+'.cal.ms' for vis in basename_north]<br />
<br />
os.system('rm -rf Antennae_South.cal.ms')<br />
concat(vis=cal_south_vis, concatvis='Antennae_South.cal.ms', timesort=True)<br />
<br />
os.system('rm -rf Antennae_North.cal.ms')<br />
concat(vis=cal_north_vis, concatvis='Antennae_North.cal.ms', timesort=True)<br />
</source><br />
<br />
The syntax used to construct the 'cal_south_vis' variable loops over basename_south and makes a list after adding '.cal.ms' to each member. To see the list 'print (cal_south_vis)'.<br />
<br />
==Continue on to Imaging of the Science Target==<br />
Now you can continue on to the [http://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_6.1 imaging guide].<br />
<div style="background-color: #CCFF99;"><br />
<p>Last checked on CASA Version 6.1.0.<br />
</p><br />
</div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Xb-checkcal-amp-time_6.1.png&diff=29411File:Xb-checkcal-amp-time 6.1.png2020-10-01T19:20:13Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Calibration_6.1&diff=29410AntennaeBand7 Calibration 6.12020-10-01T19:19:46Z<p>Dkim: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide is written for CASA 6.1 and uses Python 3. The same functionality is implemented in Python 2 using CASA 5.7 at [[AntennaeBand7 Calibration 5.7]]'''<br />
<br />
*'''This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are provided at [[AntennaeBand7]]<br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see: [[AntennaeBand7_Imaging 6.1]]'''.<br />
<br />
==Overview==<br />
<br />
This part of the Antennae Band 7 CASA guide will step through the calibration of the visibility data. We will begin by flagging (marking as bad) data known to be useless before any inspection; for example, data where one telescope blocks the line of sight of another. We will then apply telescope-generated calibration tables to partially correct for atmospheric effects. After inspecting the data, we will flag some additional data that exhibit pathologies. Using observations of the calibrators Titan and 3c279, it will be shown how to derive the phase and amplitude response of individual antennas as a function of time and frequency ("phase", "amplitude", and "bandpass" calibrations). We will apply these solutions to the data and then extract the calibrated source data into a file appropriate for imaging in the [[AntennaeBand7_Imaging | Antennae Band 7 imaging guide]].<br />
<br />
The general procedure in this guide follows the other ALMA CASA guides: [[NGC3256Band3]] and [[TWHydraBand7]].<br />
<br />
==Unpack the Data==<br />
<br />
This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]. <br />
<br />
Once you have downloaded the data, unpack the file in a terminal outside CASA using<br />
<br />
<source lang="bash"><br />
<br />
tar -xvzf Antennae_Band7_UnCalibratedMSandTablesForReduction.tgz<br />
<br />
</source><br />
<br />
then change directory to the new directory <br />
<br />
<source lang="bash"><br />
<br />
cd Antennae_Band7_UnCalibratedMSandTablesForReduction<br />
<br />
</source><br />
<br />
You may wish to type<br />
<br />
<source lang="bash"><br />
<br />
ls<br />
<br />
</source><br />
<br />
to look at the files present. You should see a set of files with extension ".ms". These are CASA measurement set (MS) files. The data have already been converted to MS format from the native ALMA format using the CASA task {{importasdm}}. In addition to the data, we provide you with calibration tables containing system temperature (Tsys), water vapor radiometer (WVR), and antenna position information. For Early Science, these tables will either be pre-applied or supplied with the data.<br />
<br />
To begin, start CASA by typing<br />
<br />
<source lang="bash"><br />
<br />
casa<br />
<br />
</source><br />
<br />
Be sure that you are using the version indicated at the top of this page.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 6.1. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casalith<br />
version = casalith.version_string()<br />
print("You are using {}".format(version))<br />
if (version < '6.1'):<br />
print ("YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE.")<br />
print ("PLEASE UPDATE IT BEFORE PROCEEDING.")<br />
else:<br />
print ("Your version of CASA is appropriate for this guide.")<br />
</source><br />
<br />
==Initial Inspection==<br />
<br />
First we will take stock of what we have. If you have not already done so, begin by reviewing the description of the observations here: [[AntennaeBand7]]. The 10 data sets each target either the Northern or the Southern Mosaic, as follows:<br />
<br />
Northern Mosaic:<br />
*uid___A002_X1ff7b0_Xb.ms<br />
*uid___A002_X207fe4_X3a.ms<br />
*uid___A002_X207fe4_X3b9.ms<br />
*uid___A002_X2181fb_X49.ms<br />
<br />
Southern Mosaic:<br />
*uid___A002_X1ff7b0_X1c8.ms<br />
*uid___A002_X207fe4_X1f7.ms<br />
*uid___A002_X207fe4_X4d7.ms<br />
*uid___A002_X215db8_X18.ms<br />
*uid___A002_X215db8_X1d5.ms<br />
*uid___A002_X215db8_X392.ms<br />
<br />
The first step is to get basic information about the data: targets observed, time range, spectral setup, and so on. We do this using the task {{listobs}}, which will output a detailed summary of each dataset. Enter the following commands into CASA:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Define a python list holding the names of all of our data sets<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
# Initialize user-input string. (for Python testing)<br />
dummy_string = ''<br />
<br />
# Loop over each element in the list and create summary file using listobs<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.listobs.txt')<br />
listobs(vis=asdm+'.ms', listfile=asdm+'.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note that after cutting and pasting a 'for' loop like this you often have to press return twice to execute. You may also want to take care to paste a line at a time if you are having trouble copy and pasting. Even better, you can use "cpaste" to paste blocks of code. To do so type "cpaste" at the CASA prompt, paste your commands, and then type "--" and hit return on the final (otherwise empty) line. This should look something like this:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
CASA <8>: cpaste<br />
Pasting code; enter '--' alone on the line to stop.<br />
:basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
: "uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
: "uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
: "uid___A002_X215db8_X392"]<br />
:<br />
:for asdm in basename_all:<br />
: print (asdm)<br />
:--<br />
uid___A002_X1ff7b0_Xb<br />
uid___A002_X207fe4_X3a<br />
uid___A002_X207fe4_X3b9<br />
uid___A002_X2181fb_X49<br />
uid___A002_X1ff7b0_X1c8<br />
uid___A002_X207fe4_X1f7<br />
uid___A002_X207fe4_X4d7<br />
uid___A002_X215db8_X18<br />
uid___A002_X215db8_X1d5<br />
uid___A002_X215db8_X392<br />
<br />
CASA <9>: <br />
<br />
</pre><br />
<br />
cpaste should be ''much'' more robust than copying-and-pasting directly into the shell but if you have trouble, just carefully paste one line at a time directly into CASA and hit return until the desired command executes.<br />
<br />
These commands define a python list called "basename_all", which contains the name of all 10 MS files. The "for" loop executes for each element in basename_all, calling listobs and directing the output to a file called, e.g., "uid___A002_X1ff7b0_Xb.listobs.txt" for the first measurement set. You can browse through the listobs output as you would normally look at a text file (use emacs, vi, or another editor). You can also send the output to the terminal from inside of CASA. To do so type:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
or<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('more uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
CASA knows a few basic shell commands like 'cat', 'ls', and 'rm' but for more complex commands you will need to run them inside 'os.system("command")'. For more information see http://casa.nrao.edu/ .<br />
<br />
Here is an example of the (abridged) output from {{listobs}} for the first dataset in the list, uid___A002_X1ff7b0_Xb.ms, which targets the Northern Mosaic. You would see this if you had specified '''verbose''' to be False in the listobs call:<br />
<br />
<pre style="background-color: #fffacd;"><br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_Xb.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA(11 antennas)<br />
Data records: 181357 Total integration time = 4931.71 seconds<br />
Observed from 28-May-2011/01:25:27.6 to 28-May-2011/02:47:39.3 (UTC)<br />
<br />
Fields: 26<br />
ID Code Name RA Decl Epoch SrcId nRows <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 39116 <br />
1 none Titan 12:42:43.94813 -01.43.38.3190 J2000 1 10626 <br />
2 none NGC4038 - Antennae *12:01:53.17008 -18.52.37.9200 J2000 2 4818 <br />
3 none NGC4038 - Antennae *12:01:51.90301 -18.51.49.9437 J2000 2 6435 <br />
4 none NGC4038 - Antennae *12:01:52.43086 -18.51.49.9437 J2000 2 6424 <br />
5 none NGC4038 - Antennae *12:01:52.95871 -18.51.49.9437 J2000 2 5478 <br />
6 none NGC4038 - Antennae *12:01:53.48656 -18.51.49.9436 J2000 2 6435 <br />
7 none NGC4038 - Antennae *12:01:54.01441 -18.51.49.9436 J2000 2 6446 <br />
8 none NGC4038 - Antennae *12:01:52.16693 -18.51.56.4319 J2000 2 6435 <br />
9 none NGC4038 - Antennae *12:01:52.69478 -18.51.56.4318 J2000 2 6424 <br />
10 none NGC4038 - Antennae *12:01:53.22263 -18.51.56.4318 J2000 2 6446 <br />
11 none NGC4038 - Antennae *12:01:53.75049 -18.51.56.4318 J2000 2 6446 <br />
12 none NGC4038 - Antennae *12:01:51.90301 -18.52.02.9201 J2000 2 6435 <br />
13 none NGC4038 - Antennae *12:01:52.43086 -18.52.02.9200 J2000 2 6424 <br />
14 none NGC4038 - Antennae *12:01:52.95871 -18.52.02.9200 J2000 2 4818 <br />
15 none NGC4038 - Antennae *12:01:53.48656 -18.52.02.9200 J2000 2 4829 <br />
16 none NGC4038 - Antennae *12:01:54.01441 -18.52.02.9199 J2000 2 4829 <br />
17 none NGC4038 - Antennae *12:01:52.16694 -18.52.09.4082 J2000 2 4829 <br />
18 none NGC4038 - Antennae *12:01:52.69479 -18.52.09.4082 J2000 2 4829 <br />
19 none NGC4038 - Antennae *12:01:53.22264 -18.52.09.4082 J2000 2 3872 <br />
20 none NGC4038 - Antennae *12:01:53.75049 -18.52.09.4081 J2000 2 4829 <br />
21 none NGC4038 - Antennae *12:01:51.90301 -18.52.15.8964 J2000 2 4829 <br />
22 none NGC4038 - Antennae *12:01:52.43087 -18.52.15.8964 J2000 2 4829 <br />
23 none NGC4038 - Antennae *12:01:52.95872 -18.52.15.8963 J2000 2 4818 <br />
24 none NGC4038 - Antennae *12:01:53.48657 -18.52.15.8963 J2000 2 4818 <br />
25 none NGC4038 - Antennae *12:01:54.01442 -18.52.15.8963 J2000 2 4840 <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 354971.074 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 354916.143 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11 'name'='station' <br />
ID= 0-3: 'DV02'='A015', 'DV04'='J505', 'DV06'='T704', 'DV07'='A004', <br />
ID= 4-7: 'DV08'='A072', 'DV09'='A008', 'DV10'='A009', 'DV11'='A016', <br />
ID= 8-10: 'PM01'='T702', 'PM02'='A017', 'PM03'='J504'<br />
================================================================================<br />
<br />
</pre><br />
<br />
And here is an extract from the full '''verbose''' {{listobs}} for uid___A002_X1ff7b0_X1c8.ms, which targets the Southern Mosaic (note that we have snipped out the record of individual scans):<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_X1c8.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA<br />
Data records: 175615 Total integration time = 4927.1 seconds<br />
Observed from 28-May-2011/02:50:18.2 to 28-May-2011/04:12:25.3 (UTC)<br />
<br />
<snip><br />
<br />
Fields: 33<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 12232 <br />
1 none Titan 12:42:44.82765 -01.43.41.4224 J2000 1 10615 <br />
2 none 3c279 12:56:11.16600 -05.47.21.5250 J2000 2 27764 <br />
3 none Antennae 12:01:53.17008 -18.52.37.9200 J2000 3 4829 <br />
4 none Antennae 12:01:52.18699 -18.53.30.3952 J2000 3 3883 <br />
5 none Antennae 12:01:52.64413 -18.53.26.6494 J2000 3 3883 <br />
6 none Antennae 12:01:53.10127 -18.53.22.9035 J2000 3 3872 <br />
7 none Antennae 12:01:53.55841 -18.53.19.1577 J2000 3 4818 <br />
8 none Antennae 12:01:54.01554 -18.53.15.4119 J2000 3 4829 <br />
9 none Antennae 12:01:54.47268 -18.53.11.6661 J2000 3 4829 <br />
10 none Antennae 12:01:54.92982 -18.53.07.9203 J2000 3 3872 <br />
11 none Antennae 12:01:55.38696 -18.53.04.1744 J2000 3 3883 <br />
12 none Antennae 12:01:55.84409 -18.53.00.4286 J2000 3 4840 <br />
13 none Antennae 12:01:56.30123 -18.52.56.6828 J2000 3 4818 <br />
14 none Antennae 12:01:52.18700 -18.53.22.9033 J2000 3 4829 <br />
15 none Antennae 12:01:52.64414 -18.53.19.1575 J2000 3 4818 <br />
16 none Antennae 12:01:53.10128 -18.53.15.4116 J2000 3 4818 <br />
17 none Antennae 12:01:53.55842 -18.53.11.6658 J2000 3 4840 <br />
18 none Antennae 12:01:54.01555 -18.53.07.9200 J2000 3 3872 <br />
19 none Antennae 12:01:54.47269 -18.53.04.1742 J2000 3 4829 <br />
20 none Antennae 12:01:54.92983 -18.53.00.4284 J2000 3 4829 <br />
21 none Antennae 12:01:55.38697 -18.52.56.6825 J2000 3 4829 <br />
22 none Antennae 12:01:55.84410 -18.52.52.9367 J2000 3 4829 <br />
23 none Antennae 12:01:51.72988 -18.53.19.1572 J2000 3 4818 <br />
24 none Antennae 12:01:52.18702 -18.53.15.4114 J2000 3 4829 <br />
25 none Antennae 12:01:52.64415 -18.53.11.6656 J2000 3 4829 <br />
26 none Antennae 12:01:53.10129 -18.53.07.9197 J2000 3 2266 <br />
27 none Antennae 12:01:53.55843 -18.53.04.1739 J2000 3 2266 <br />
28 none Antennae 12:01:54.01557 -18.53.00.4281 J2000 3 3212 <br />
29 none Antennae 12:01:54.47270 -18.52.56.6823 J2000 3 3234 <br />
30 none Antennae 12:01:54.92984 -18.52.52.9365 J2000 3 3212 <br />
31 none Antennae 12:01:55.38698 -18.52.49.1906 J2000 3 2266 <br />
32 none Antennae 12:01:55.84411 -18.52.45.4448 J2000 3 3223 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 356845.586 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 356900.518 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11:<br />
ID Name Station Diam. Long. Lat. <br />
0 DV02 A015 12.0 m -067.45.15.3 -22.53.26.0 <br />
1 DV04 J505 12.0 m -067.45.18.0 -22.53.22.8 <br />
2 DV06 T704 12.0 m -067.45.16.2 -22.53.22.1 <br />
3 DV07 A004 12.0 m -067.45.15.9 -22.53.28.0 <br />
4 DV08 A072 12.0 m -067.45.12.6 -22.53.24.0 <br />
5 DV09 A008 12.0 m -067.45.15.4 -22.53.26.8 <br />
6 DV10 A009 12.0 m -067.45.16.1 -22.53.26.1 <br />
7 DV11 A016 12.0 m -067.45.16.4 -22.53.25.1 <br />
8 PM01 T702 12.0 m -067.45.18.6 -22.53.24.1 <br />
9 PM02 A017 12.0 m -067.45.15.9 -22.53.26.8 <br />
10 PM03 J504 12.0 m -067.45.17.0 -22.53.23.0 <br />
</pre><br />
<br />
This output shows that three sources were observed in each data set: 3c279, Titan, and the Antennae.<br />
<br />
* The '''Antennae''' are our science target. Note that the source name changes between the Northern Mosaic, where it is "NGC4038 - Antennae", and the Southern Mosaic, where it is just "Antennae". Also note that the source corresponds to a number of individual fields (see the Field ID column). These are the individual mosaic pointings. There are 23 for the Northern Mosaic and 29 for the Southern Mosaic.<br />
* '''Titan''' is observed once and will be used to set the absolute flux scale of the data.<br />
* '''3c279''' plays two roles: it will serve as our bandpass calibrator, to characterize the frequency response of the antennas, and because it is fairly close on the sky to the Antennae (18.6 degrees away) it will serve as our secondary calibrator (also referred to as the "phase calibrator" or "gain calibrator"), to track changes in the phase and amplitude response of the telescopes over time. Observations of 3c279 are interleaved with observations of the Antennae.<br />
<br />
The output also shows that the data contain many spectral windows. Using the labeling scheme in the listobs above these are:<br />
<br />
* '''spw 0''' targets ~185 GHz and holds water vapor radiometer data<br />
* '''spw 1''' and '''spw 3''' hold our science data. These are "Frequency Domain Mode" (FDM) data with small (0.49 MHz) channel width and wide (1.875 GHz) total bandwidth. As a result these have a lot of channels (3840). spw 1 holds the lower sideband (LSB) data and includes the CO(3-2) line. We will focus on these data. For the CO(3-2) line the channel width corresponds to 0.426 km/s and the bandwidth of spw 1 to 1634 km/s.<br />
* '''spw 2''' and '''spw 4''' hold frequency-averaged versions of spw 1 and 3 ("Channel 0" for those familiar with AIPS). These are used for some quick automated inspection. We will not use them here but we will carry out an equivalent inspection using spw 1.<br />
* '''spw 5''' and '''spw 7''' hold lower a resolution processing ("Time Domain Mode", TDM) of the data from the same part of the spectrum (baseband) as spws 1 and 3. These data have only 128 channels across 2 GHz bandwidth and so have a much coarser channel spacing than the FDM data. These were used to generate the calibration tables that we include in the tarball but will not otherwise appear in this guide.<br />
<br />
The final column of the listobs output in the logger (not shown above) gives the scan intent. Later we will use this information to flag the pointing scans and the hot and ambient load calibration scans.<br />
<br />
We'll now have a look at the configuration of the antennas used to take the data using the task {{plotants}} (<xr id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"><br />
[[File:Uid_A002_X1ff7b0_Xb.ANT_6.1.png|200px|thumb|right|<caption> Position of antennas in dataset uid_A002_X1ff7b0_Xb obtained using task plotants. </caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Antenna configuration for : "+asdm)<br />
plotants(vis=asdm+'.ms', figfile=asdm+'.plotants.png')<br />
clearstat()<br />
dummy_string = input("Hit <Enter> to see the antenna configuration for the next data set.")<br />
</source> <br />
<br />
This will loop through all 10 data sets, show you the antenna position for each, and save that as a file named, e.g., "uid___A002_X1ff7b0_Xb.plotants.png" for the first data set. The "input" command asks CASA to wait for your input before proceeding. If you would prefer to just browse the .png files after the fact you can remove this. Notice that the antenna setup changes, but only slightly, over the course of the 10 data sets.<br />
<br />
==How to Deal With 10 Measurement Sets==<br />
<br />
It should already be clear from the initial inspection that dealing with 10 data sets at the same time can be a bit problematic. This is especially tricky in our case because the Antennae data contain two distinct sets of observations: the Northern and Southern Mosaics. The source name changes between these two scripts and there are different numbers of fields in the mosaic.<br />
<br />
''As a general rule one would reduce each individual observation separately or at the very least only group data observed in a uniform way and very close in time.'' <br />
<br />
Unfortunately, a CASA Guide stepping through the reduction for each of 10 data sets would quickly become unwieldy. Therefore we will use a few tricks to reduce the Antennae data in a kind of batch mode. You have already seen the first trick: we can define a python list holding the names of each data set and then loop over this list to execute the same command on each data set. For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print (asdm)<br />
</source><br />
<br />
You only need to define your list of MS files once per CASA session. Then "basename_all" will be a variable in the casapy shell. You can check if it exists by typing "print (basename_all)". In the interests of allowing you to easily exit and restart CASA and pick this guide up at any point we will redefine "basename_all" in each section of the guide. Feel free to skip this step if you've already defined it in your session.<br />
<br />
This page will step you through the reduction of the whole Antennae Band 7 SV data set using these 'for' loops. We will not be able to show every diagnostic plot but we give an example of each and the syntax to generate the rest. Also please be aware that even on a very fast machine this whole process can take a while, we are simply dealing with a lot of data.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
One potential "gotcha" is that the source name changes between the two data sets. Therefore at several points we will break apart our loop to iterate separately over the Northern and Southern Mosaics, where the source can be referred unambiguously. Another subtle point is that 3c279 appears with two distinct field IDs in the Southern Mosaic, but only one in the Northern Mosaic. We will largely avoid this by referring to the source by its name but if you tried to use field ID numbers and mingled the two data sets this could cause confusion.<br />
</pre><br />
<br />
==''A Priori'' Flagging==<br />
<br />
Even before we look in detail, we know that there are some data that we wish to exclude. We will start by flagging "shadowed" data where one antenna blocks the line of sight of another. We will also flag scans that were used to carry out pointing and atmospheric calibration, identified by their scan intent. Finally, we'll flag the autocorrelation data (the correlation of the signal from an antenna with itself) as we are only interested in cross-correlation data to make an interferometric image.<br />
<br />
Start by defining our list of MS files:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
You may want to reset the flagging if you have tried this step before and are starting over though this is not necessary on your first time through. Do so using {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Resetting flags for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='unflag', flagbackup=False)<br />
</source><br />
<br />
Then flag shadowed data using the command {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging shadowed data for "+asdm)<br />
flagdata(vis=asdm+'.ms',mode = 'shadow', flagbackup = False)<br />
</source><br />
<br />
In the {{flagdata}} task we choose:<br />
<br />
* '''vis''' = asdm+'.ms' : each measurement set<br />
* '''mode''' = 'shadow': flag shadowed data<br />
* '''flagbackup''' = False: Do not automatically back up the flag files. We will save all of the ''a priori'' flags together using {{flagmanager}} at the end of this subsection and save some space and time.<br />
<br />
The relevant calibration information has already been extracted from the pointing and atmospheric scans and we will not need them below. Now flag the pointing scans using {{flagdata}} in 'manualflag' mode and selecting on 'intent':<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging calibration scans for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='manual', intent='*POINTING*', flagbackup = False)<br />
</source><br />
<br />
Note that because the atmospheric calibration scans contain only TDM spectral windows, they will be removed automatically when we separate out the FDM data below.<br />
<br />
Now flag the autocorrelation data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging autocorrelation data for "+asdm)<br />
flagdata(vis=asdm+'.ms',autocorr=True,flagbackup=False)<br />
</source><br />
<br />
Finally store the current flags information using {{flagmanager}}: <br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Backing up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'save', versionname = 'Apriori')<br />
</source><br />
<br />
Where '''versionname''' is just the name we assign to the current flagging state in the data. We can now roll back the flags to match the current version, called 'Apriori', whenever we want. There is no reason to do this now, but the syntax would be:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Restoring up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'restore', versionname = 'Apriori')<br />
</source><br />
<br />
<br />
It would have been possible to set {{flagdata}} to '''flagbackup'''=True so that it stores the flags at each of the flagging step automatically, but this way it is a bit more efficient with regard to time and disk space. More important, lumping all the ''a priori'' flagging together gives us a natural point to roll back to if we get in trouble.<br />
<br />
<br />
The flagmanager task will also allow you to view the saved flagging versions,<br />
including those created by running flagdata with flagbackup=True.<br />
<br />
For example try <br />
<br />
<source lang="python"><br />
# In CASA<br />
flagmanager(vis='uid___A002_X2181fb_X49.ms', mode='list')<br />
</source><br />
<br />
The output in the logger should list the Apriori flagging that we have applied.<br />
It will also indicate versions associated with any flagdata command where you<br />
did not set flagbackup=False. Other tasks, for example applycal, will also create<br />
flag version tables.<br />
<br />
==Create and Apply Tsys, WVR, and Antenna Position Calibration Tables==<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
===Tsys===<br />
<br />
The Tsys calibration gives a first-order correction for the atmospheric opacity as a function of time and frequency and associates weights with each visibility that persists through imaging.<br />
<br />
Use gencal to create the Tsys calibration tables from the spectral windows with CALIBRATE_ATMOSPHERE intents in listobs (i.e. the TDM spectral windows with 128 channels), these are spectral windows 5 and 7.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#Removing existing Tsys information<br />
os.system('rm -rf *tdm.tsys')<br />
for asdm in basename_all:<br />
print ("Creating TDM Tsys Table for "+asdm)<br />
gencal(vis=asdm+'.ms',caltable=asdm+'.tdm.tsys',spw='5,7',caltype='tsys')<br />
</source><br />
<br />
Later in the applycal stage this TDM Tsys table will be interpolated to the FDM (3840 channels per spw) science spectral windows 1 and 3.<br />
<br />
Next we inspect the Tsys tables for the spectral window '''spw''' = 5 with the task {{plotms}}. In previous CASA versions, we used {{plotcal}} for this task, but most of '''plotcal''''s functionality is now included in {{plotms}}, and '''plotcal''' will be deprecated in a future CASA release. We want to check that Tsys data have reasonable values and identify any unexpected features as a function of either time or frequency. To get an idea of sensible Tsys under average atmospheric observations consult the ALMA sensitivity calculator, accessible from http://www.almascience.org (via the "Documents & Tools" link).<br />
<br />
We start by plotting the Tsys for all the antennas and polarizations (XX and YY) as a function of time for each. <!--Here and throughout we focus on spw 1, which contains CO(3-2): --><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Note that right now, plotms can't select individual channels when plotting caltables (as was possible with plotcal). In addition, when iteraxis is set, plotms appends the axes being iterated over to the output filename specified in plotfile; this can make for rather unwieldy filenames (particularly when iteraxis='antenna'!) but is useful for the ALMA pipeline. <br />
</pre><br />
<br />
<figure id="Xb.Tsys_vs_time.page1.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page1.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 8 antennas. Note the high y-axis values for DV04. The two different colors indicate the two polarizations (XX and YY).</caption>]]<br />
</figure><br />
<figure id="Xb.Tsys_vs_time.page2.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page2.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting Tsys vs. time for "+asdm)<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='0~7',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page1.png',overwrite=True)<br />
#dummy_string = input("First eight antennas for "+asdm+" . Hit <Enter> to continue.")<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='8~15',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page2.png',overwrite=True)<br />
#dummy_string = input("Remaining antennas for "+asdm+" . Hit <Enter> to continue.")<br />
</source><br />
<br />
This sequence loops over all of our files and plots Tsys as a function of time for channel 50 in spectral window 5. In the call to {{plotms}}:<br />
<br />
* '''gridrows'''=4 and '''gridcols'''=2 sets up a 4 x 2 panel grid. <br />
* '''iteraxis'''='antenna' tells {{plotms}} to make a separate plot for each antenna.<br />
* '''spw'''='5:50~50' selects spw '5' channel 50-50. This allows us to cleanly separate time variations from frequency variations. '''Note that this is a functionality in plotcal but not yet in {{plotms}}, and plotms is actually showing all channels from spw 5 at this time.'''<br />
<br />
Because 8 panels (2 panels for each antenna - LSB and USB) is not enough to show all antennas on one page, there are two {{plotms}} calls: one for the first 8 antennas ('''antenna'''='0~7'), and then for the remaining antennas ('''antenna'''='8~15').<br />
<br />
The 'input' commands will wait for you to hit Enter before issuing the next plot command. In the example above these are commented out (the leading "#" means that CASA will ignore them). If you would like to interactively cycle through the plots, uncomment them by removing the "#". Otherwise, the '''plotfile''' parameter directs the output to .png files for later inspection. The easiest way to look at the 20 plots produced here is to simply inspect the .png files using your favorite viewer. As noted above, here plotms is adding the antenna information to the filenames because we set '''iteraxis''' = 'antenna', so check your directory for the impressively long filenames to view them. <br />
<br />
The Tsys values in <xr id="Xb.Tsys_vs_time.page1.6.1.png"/> and <xr id="Xb.Tsys_vs_time.page2.6.1.png"/> look reliable, with typical values ~150 K except for some large values of Tsys at ~400 and 500 K for DV04. We will flag the data for that antenna later. <br />
<br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV02.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 4 antennas. Note the high y-axis values for DV04 and the mesospheric line near 343.2 GHz.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV08.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Next 4 antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"><br />
[[File:uid___A002_X215db8_X392.tdm.tsys.3c279.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid___A002_X215db8_X392. Note the pathological behavior for DV12.</caption>]]<br />
</figure><br />
<br />
We will also want to look at Tsys as a function of frequency. <br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
os.system('rm -rf cal_plots/Tsys_plots/'+asdm+'.tdm.tsys*')<br />
tsysfields=['3c279','Titan','*Antennae*']<br />
caltable=asdm+'.tdm.tsys'<br />
for field in tsysfields:<br />
plotbandpass(caltable=caltable,yaxis='amp',field=field,xaxis='freq',<br />
showatm=True,overlay='time',<br />
figfile='cal_plots/Tsys_plots/'+caltable+'.'+field,<br />
buildpdf=False,interactive=False,chanrange='8~120',subplot=42)<br />
</source><br />
<br />
You will see the following statement in the logger, but this is fine: <br />
<br />
<pre style="background-color: #fffacd;"><br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
</pre><br />
<br />
Now have a look at the Tsys vs. frequency plots or see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/>, <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"/>, and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/> for examples on the first data set. You can see the effect of a close pair of atmospheric ozone absorption lines at about 343.2 GHz that makes Tsys larger near that frequency in all antennas. Applying the Tsys calibration tables will minimize the contribution of these atmospheric lines. Again DV04 stands out with its very high Tsys. Although not present in the first data sets, Antenna DV12 exhibits periodic spikes in Tsys vs. frequency for one polarization (see <xr id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"/> for an example from a later data set). It may or may not be possible to calibrate that behavior out. We will make a note to look carefully at DV12 further on in the calibration process.<br />
<br />
===WVR===<br />
The WVR calibration uses observations of the wings of the 183 GHz atmospheric water line to correct for phase variations as a function of time. As noted in the tsys section, this run of gencal will append to existing WVR produced tables. To avoid this, preexisting wvrgcal data is removed. <br />
<source lang="python"><br />
#In CASA<br />
#Removing existing WVR information<br />
os.system('rm -rf *.wvrgcal')<br />
for asdm in basename_all:<br />
wvrgcal(vis=asdm+'.ms',caltable=asdm+'.wvrgcal',toffset=-1)<br />
</source><br />
<br />
===Antenna Positions===<br />
<br />
In general, the most appropriate antenna positions for the dataset will be determined and updated if needed during QA2. If the antenna positions need to be updated after QA2, we inform the PIs of the affected datasets and provide instructions on how to update the antenna positions. For the data in this guide, we do need to update the antenna positions. <br />
<br />
The antenna position table reflects refinements in the measured positions of the antennas from those stored in the data. {{gencal}} will now be used put antenna position data into each observation. Again, {{gencal}} will merely append to existing antenna position data, ruining any subsequent results. We start by removing any existing antenna position refinements, followed by defining the antenna names, then their refinements (both as arrays), finally running {{gencal}} to create the information CASA can refer to for antenna positions.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_Xb.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:21]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3a.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3b9.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X2181fb_X49.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV01,DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
-0.00004, 0.00026, 0.00019, #DV01-A137<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_X1c8.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X1f7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X4d7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X18.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X1d5.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X392.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
</source><br />
<br />
===Applycal===<br />
<br />
We are now ready to apply the Tsys and the WVR calibration tables to the data with {{applycal}}, which reads the specified gain calibration tables, applies them to the (raw) data column, and writes the calibrated results into the corrected column. Again, we loop through all the datasets. It is important to only apply Tsys and WVR corrections obtained close in time to the data being corrected, so in addition to looping over data sets we define the list of unique source names and loop over these. Then by setting '''gainfield''' and '''field''' to the same value we ensure that Tsys and WVR calibrations are only applied to the source for which they are measured. Because the source has a different name in the Northern Mosaic and the Southern Mosaic, we will carry out two loops. We will only correct '''spw''' 1 and 3, our science windows, because we will drop the other data in a moment.<br />
<br />
The applycal task now has much more flexibility for interpolating and applying calibrations derived in one spectral window to another, even if they do not share the same spectral shape (number of channels and channel width). This new functionality is used below to interpolate the TDM (128 channel) Tsys measurements to the FDM (3840 channel) spectral windows. This is controlled through the spectral window mapping parameter *spwmap*. Because this can be a bit confusing, we've written a "helper" function that will tell you what you should put for the Tsys calibration table part of spwmap. We only need to run it on one of the datasets because they are all the same in this regard<br />
<br />
<source lang="python"><br />
# In CASA<br />
from casarecipes.almahelpers import tsysspwmap<br />
tsysspwmap(vis='uid___A002_X207fe4_X3a.ms',tsystable='uid___A002_X207fe4_X3a.tdm.tsys')<br />
</source><br />
<br />
This will print to your screen: [0, 5, 5, 7, 5, 5, 5, 7]. Recall that the TDM spectral windows are spw=5 and 7 and the FDM spectral windows are 1 and 3. This spwmap tells applycal to use the Tsys information in spectral window 5 for spectral window 1; and to use the information in spectral window 7 for spectral window 3. Beyond that, it is only important that there are placeholders for the other spectral windows, its also useful to note that you need not give placeholders for spectral window ids larger than the largest spectral window you need to use, in this case 7.<br />
<br />
You will also need to put in placeholders for other tables that you give the gaintables. So if the Tsys table is 2nd in the list, spwmap=[[],[0,5,5,7,5,5,5,7],[]]<br />
<br />
Now run the applycal commands.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# A new list of file names that contain only data from the Northern Mosaic<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names_north = ['Titan','3c279','NGC*']<br />
<br />
for asdm in basename_north:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_north:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=['',field,field],<br />
interp=['','linear,spline','nearest'], <br />
gaintable=[asdm+'.antpos',asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]],<br />
flagbackup=False, calwt=True)<br />
<br />
# A new list of file names that contain only data from the Southern Mosaic<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names_south = ['Titan','3c279','Ant*']<br />
<br />
for asdm in basename_south:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_south:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=["",field,field],<br />
interp=['','linear,spline','nearest'],<br />
gaintable=[asdm+".antpos",asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]], <br />
flagbackup=False, calwt=True)<br />
</source><br />
<br />
where:<br />
<br />
*'''field''': the field ''to'' which we will apply the calibration, <br />
*'''gainfield''': the field ''from'' which we wish to take the calibration table<br />
*'''interp''' = 'nearest' : apply the nearest solution from the calibration table rather than interpolating.<br />
<br />
As you browse through the whole data set, you will probably note some problems along the same lines as the DV04 issue we saw above. We'll apply these as additional data flagging in just a moment.<br />
<br />
==Inspect Data==<br />
We are not quite done with the original ".ms" data sets yet. Before going further it will be useful to use {{plotms}} to show the effects of applying the calibration. In the process we'll take a quick look at each antenna and search for pathologies in the data.<br />
<br />
For this basic inspection, we want to compare the phase and amplitude as a function of frequency and time in the DATA and CORRECTED columns of each measurement set. The CORRECTED column has had the Tsys and WVR calibrations applied and so we expect lower phase scatter and flatter amplitude response as a function of time and frequency. We are looking for antenna-based issues, so cycling through a set of baselines that includes each antenna once will be a good start. We'll focus these plots on the phase+bandpass calibrator, 3c279, and on baselines that include antenna DV11, which we will make our reference antenna in just a bit.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
Each CASA Measurement Set has up to three "columns" of data: DATA, CORRECTED, and MODEL (though it is possible<br />
for a MS to hold only a DATA column if it has not been processed at all). <br />
<br />
A column entry exists for each data point (baseline, frequency, time). <br />
<br />
The DATA column holds the current raw data, though using split as we just did we can change the definition of<br />
"raw" data. <br />
<br />
The CORRECTED column holds the result of applying one or more calibration tables (e.g., via applycal) to the<br />
DATA column and so represents a corrected version of the DATA column. <br />
<br />
The MODEL column is now deprecated (though it is still possible to use it by explicitly setting usescratch=True).<br />
Instead, the model is stored in the header of the ms. This is a great step forward in terms of saving space and time <br />
to create scratch columns <br />
<br />
To get an intuitive feel for the columns you may wish to explore using plotms (which can plot different data <br />
columns, as seen below) or the browsetable task.<br />
<br />
</pre><br />
<br />
<figure id="plotms_amp_vs_freq_example-data.png"><br />
[[File:plotms_amp_vs_freq_example-data_6.1.png|200px|thumb|right|<caption> Example of Amplitude vs. Frequency before correction for the 3c 279.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_example-corr.png"><br />
[[File:plotms_amp_vs_freq_example-corr_6.1.png|200px|thumb|right|<caption> Same baseline as Figure 8 but now after correction using WVR and Tsys calibrations.</caption>]]<br />
</figure><br />
<br />
First, we plot amplitude as a function of frequency for 3c279. We start by plotting the DATA column, set color to indicate the two correlations (i.e., the XX and YY polarizations), and ask plotms to iterate over baseline. By setting '''antenna''' to 'DV11&*' we select only baselines that include DV11. We ask plotms to average all data over a very long timescale, '''avgtime''' = 1e8 seconds ~ 3 years or much longer than the time spanned by the whole data set. By setting '''avgscan''' = True we allow {{plotms}} to average across scan boundaries. The result is a plot of average amplitude per channel vs. frequency.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
asdm=basename_all[0]<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='amp',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Notice the green arrows along the bottom of the {{plotms}} window. We asked {{plotms}} to iterate over baseline. As you click the arrows, the plot will rotate from baseline to baseline, always with DV11 so that each antenna shows up once. To see the effect of the calibration, go to the "Axes" tab along the left of the {{plotms}} window and pull down the Data Column menu under the Y Axis. Set this from DATA to CORRECTED and you should see the effects of the calibration. You may need to ensure that the "Force Reload" box is checked before clicking "Plot" (both buttons lie at the bottom of the panel). For the most part things get better (flatter), but as we noted before DV04 is problematic.<br />
<br />
<figure id="plotms_amp_vs_time_north.png"><br />
[[File:plotms_amp_vs_time_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_time_south.png"><br />
[[File:plotms_amp_vs_time_south_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a southern mosaic data set.</caption>]]<br />
</figure><br />
<br />
You can now make analogous calls to examine the phase vs. frequency, amplitude vs. time, and phase vs. time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='phase',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='amp',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='phase',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Where:<br />
<br />
* '''spw''' is set to cover only channels 1200~1300 for the time plots in order to isolate time dependent variations from frequency-dependent behavior. Those 101 channels represent only a small part of the total spw 1 bandpass.<br />
* '''avgchannel''' set to a large number causes the plots of phase and amplitude vs. time to average data at all frequencies into a single point for each measurement.<br />
* '''coloraxis''' corr sets the colors to correspond to the two polarizations of the data.<br />
<br />
In each case, you will want to examine each baseline, alternating between the DATA and CORRECTED columns.<br />
<br />
This is a lot of data inspection and that's only for one of 10 data sets! You can iterate across the data by hand, updating "asdm" to refer to each data set in order and cycling between baselines and DATA/CORRECTED. It is also possible to script CASA to show you the key plots in succession (see the next block down). However you approach the infrastructure, you are looking for:<br />
<br />
* Improved scatter and lower variability in phase and amplitude vs. frequency and time. This indicates that the WVR and Tsys calibrations helped. <br />
* Sudden jumps in phase or amplitude as a function of either time or frequency. These may indicate problems with the antenna during that observation.<br />
* Large gradients, especially full wraps, in phase as a function of frequency. This may indicate a problem in the delays, the signal path length to the telescopes.<br />
* Unusual magnitude, scatter, or patterns in any plot - though this may be better explored using plots that show all data together, which we'll make in a moment.<br />
* Missing data. For example, if the phase calibrator drops out for a period of time we will not be able to calibrate and will need to flag the data.<br />
<br />
As you look through, note individual potentially problematic antennas. If ''all'' antennas in a data set appear problematic it may be that your "reference" antenna, DV11 in the example above, is the source of the problem. In this case swap this reference antenna for another and see whether the problem is isolated to your original reference antenna.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
A brief aside on structure:<br />
<br />
This section (Data Inspection) and the next (Apply Flags) are closely linked. We will present them as two<br />
separate steps. The idea here is that you look through your data, note problems, and then write commands to<br />
flag problematic data. This mimics one approach to writing data reduction scripts for CASA, where you will<br />
group all flagging together into one convenient place. Other CASA guides take a different approach, interleaving <br />
flagging and plotting. There is no "right" answer here. Find an approach to data inspection that works for you.<br />
<br />
</pre><br />
<br />
If you do wish to semi-automate the plot generation, the following sequence will cycle between data and corrected plots for each data set in turn. Type "stop" at any input call to break out.<br />
<br />
<!--<br />
'''Note:''' In loops like this involving {{plotms}}, hitting enter before the last dataset completes loading may cause {{plotms}} to stop refreshing the plot window at each step, or cause the window to disappear altogether. This will be fixed in an upcoming CASA release. Right now, you may need to exit CASA and restart to bring up the {{plotms}} window again, but you should be able to continue in the script where you left off.<br />
--><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
user_input = ""<br />
for asdm in basename_all:<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
# Extract antenna list for this data set.<br />
tb.open(asdm+'.ms/ANTENNA', nomodify=True)<br />
ants = tb.getcol('NAME')<br />
tb.close<br />
# Define the reference antenna to make baselines with<br />
ref_ant = 'DV11'<br />
# Loop over antennas<br />
for ant in ants:<br />
# Check if the user wants to stop<br />
if user_input == "stop":<br />
break<br />
# Skip correlation of reference antenna with itself (autocorrelations are flagged anyhow) <br />
if ant == ref_ant:<br />
continue<br />
# Define the baseline with the reference antenna for current antenna<br />
ant_str = ref_ant+'&'+ant<br />
print ("Showing baseline "+ant_str+" for data set "+asdm)<br />
print ("Use this to inspect effect of applying wvrcal and Tsys calibrations.")<br />
# Loop over phase and amplitude as axes<br />
for y_axis in ["amp", "phase"]:<br />
# Make 'before' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'before' plot for time x-axis<br />
print ("... "+y_axis+" vs. time for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for time y-axis<br />
print ("... "+y_axis+" vs. time for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<figure id="plotms_amp_vs_uvdist_north.png"><br />
[[File:plotms_amp_vs_uvdist_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. uv-distance for 3c279 in the first northern mosaic data set.</caption>]]<br />
</figure><br />
<br />
<figure id="plotms_amp_vs_freq_3c279.png"><br />
[[File:plotms_amp_vs_freq_3c279_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for 3c279 in the second northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Titan.png"><br />
[[File:plotms_amp_vs_freq_Titan_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for Titan in the second northern mosaic data set. Note the strong line (this is CO 3-2)!</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Antennae.png"><br />
[[File:plotms_amp_vs_freq_Antennae_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for the Antennae in the second northern mosaic data set. The CO(3-2) line is visible.</caption>]]<br />
</figure><br />
<br />
A detailed explanation of the procedure is a bit outside the scope of this guide (for more on python see http://www.python.org/ and for more on the CASA toolkit see http://casa.nrao.edu/), but the basic process is to loop over each data set, baseline with the reference antenna (here DV11), and y-axis of interest (phase or amplitude) then plot the effect of the calibration vs. frequency and time for each combination. Running this to step through the data will give you about 200 "before and after" plots from which you could note a subset of problematic cases to be followed up by hand. Many other strategies to inspect the data are also viable.<br />
<br />
With the Tsys and WVR calibrations applied successfully and the ''a priori'' flagging taken care of we will now {{split}} out the corrected data. We will keep only the corrected data, specified via '''datacolumn''', and only spectral window 1, which contains the FDM (high spectral resolution) observations of the CO(3-2) line. Setting '''keepflags'''=False tells {{split}} not to carry over any fully flagged rows from the original data set to the new MS. We give the new MS files the extension ".wvrtsys.ms" to indicate that they have been corrected for WVR and Tsys effects. Because split will not overwrite existing files, we remove any previous versions of the new MS before beginning.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm -rf '+asdm+'.wvrtsys.ms')<br />
print ("Splitting out corrected data for "+asdm)<br />
split(vis=asdm+'.ms', outputvis=asdm+'.wvrtsys.ms', <br />
datacolumn='corrected', spw='1', keepflags=False)<br />
</source><br />
<br />
Be patient, {{split}} may take awhile. The WVR and Tsys-corrected data now sit in the DATA column of the new measurement sets, which have only one spectral window (now labeled spectral window 0 though it was spectral window 1 in the original data). You may wish to run {{listobs}} to illustrate the changes:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.wvrtsys.listobs.txt')<br />
listobs(vis=asdm+'.wvrtsys.ms', listfile=asdm+'.wvrtsys.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note the new spectral window information:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
2011-08-05 01:07:08 INFO listobs Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
2011-08-05 01:07:08 INFO listobs SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
2011-08-05 01:07:08 INFO listobs 0 3840 TOPO 344845.586 488.28125 1875000 344908.33 XX YY <br />
<br />
</pre><br />
<br />
<br />
Next we will do a bit more inspection using {{plotms}} to look at whole data sets. This will help us identify missing data or look for egregious outliers.<br />
<br />
First we plot amplitude versus time (see <xr id="plotms_amp_vs_time_north.png"/> and <xr id="plotms_amp_vs_time_south.png"/>), averaging over all channels (by setting '''avgchannel''' to the very large value 10,000). We colorize by field so that scans on Titan are red, the bandpass and phase calibrator 3c279 is black (and orange in the Southern Mosaic where it has two field IDs), and the Antennae mosaic appears as a range of colors (one per pointing).<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='amp', <br />
avgchannel='3840',coloraxis='field', showgui = True)<br />
user_input = input("Examining amplitude vs. time for "+asdm+" . Hit <Enter> to proceed.[type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
Here look for:<br />
<br />
* Missing data. The source needs to be flanked by phase calibrator scans, if those are missing for any reason we need to flag the appropriate time range.<br />
* Dramatic outliers. Does the source suddenly get very bright or the otherwise bright calibrator appear anomalously faint for a brief time? This likely indicates problematic data that should be identified and flagged. You can use the "select" (box with green plus along the bottom row in plotms) and "locate" (magnifying glass) buttons in {{plotms}} to isolate and identify problem data (it will print to the log).<br />
* Smooth variation with time. A sudden jump may indicate a problem and often the safest approach is to flag data near a discontinuity.<br />
<br />
Look through the amplitudes vs. time for each data set (remember that we've already examined the phases vs. time and amplitude vs. time for individual baselines above).<br />
<br />
There are two other very useful "averaging" plots worth making. First, we plot amplitude as a function of u-v distance (projected antenna separation). Discontinuities and spikes in this plot are often from non-astrophysical sources. In the phase analog to the plot, the effects of atmospheric decorrelation can be assessed from increased scatter at longer u-v distances. While using the moon Titan as our flux calibrator, we may want to watch for flaring amplitudes at short u-v distances. These may indicate that Saturn is contaminating our beam. For a perfect, bright point source, we expect flat amplitudes as a function of u-v distance at the source amplitudes. <xr id="plotms_amp_vs_uvdist_north.png"/> shows an example of this plot, generated via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='3c279',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. UV Distance for 3c279 for "+asdm+" . Hit <Enter> to proceed.")<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='Titan',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
user_input = input("Examining amplitude vs. UV Distance for Titan for "+asdm+" . Hit <Enter> to proceed [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
<br />
<br />
It can also be useful to examine the average amplitude as a function of frequency for each target. This allows one to check for lingering atmospheric effects, unexpected line emission or absorption in the calibrators, or decreased sensitivity due to "roll-off" of the telescope sensitivity at the band edges. These plots are created by the sequence of commands below, where we have broken up the script to loop separately over the Northern and Southern Mosaics to reflect the different source names.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names = ["3c279","Titan","NGC*"]<br />
<br />
for asdm in basename_north:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+". Hit <Enter> to proceed.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names = ["3c279","Titan","Ant*"]<br />
<br />
for asdm in basename_south:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+" . Hit <Enter> to proceed.")<br />
<br />
</source><br />
<br />
<br />
For this command notice that we can see the CO(3-2) line in the Antennae even before calibration (see <xr id="plotms_amp_vs_freq_Antennae.png"/>) and that Titan also shows evidence of a strong line (also <xr id="plotms_amp_vs_freq_Titan.png"/>)! This will need to be flagged before we can use Titan to calibrate the flux scale of our data.<br />
<br />
This suite of plots (along with the earlier inspection of the Tsys tables) gives us the tools we need to identify problematic data through the data sets. We use this to generate a set of inspection-driven {{flagdata}} commands for each data set. We apply these before the bandpass and gain calibration.<br />
<br />
==Apply Flagging==<br />
Based on this inspection and the other plots we have made, we now flag problematic portions of the data. We break up the flags by reason for flagging in order to illustrate the process. As you reduce your own data it may be more efficient to group flags by data set and make use of the flagcmd command. Except for the "post-calibration" flagging, the inspection plots that we just looked through have already revealed all of the problems that we flag. We structure the guide so that the flagging is grouped in one place.<br />
<br />
As before, we may wish to reset our flags before beginning (particularly if one iterates this process) via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms',mode='unflag', flagbackup = False)<br />
</source><br />
<br />
Remember that we dropped the flagged data when splitting out after the WVR and Tsys calibration, so this should not undo your "A Priori" flagging of shadowed data, autocorrelations, etc.. In any case this unflagging step is not necessary during the first iteration.<br />
<br />
* '''Edge Channels'''<br />
<br />
ALMA's sensitivity decreases near the edge of the baseband and it is often useful to check for a 'roll-off' in sensitivity near the edge of the band. This will appear as a downturn in amplitude as a function of channel near the edge of the window in the uncalibrated data, as a flaring due to increased noise at the spw edges in the calibrated data. It will also be visible in the amplitude part of the bandpass calibration table. Because our FDM spw does not cover the full baseband, we do not see a strong roll off in our data (see <xr id="amp_vs_channel_example.png"/>), where there is only a mild hint of a roll-off at the high end) but we do flag a (very) few channels at the high and low-frequency edge of the data set to be safe.<br />
<br />
<figure id="amp_vs_channel_example.png"><br />
[[File:amp_vs_channel_example.png|200px|thumb|right|<caption> Amplitude vs. channel for one uncalibrated antenna pair. This kind of plot can be inspected to get an idea of the presence or magnitude of any roll-off in sensitivity near the edges of the spectral window.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:0~7,0:3831~3839', flagbackup = False)<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:3260~3320', flagbackup = False)<br />
</source><br />
<br />
* '''Problematic Tsys measurements'''<br />
<br />
Above we noted issues with the Tsys measurements for both DV04 and DV12. We flag the affected data. Each of these issues should be visible in the Tsys plots you made above (e.g., see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/> and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/>).<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04',flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X1d5"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X392"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
</source><br />
<br />
* '''Unreliable Short-Spacing Measurements on Titan'''<br />
<br />
<figure id="amp_vs_uv_titan_obs.png"><br />
[[File:amp_vs_uv_titan_obs.png|200px|thumb|right|<caption> Observed amplitude vs. uv-distance for observations of Titan in the first data set. Note the scatter for low projected antenna separations. We will flag these short-spacing data, which may reflect contamination by Saturn, and use only the more extended baselines for flux calibration.</caption>]]<br />
</figure><br />
<br />
Saturn may contaminate the short u-v spacings from Titan. In any case these often show significant scatter (<xr id="amp_vs_uv_titan_obs.png"/>), so we flag them. There are still enough baselines to determine a good amplitude calibration for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~40', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
</source><br />
<br />
* '''Delay Issues''' <br />
<br />
<figure id="phase_vs_freq_DV13.png"><br />
[[File:phase_vs_freq_DV13.png|200px|thumb|right|<caption> Phase vs. frequency for DV13 in a data set where this antenna shows evidence of imperfect delay calibration.</caption>]]<br />
</figure><br />
<br />
DV13 and a few other antennas show signatures of an imperfect delay calibration. This is most easily identified via strong "wrapping" of phase as a function of frequency (see <xr id="phase_vs_freq_DV13.png"/>). Such effects can be calibrated out with mild delay issues largely accounted for by the bandpass solution. The phase wrapping in DV13 seems weak enough that we will trust the calibrations to remove it. For a more extreme example see the CASA guide describing the calibration of [[NGC3256Band3]].<br />
<br />
* '''Missing Phase Calibrator Observations'''<br />
<br />
<figure id="amp_vs_time_missing_scans.png"><br />
[[File:amp_vs_time_missing_scans.png|200px|thumb|right|<caption> Amplitude vs. time colored by field for a data set where the final visit to the phase calibrator is missing. We will flag the last set of source data to ensure that each visit to the source is flanked in time by visits to the phase calibrator.</caption>]]<br />
</figure><br />
<br />
As a general rule, we want to be sure that observations of the phase calibrator (3c279) bracket each source observation. Two of the data sets do not include a final phase calibrator observation (see <xr id="amp_vs_time_missing_scans.png"/>) and for those two cases we flag the affected source observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='00:53:47~01:08:00',flagbackup = False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV10',timerange='19:46:20~20:34:40',flagbackup=False)<br />
</source><br />
<br />
* '''Unexpected Scatter or Discontinuity in the Data'''<br />
<br />
For several antennas we find sudden jumps in the phase of the phase calibrator as a function of time. These are visible in the plots of uncalibrated phase vs. time for single baselines above, and we show an example in <xr id="phase_vs_time_DV09.png"/>. It will not be possible to effectively interpolate the phase between measurements when we see these discontinuities. The safest approach is to flag the source data across these jumps. We do so here (though note that the last two flaggings are borderline cases).<br />
<br />
<figure id="phase_vs_time_DV09.png"><br />
[[File:phase_vs_time_DV09.png|200px|thumb|right|<caption> Phase vs. time for DV09 on a problematic day. It may prove problematic to calibrate the data near this discontinuity so we flag data near this time.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09', timerange='21:24:09~21:35:35', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09',timerange='23:30:52~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM01',timerange='23:16:50~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM03',timerange='23:16:50~24:10:00',flagbackup=False)<br />
</source><br />
<br />
* '''Outliers Visible After Calibration'''<br />
<br />
<figure id="amp_vs_uvdist_outliers.png"><br />
[[File:amp_vs_uvdist_outliers.png|200px|thumb|right|<caption> Amplitude vs. u-v distance ''after'' calibration. Note the outlying data. We track these down using the select (box with green "+") and locate (magnifying glass) features inside plotms and identify several problematic baselines across our data. ''Note that you cannot make this plot at this point in the guide, these pathologies become evident after calibration, requiring an iterative approach to reduction.''</caption>]]<br />
</figure><br />
<br />
Often issues with the data may become evident after calibration (i.e., after the next few steps that we apply). These data can appear as outliers in diagnostic plots for the calibrated data or even show up in the imaging stages. Once these are identified, best practice is to apply this new flagging then redo the calibration (if the issue is very minor, then re-calibrating may not be necessary).<br />
<br />
<source lang="python"><br />
# In CASA<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='21:18:00~21:22:15', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV01&DV04', flagbackup=False)<br />
</source><br />
<br />
Now that we've applied our flagging, back up the flags as version "User" using {{flagmanager}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis=asdm+'.wvrtsys.ms',mode='save',versionname ='User')<br />
</source><br />
<br />
Applying this flagging will remove the most egregious pathologies from the data. We are now ready to calibrate the data.<br />
<br />
==Bandpass Calibration==<br />
<br />
We begin by calibrating the phase and amplitude response of each antenna as a function of frequency, called "bandpass calibration." We have already seen that the data contain smooth but systematic variations in both phase and amplitude as a function of frequency. We can see this again in a more compact form by plotting phase as a function of frequency for all baselines associated with each antenna (<xr id="plotms_phase_vs_freq_example.png"/>).<br />
<br />
<figure id="plotms_phase_vs_freq_example.png"><br />
[[File:plotms_phase_vs_freq_example_6.1.png|200px|thumb|right|<caption> Phase vs. frequency for the bandpass calibrator, 3c279 in the first data set. We plot all baselines with DV02, averaged over time, and show only the 'XX' correlation.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='freq', yaxis='phase', <br />
selectdata=True, field='3c279', correlation='XX',<br />
avgtime='1e8', avgscan=True, antenna='*&*',<br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. frequency for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
Each plot shows phase as a function of frequency for all baselines with one antenna for 3c279. We plot only the 'XX' correlation, colorizing by baseline. With '''iteraxis''' set to antenna the green arrows at the bottom of {{plotms}} will cycle through antennas. By using '''avgscan''' and a large '''avgtime''' we average all scans and integrations. <br />
<br />
The phase (and amplitude) also varies as a function of time, as we saw before. Here are the similar plots for phase vs. time (see <xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb-phasecont.png"><br />
[[File:Uid_A002_X1ff7b0_Xb-phasecont_6.1.png|200px|thumb|right|<caption> Phase vs. time for the bandpass calibrator, 3c279. Averaged over channel. Only baselines with antenna DV02, and corr='XX'</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='phase', <br />
selectdata=True, field='3c279', <br />
spw='0:1200~1299', antenna='*&*',correlation='XX',<br />
avgchannel='100', avgscan=True, <br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. time for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
<xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/> shows that the phase varies with time. We need to take this temporal variation into account when we solve for the frequency variations. Therefore we carry out the bandpass calibration in two steps. First, we use {{gaincal}} to solve for the variation of phase as a function of time for 3c279 on very short timescales. We set {{gaincal}} to derive a separate phase solution for each antenna every integration by setting '''solint''' to 'int'. We solve, averaging together only a small fraction of the total bandpass (channels 1100-1300) to avoid the effects of the phase vs. frequency behavior. We will then apply this solution to remove time-dependent behavior when we solve for the frequency response of the antennas with {{bandpass}}.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
An integration is the smallest time quantum of observation in the data, usually a few seconds. <br />
You can check the integration length for each scan in listobs. <br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
for asdm in basename_all:<br />
print ("Running a short solution interval phase calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bpphase.gcal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
selectdata=True,field = '3c279',spw = '0:1100~1300',<br />
caltable = asdm+'.bpphase.gcal',<br />
solint = 'int',refant = 'DV11',calmode='p')<br />
</source><br />
<br />
Now we use {{bandpass}} to solve for the frequency response of each antenna. To do this, we average all data in time by setting '''solint''' to 'inf' (that is, 'infinite'). We allow combination across scans and the different field IDs found for 3c279 by setting '''combine''' to "scan,field". We apply the phase vs. time calibration that we just derived on-the-fly using the parameter "gaintable".<br />
<br />
<source lang="python"><br />
for asdm in basename_all:<br />
print ("Running a bandpass calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bandpass.bcal')<br />
bandpass(vis = asdm+'.wvrtsys.ms',<br />
field = '3c279',<br />
gaintable = asdm+'.bpphase.gcal',<br />
caltable = asdm+'.bandpass.bcal',<br />
bandtype='B',<br />
solint = 'inf',combine = 'scan,field', solnorm=True,refant = 'DV11',<br />
minblperant=3,minsnr=2,fillgaps=62)<br />
</source><br />
<br />
in these calls:<br />
<br />
*'''caltable''' specifies the output calibration table<br />
*'''gaintable''' specifies any calibration tables to be applied "on the fly" to the data before solving.<br />
*'''solint''' sets the time interval for which solutions are derived for each antenna.<br />
*'''refant''' set the reference antenna, here DV11, which is defined to have zero correction by construction.<br />
*'''calmode''' 'p' sets {{gaincal}} to calibrate the phase only, other options are 'a'mplitude or 'ap' - amplitude and phase.<br />
*'''minblperant''' sets the minimum baselines required per antenna for a successful solution.<br />
*'''minsnr''' sets the minimum signal-to-noise ratio required for a successful solution.<br />
*'''bandtype''' here 'B' tells {{bandpass}} to solve for the phase and frequency response of each antenna in each channel, averaging data in time across the solution interval.<br />
*'''fillgaps''' tells {{bandpass}} to interpolate across channel gaps 1 channel wide.<br />
*'''solnorm''' tells {{bandpass}} to normalize the bandpass amplitude and phase corrections to have magnitude unity. The absolute scale of the calibration will come from our later {{gaincal}} solutions.<br />
<br />
Do not worry about the message "Insufficient unflagged antennas" when running the {{bandpass}} task. This indicates that {{bandpass}} is failing on the flagged edge channels, which is expected.<br />
<br />
It is now a good idea to plot both sets of solutions to look for irregularities, especially:<br />
<br />
* discontinuities in the phase vs. time solution<br />
* rapid wrapping of phase in either phase vs. time or bandpass solution<br />
* large roll-off in the amplitude response near the band edge in the bandpass solution<br />
* large scatter in any solution.<br />
<br />
We loop through and using analysis utils, again generating .png files of each calibration. '''For what systems is this true?''' As the bandpass plots take a while you may want to go have a cup of coffee and inspect them using your favorite image viewer. Otherwise, switch the '''interactive''' parameter to True to see them in real time instead.<br />
<br />
<figure id="uid___A002_X1ff7b0_X1c8.bpphase.page1.png"><br />
[[File:uid___A002_X1ff7b0_X1c8.bpphase.page1_6.1.png|200px|thumb|right|<caption> Short interval phase vs. time solution carried out and applied during bandpass calibration, here for the first set of antennas for the first data set. This solution removes any systematic variations in phase vs. time.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1.CASA3.4.png"><br />
[[File:Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1_6.1.png|200px|thumb|right|<caption> Bandpass amplitude solution for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X1ff7b0_Xb.bcal_phase.page1.png"><br />
[[File:uid___A002_X1ff7b0_Xb.bcal_phase.page1.png|200px|thumb|right|<caption> Phase vs. frequency calibration from the bandpass calibration for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<br />
<!--<br />
Again this warning:<br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
--><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
os.system('rm -rf cal_plots/*bandpass*.png')<br />
for asdm in basename_all:<br />
plotbandpass(caltable=asdm+'.bandpass.bcal',<br />
field='',xaxis='freq',yaxis='both',<br />
figfile='cal_plots/'+asdm+'.bandpass.png',<br />
showatm=True,interactive=False,subplot=42)<br />
</source><br />
<br />
==Absolute Flux Calibration==<br />
<br />
The bandpass calibration will account for the phase and amplitude response of our antennas as a function of frequency. We now solve for the absolute flux scale of the data by referencing to Titan and in the next section we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
Before using Titan to set the flux, there is an important systematic to account for. When we looked at the integrated spectra of our targets above, remember that Titan showed a whopping spectral line, in fact the same CO(3-2) line that we wish to observe in the Antennae. We will set the flux of Titan (and thus all of our data) by referencing to a model in casa that does not account for this line. Therefore we need to flag the part of the Titan observations contaminated by the line before we calibrate (you can see the affected channel range in <xr id="Antennae-TitanLine.png"/>). We run the following additional flagging step:<br />
<br />
<figure id="Antennae-TitanLine.png"><br />
[[File:Antennae-TitanLine_6.1.png|200px|thumb|right|<caption> Uncalibrated amplitude vs. channel plot for the flux calibrator, Titan (uid___A002_X1ff7b0_Xb dataset). Averaged over time, corr='XX', and colorized by baseline.</caption>]]<br />
</figure><br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Flagging CO(3-2) in Titan for "+asdm)<br />
flagdata(vis=asdm+'.wvrtsys.ms',flagbackup=False, <br />
field='Titan', spw='0:1100~1700')<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis =asdm+'.wvrtsys.ms',mode = 'save',versionname = 'Calibration')<br />
</source><br />
<br />
Next, we will use the {{setjy}} task to read the predicted complex visibilities for Titan into the MODEL column of each data set.<br />
<br />
<source lang="python"><br />
# in CASA<br />
for asdm in basename_all:<br />
print ("Reading model for Titan into "+asdm)<br />
setjy(vis = asdm+'.wvrtsys.ms',field = 'Titan',<br />
usescratch=True,scalebychan=True,<br />
standard = 'Butler-JPL-Horizons 2012')<br />
</source><br />
<br />
{{setjy}} will output the flux of Titan to the CASA logger and it is worth recording this information. The flux of Titan at these frequencies is about 3.3 Jy. For example, for dataset uid___A002_X1ff7b0_Xb.wvrtsys.ms:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Titan: spw0 Flux:[I=3.2637,Q=0.0,U=0.0,V=0.0] +/- [I=0.0,Q=0.0,U=0.0,V=0.0] Jy @ 344.85GHz<br />
</pre><br />
<br />
Now we are going to take a look at the Titan model for one dataset:<br />
<br />
<source lang="python"><br />
# in CASA<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
</source><br />
<br />
<figure id="2012_titan_model_5.1.png">[[File:2012_titan_model_6.1.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2012'.</caption>]]</figure><br />
<figure id="2010_titan_model.png">[[File:2010_titan_model.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2010'.</caption>]]</figure><br />
<br />
<br/><br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
The setjy invocation made in this section uses the flux density standard '''standard='Butler-JPL-Horizons 2012' '''. Previous versions of this guide used an older flux density standard '''standard='Butler-JPL-Horizons 2010' '''. <xr id="2012_titan_model_5.1.png"/> and <xr id="2010_titan_model.png"/> show the differences in the Titan models produced using these two standards. <br />
</div><br />
<br />
==Gain (Phase and Amplitude) Calibration==<br />
<br />
With the flux now properly scaled, we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
We begin by running a short-solution interval {{gaincal}} to solve for phase variation on short timescales during observations of our two calibrators, with '''solint''' set to "int". By applying this on-the-fly, we can remove any decorrelation in the data due to phase scatter when we solve for the amplitude calibration. However, there is no benefit to using this short-timescale solution to calibrate the source because we only have information on the gain during calibrator visits (though see the Imaging portion of this guide). Instead we will solve for the gains to apply to the source using a longer '''solint''' in just a moment.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out short timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.intphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.intphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='int',minsnr=2.0, minblperant=4)<br />
</source><br />
<br />
Now we derive the longer timescale phase calibration table using '''solint''' set to "inf", but not allowing scan combination. This calibration has higher signal to noise due to combining more data, and for the purposes of correcting the source, it is just as precise as the short timescale solution.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out longer timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.scanphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.scanphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='inf',minsnr=2.0,minblperant=4)<br />
</source><br />
<br />
Now we apply the short-timescale phase solution and carry out a scan length ('''solint''' set to "inf") calibration of the data using '''calmode''' of 'ap'.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Solving for longer (scan) interval amplitude solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.amp.cal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
gaintable =[asdm+'.bandpass.bcal',asdm+'.intphase.gcal'],<br />
caltable = asdm+'.amp.cal',<br />
calmode='ap',<br />
field = 'Titan,3c279',<br />
spw='0:40~3800',<br />
refant = 'DV11',solint = 'inf', minblperant=4)<br />
</source><br />
<br />
This "amp.cal" solution gives us the amplitude variations as a function of time, but they are not yet pinned to a realistic scale except in the case of Titan, where we have solved using the model input by {{setjy}}. We will set the flux of our secondary calibrator 3c279 with reference to Titan using {{fluxscale}}.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Scaling amplitude calibration to match Titan for "+asdm)<br />
os.system('rm -rf '+asdm+'.flux.cal')<br />
fluxscale(vis = asdm+'.wvrtsys.ms',<br />
caltable = asdm+'.amp.cal',<br />
fluxtable = asdm+'.flux.cal',<br />
reference = 'Titan',<br />
transfer = '3c279')<br />
</source><br />
<br />
This new correctly-scaled flux table ".flux.cal" replaces the previous ".amp.cal" table as the correct amplitude calibration table to apply to the data, i.e., the ".flux.cal" contains both the time variability of the amplitude solved for in ".amp.cal" and the correct flux scaling set with {{fluxscale}}.<br />
<br />
Fluxscale will output the derived flux for 3c279 to the CASA logger. This information is worth noting. We find that the flux of 3c279 is 10.79 Jy, by averaging the fluxes obtained from the ten available datasets. If we check this value against reported flux measurements in the SMA calibrator list [http://sma1.sma.hawaii.edu/callist/callist.html], we find that a flux of 10.79 Jy agrees within a few per cent of a linear interpolation between the two 0.85 mm measurements closest in time to the ALMA observations: (23 May 2011, SMA 11.644 ± 0.583; 01 July 2011, 9.748 ± 0.488).<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used the older, Butler-JPL-Horizons 2010, flux density standard when you ran {{setjy}} earlier in this tutorial, the derived flux values for 3c279 will be slightly lower. The flux of 3c279, when averaged over all 10 measurement sets, will be 10.41 Jy.<br />
</div><br />
<br />
Now we plot the final phase and amplitude calibration tables for each data set. A well-behaved calibration table will show smooth variations as a function of time. Sudden jumps or wild variations among the antenna amplitude gains should prompt further investigation and possibly additional flagging.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting solutions for "+asdm)<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis='antenna',antenna='0~7',plotrange=[0,0,-180,180],<br />
gridrows=4,gridcols=1,showgui=False,<br />
plotfile=asdm+'.scanphase.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis = 'antenna', antenna='8~15', plotrange=[0,0,-180,180],<br />
showgui=False, gridrows=4, gridcols=1, <br />
plotfile=asdm+'.scanphase.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='0~7', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='8~15', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
<br />
</source><br />
<br />
==Apply the Calibrations and Inspect ==<br />
Now we will use {{applycal}} to apply the bandpass, phase, and amplitude calibration tables that we generated in the previous sections to the data. We apply the solutions separately to the bandpass and secondary ("phase") calibrator 3c279, the flux calibrator Titan, and the target source. In most data sets, the bandpass and secondary calibrator will not be the same and this step would include one additional {{applycal}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
for asdm in basename_north: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='NGC*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_south: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Ant*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
</source><br />
<br />
Here:<br />
* '''vis''' and '''field''' specify the measurement set and field to calibrate.<br />
* '''gaintable''' specifies the tables to apply to the data. There may be several tables applied all at once, here we apply the bandpass, phase, and flux calibrations.<br />
* '''interp''' specifies the type of interpolation used to match calibration tables to the data. If there are several gaintables then interp may be either a single value (e.g., "linear" or "nearest") or a list of values with size equal to the list of gaintables. In the case where interp is a list, applycal will match each element to the corresponding gaintable (e.g., first gaintable with first interp parameter).<br />
* '''gainfield''' specifies field from which to draw the calibration. As with interp, this can be a list of size matched to gaintable, so that the first element of gainfield will be the field used for the first table. For example, in the above commands the bandpass calibration (the first table) will always be applied from '3c279' (the first gainfield).<br />
* '''calwt''' indicates that the weights, which were derived from the Tsys measurements, should also be calibrated. Note that '''calwt''' is True by default.<br />
<br />
Once calibrations are applied, it is important to go back and inspect the calibrated data. New problematic antennas or baselines may be visible after calibration. Repeat the steps above, focusing on the CORRECTED data column. Bear in mind that for any point source calibrators we now expect to find phase scattering around zero and to find flat amplitudes as a function of u-v distance. Look for outliers and other signatures of problematic data. As a general rule, you will want to incorporate these data into your overall flagging script then rerun the whole calibration process, so that reduction is iterative. If the data only represent a minor problem, however, it may not be terribly harmful to flag them after the fact so that they do not interfere with imaging but trust that the calibrations are mostly unaffected.<br />
<br />
As an example of this inspection, we cycle through the corrected amplitudes and phases of 3c279 and Titan as a function u-v distance, to check that the phases are close to zero and the amplitudes are constant. <br />
<br />
<figure id="xb-checkcal-pha-cha.png"><br />
[[File:xb-checkcal-pha-cha_6.1.png|200px|thumb|right|<caption> Calibrated phase vs. channel plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<figure id="xb-checkcal-amp-time.png"><br />
[[File:xb-checkcal-amp-time_6.1.png|200px|thumb|right|<caption> Calibrated amplitude vs. time plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='phase',<br />
ydatacolumn='corrected', field='3c279',<br />
avgchannel='3840', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
In <xr id="xb-checkcal-pha-cha.png"/> and <xr id="xb-checkcal-amp-time.png"/> we plot phase vs. channel and amp vs. time for 3c279 for the uid___A002_X1ff7b0_Xb dataset. <br />
<br />
Finally we can use {{plotms}} to examine the corrected amplitude and phase of Antennae galaxies as a function of time and uv-distance (plots not shown):<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
for asdm in basename_north:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
avgtime='1e8', avgscan=True, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
for asdm in basename_south:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
avgtime='1e8', avgscan=True,avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
</source><br />
<br />
==Split and Concatenate Data for Northern and Southern Mosaics==<br />
The individual data sets are now calibrated. We can safely split out the calibrated data for our science target and drop the calibrators. As we do so, we will smooth the data in frequency, averaging together groups of 23 channels by setting '''width=23''' in {{split}}. The new data will have a channel width corresponding to about ~10 km/s, very similar to the SMA data being verified. The factor of >20 drop in data volume will also make the imaging steps ''much'' more tractable.<br />
<br />
Note that you will see a warning that the last output channel in the new spw 0 will be dropped, as it has less than 23 channels over which to average:<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO MSTransformDataHandler The last output channel of spw 0 has only 22 input channels.<br />
WARN MSTransformManager Not enough input channels to populate output channel n# 166 from SPW 0.<br />
WARN MSTransformManager The channel will be dropped in order to have an uniform grid.<br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_north:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'NGC*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
<br />
for asdm in basename_south:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'Ant*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
</source><br />
<br />
For convenience we concatenate all data for the Northern Mosaic into a single big MS and place all data for the Southern Mosaic into another file. To do this, we construct a list that holds the names of all the Southern Mosaic MS files and another that holds the name of all the Northern Mosaic MS files then feed these into the {{concat}} task. <br />
<br />
Before we do this, we'll take a brief aside to remove Pointing information from the calibrated data. Normally, the pointing information would apply important corrections to be used while imaging the data. However, some aspects of this are still under development and the pointing information in these data interacts poorly with CASA. We will remove the pointing information using the CASA toolkit Table tool (tb). ''This kind of operation is dangerous and should not be a regular feature of your CASA reduction.''<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Manually removing pointing table from "+asdm+".cal.ms ... Please be careful!")<br />
tb.open(asdm+'.cal.ms/POINTING',nomodify=False)<br />
a = tb.rownumbers()<br />
tb.removerows(a)<br />
tb.close()<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
cal_south_vis = [vis+'.cal.ms' for vis in basename_south]<br />
cal_north_vis = [vis+'.cal.ms' for vis in basename_north]<br />
<br />
os.system('rm -rf Antennae_South.cal.ms')<br />
concat(vis=cal_south_vis, concatvis='Antennae_South.cal.ms', timesort=True)<br />
<br />
os.system('rm -rf Antennae_North.cal.ms')<br />
concat(vis=cal_north_vis, concatvis='Antennae_North.cal.ms', timesort=True)<br />
</source><br />
<br />
The syntax used to construct the 'cal_south_vis' variable loops over basename_south and makes a list after adding '.cal.ms' to each member. To see the list 'print (cal_south_vis)'.<br />
<br />
==Continue on to Imaging of the Science Target==<br />
Now you can continue on to the [http://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_6.1 imaging guide].<br />
{{Checked 6.1}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Xb-checkcal-pha-cha_6.1.png&diff=29409File:Xb-checkcal-pha-cha 6.1.png2020-10-01T19:09:23Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Calibration_6.1&diff=29408AntennaeBand7 Calibration 6.12020-10-01T19:06:31Z<p>Dkim: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide is written for CASA 6.1 and uses Python 3. The same functionality is implemented in Python 2 using CASA 5.7 at [[AntennaeBand7 Calibration 5.7]]'''<br />
<br />
*'''This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are provided at [[AntennaeBand7]]<br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see: [[AntennaeBand7_Imaging 6.1]]'''.<br />
<br />
==Overview==<br />
<br />
This part of the Antennae Band 7 CASA guide will step through the calibration of the visibility data. We will begin by flagging (marking as bad) data known to be useless before any inspection; for example, data where one telescope blocks the line of sight of another. We will then apply telescope-generated calibration tables to partially correct for atmospheric effects. After inspecting the data, we will flag some additional data that exhibit pathologies. Using observations of the calibrators Titan and 3c279, it will be shown how to derive the phase and amplitude response of individual antennas as a function of time and frequency ("phase", "amplitude", and "bandpass" calibrations). We will apply these solutions to the data and then extract the calibrated source data into a file appropriate for imaging in the [[AntennaeBand7_Imaging | Antennae Band 7 imaging guide]].<br />
<br />
The general procedure in this guide follows the other ALMA CASA guides: [[NGC3256Band3]] and [[TWHydraBand7]].<br />
<br />
==Unpack the Data==<br />
<br />
This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]. <br />
<br />
Once you have downloaded the data, unpack the file in a terminal outside CASA using<br />
<br />
<source lang="bash"><br />
<br />
tar -xvzf Antennae_Band7_UnCalibratedMSandTablesForReduction.tgz<br />
<br />
</source><br />
<br />
then change directory to the new directory <br />
<br />
<source lang="bash"><br />
<br />
cd Antennae_Band7_UnCalibratedMSandTablesForReduction<br />
<br />
</source><br />
<br />
You may wish to type<br />
<br />
<source lang="bash"><br />
<br />
ls<br />
<br />
</source><br />
<br />
to look at the files present. You should see a set of files with extension ".ms". These are CASA measurement set (MS) files. The data have already been converted to MS format from the native ALMA format using the CASA task {{importasdm}}. In addition to the data, we provide you with calibration tables containing system temperature (Tsys), water vapor radiometer (WVR), and antenna position information. For Early Science, these tables will either be pre-applied or supplied with the data.<br />
<br />
To begin, start CASA by typing<br />
<br />
<source lang="bash"><br />
<br />
casa<br />
<br />
</source><br />
<br />
Be sure that you are using the version indicated at the top of this page.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 6.1. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casalith<br />
version = casalith.version_string()<br />
print("You are using {}".format(version))<br />
if (version < '6.1'):<br />
print ("YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE.")<br />
print ("PLEASE UPDATE IT BEFORE PROCEEDING.")<br />
else:<br />
print ("Your version of CASA is appropriate for this guide.")<br />
</source><br />
<br />
==Initial Inspection==<br />
<br />
First we will take stock of what we have. If you have not already done so, begin by reviewing the description of the observations here: [[AntennaeBand7]]. The 10 data sets each target either the Northern or the Southern Mosaic, as follows:<br />
<br />
Northern Mosaic:<br />
*uid___A002_X1ff7b0_Xb.ms<br />
*uid___A002_X207fe4_X3a.ms<br />
*uid___A002_X207fe4_X3b9.ms<br />
*uid___A002_X2181fb_X49.ms<br />
<br />
Southern Mosaic:<br />
*uid___A002_X1ff7b0_X1c8.ms<br />
*uid___A002_X207fe4_X1f7.ms<br />
*uid___A002_X207fe4_X4d7.ms<br />
*uid___A002_X215db8_X18.ms<br />
*uid___A002_X215db8_X1d5.ms<br />
*uid___A002_X215db8_X392.ms<br />
<br />
The first step is to get basic information about the data: targets observed, time range, spectral setup, and so on. We do this using the task {{listobs}}, which will output a detailed summary of each dataset. Enter the following commands into CASA:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Define a python list holding the names of all of our data sets<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
# Initialize user-input string. (for Python testing)<br />
dummy_string = ''<br />
<br />
# Loop over each element in the list and create summary file using listobs<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.listobs.txt')<br />
listobs(vis=asdm+'.ms', listfile=asdm+'.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note that after cutting and pasting a 'for' loop like this you often have to press return twice to execute. You may also want to take care to paste a line at a time if you are having trouble copy and pasting. Even better, you can use "cpaste" to paste blocks of code. To do so type "cpaste" at the CASA prompt, paste your commands, and then type "--" and hit return on the final (otherwise empty) line. This should look something like this:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
CASA <8>: cpaste<br />
Pasting code; enter '--' alone on the line to stop.<br />
:basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
: "uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
: "uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
: "uid___A002_X215db8_X392"]<br />
:<br />
:for asdm in basename_all:<br />
: print (asdm)<br />
:--<br />
uid___A002_X1ff7b0_Xb<br />
uid___A002_X207fe4_X3a<br />
uid___A002_X207fe4_X3b9<br />
uid___A002_X2181fb_X49<br />
uid___A002_X1ff7b0_X1c8<br />
uid___A002_X207fe4_X1f7<br />
uid___A002_X207fe4_X4d7<br />
uid___A002_X215db8_X18<br />
uid___A002_X215db8_X1d5<br />
uid___A002_X215db8_X392<br />
<br />
CASA <9>: <br />
<br />
</pre><br />
<br />
cpaste should be ''much'' more robust than copying-and-pasting directly into the shell but if you have trouble, just carefully paste one line at a time directly into CASA and hit return until the desired command executes.<br />
<br />
These commands define a python list called "basename_all", which contains the name of all 10 MS files. The "for" loop executes for each element in basename_all, calling listobs and directing the output to a file called, e.g., "uid___A002_X1ff7b0_Xb.listobs.txt" for the first measurement set. You can browse through the listobs output as you would normally look at a text file (use emacs, vi, or another editor). You can also send the output to the terminal from inside of CASA. To do so type:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
or<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('more uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
CASA knows a few basic shell commands like 'cat', 'ls', and 'rm' but for more complex commands you will need to run them inside 'os.system("command")'. For more information see http://casa.nrao.edu/ .<br />
<br />
Here is an example of the (abridged) output from {{listobs}} for the first dataset in the list, uid___A002_X1ff7b0_Xb.ms, which targets the Northern Mosaic. You would see this if you had specified '''verbose''' to be False in the listobs call:<br />
<br />
<pre style="background-color: #fffacd;"><br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_Xb.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA(11 antennas)<br />
Data records: 181357 Total integration time = 4931.71 seconds<br />
Observed from 28-May-2011/01:25:27.6 to 28-May-2011/02:47:39.3 (UTC)<br />
<br />
Fields: 26<br />
ID Code Name RA Decl Epoch SrcId nRows <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 39116 <br />
1 none Titan 12:42:43.94813 -01.43.38.3190 J2000 1 10626 <br />
2 none NGC4038 - Antennae *12:01:53.17008 -18.52.37.9200 J2000 2 4818 <br />
3 none NGC4038 - Antennae *12:01:51.90301 -18.51.49.9437 J2000 2 6435 <br />
4 none NGC4038 - Antennae *12:01:52.43086 -18.51.49.9437 J2000 2 6424 <br />
5 none NGC4038 - Antennae *12:01:52.95871 -18.51.49.9437 J2000 2 5478 <br />
6 none NGC4038 - Antennae *12:01:53.48656 -18.51.49.9436 J2000 2 6435 <br />
7 none NGC4038 - Antennae *12:01:54.01441 -18.51.49.9436 J2000 2 6446 <br />
8 none NGC4038 - Antennae *12:01:52.16693 -18.51.56.4319 J2000 2 6435 <br />
9 none NGC4038 - Antennae *12:01:52.69478 -18.51.56.4318 J2000 2 6424 <br />
10 none NGC4038 - Antennae *12:01:53.22263 -18.51.56.4318 J2000 2 6446 <br />
11 none NGC4038 - Antennae *12:01:53.75049 -18.51.56.4318 J2000 2 6446 <br />
12 none NGC4038 - Antennae *12:01:51.90301 -18.52.02.9201 J2000 2 6435 <br />
13 none NGC4038 - Antennae *12:01:52.43086 -18.52.02.9200 J2000 2 6424 <br />
14 none NGC4038 - Antennae *12:01:52.95871 -18.52.02.9200 J2000 2 4818 <br />
15 none NGC4038 - Antennae *12:01:53.48656 -18.52.02.9200 J2000 2 4829 <br />
16 none NGC4038 - Antennae *12:01:54.01441 -18.52.02.9199 J2000 2 4829 <br />
17 none NGC4038 - Antennae *12:01:52.16694 -18.52.09.4082 J2000 2 4829 <br />
18 none NGC4038 - Antennae *12:01:52.69479 -18.52.09.4082 J2000 2 4829 <br />
19 none NGC4038 - Antennae *12:01:53.22264 -18.52.09.4082 J2000 2 3872 <br />
20 none NGC4038 - Antennae *12:01:53.75049 -18.52.09.4081 J2000 2 4829 <br />
21 none NGC4038 - Antennae *12:01:51.90301 -18.52.15.8964 J2000 2 4829 <br />
22 none NGC4038 - Antennae *12:01:52.43087 -18.52.15.8964 J2000 2 4829 <br />
23 none NGC4038 - Antennae *12:01:52.95872 -18.52.15.8963 J2000 2 4818 <br />
24 none NGC4038 - Antennae *12:01:53.48657 -18.52.15.8963 J2000 2 4818 <br />
25 none NGC4038 - Antennae *12:01:54.01442 -18.52.15.8963 J2000 2 4840 <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 354971.074 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 354916.143 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11 'name'='station' <br />
ID= 0-3: 'DV02'='A015', 'DV04'='J505', 'DV06'='T704', 'DV07'='A004', <br />
ID= 4-7: 'DV08'='A072', 'DV09'='A008', 'DV10'='A009', 'DV11'='A016', <br />
ID= 8-10: 'PM01'='T702', 'PM02'='A017', 'PM03'='J504'<br />
================================================================================<br />
<br />
</pre><br />
<br />
And here is an extract from the full '''verbose''' {{listobs}} for uid___A002_X1ff7b0_X1c8.ms, which targets the Southern Mosaic (note that we have snipped out the record of individual scans):<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_X1c8.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA<br />
Data records: 175615 Total integration time = 4927.1 seconds<br />
Observed from 28-May-2011/02:50:18.2 to 28-May-2011/04:12:25.3 (UTC)<br />
<br />
<snip><br />
<br />
Fields: 33<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 12232 <br />
1 none Titan 12:42:44.82765 -01.43.41.4224 J2000 1 10615 <br />
2 none 3c279 12:56:11.16600 -05.47.21.5250 J2000 2 27764 <br />
3 none Antennae 12:01:53.17008 -18.52.37.9200 J2000 3 4829 <br />
4 none Antennae 12:01:52.18699 -18.53.30.3952 J2000 3 3883 <br />
5 none Antennae 12:01:52.64413 -18.53.26.6494 J2000 3 3883 <br />
6 none Antennae 12:01:53.10127 -18.53.22.9035 J2000 3 3872 <br />
7 none Antennae 12:01:53.55841 -18.53.19.1577 J2000 3 4818 <br />
8 none Antennae 12:01:54.01554 -18.53.15.4119 J2000 3 4829 <br />
9 none Antennae 12:01:54.47268 -18.53.11.6661 J2000 3 4829 <br />
10 none Antennae 12:01:54.92982 -18.53.07.9203 J2000 3 3872 <br />
11 none Antennae 12:01:55.38696 -18.53.04.1744 J2000 3 3883 <br />
12 none Antennae 12:01:55.84409 -18.53.00.4286 J2000 3 4840 <br />
13 none Antennae 12:01:56.30123 -18.52.56.6828 J2000 3 4818 <br />
14 none Antennae 12:01:52.18700 -18.53.22.9033 J2000 3 4829 <br />
15 none Antennae 12:01:52.64414 -18.53.19.1575 J2000 3 4818 <br />
16 none Antennae 12:01:53.10128 -18.53.15.4116 J2000 3 4818 <br />
17 none Antennae 12:01:53.55842 -18.53.11.6658 J2000 3 4840 <br />
18 none Antennae 12:01:54.01555 -18.53.07.9200 J2000 3 3872 <br />
19 none Antennae 12:01:54.47269 -18.53.04.1742 J2000 3 4829 <br />
20 none Antennae 12:01:54.92983 -18.53.00.4284 J2000 3 4829 <br />
21 none Antennae 12:01:55.38697 -18.52.56.6825 J2000 3 4829 <br />
22 none Antennae 12:01:55.84410 -18.52.52.9367 J2000 3 4829 <br />
23 none Antennae 12:01:51.72988 -18.53.19.1572 J2000 3 4818 <br />
24 none Antennae 12:01:52.18702 -18.53.15.4114 J2000 3 4829 <br />
25 none Antennae 12:01:52.64415 -18.53.11.6656 J2000 3 4829 <br />
26 none Antennae 12:01:53.10129 -18.53.07.9197 J2000 3 2266 <br />
27 none Antennae 12:01:53.55843 -18.53.04.1739 J2000 3 2266 <br />
28 none Antennae 12:01:54.01557 -18.53.00.4281 J2000 3 3212 <br />
29 none Antennae 12:01:54.47270 -18.52.56.6823 J2000 3 3234 <br />
30 none Antennae 12:01:54.92984 -18.52.52.9365 J2000 3 3212 <br />
31 none Antennae 12:01:55.38698 -18.52.49.1906 J2000 3 2266 <br />
32 none Antennae 12:01:55.84411 -18.52.45.4448 J2000 3 3223 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 356845.586 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 356900.518 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11:<br />
ID Name Station Diam. Long. Lat. <br />
0 DV02 A015 12.0 m -067.45.15.3 -22.53.26.0 <br />
1 DV04 J505 12.0 m -067.45.18.0 -22.53.22.8 <br />
2 DV06 T704 12.0 m -067.45.16.2 -22.53.22.1 <br />
3 DV07 A004 12.0 m -067.45.15.9 -22.53.28.0 <br />
4 DV08 A072 12.0 m -067.45.12.6 -22.53.24.0 <br />
5 DV09 A008 12.0 m -067.45.15.4 -22.53.26.8 <br />
6 DV10 A009 12.0 m -067.45.16.1 -22.53.26.1 <br />
7 DV11 A016 12.0 m -067.45.16.4 -22.53.25.1 <br />
8 PM01 T702 12.0 m -067.45.18.6 -22.53.24.1 <br />
9 PM02 A017 12.0 m -067.45.15.9 -22.53.26.8 <br />
10 PM03 J504 12.0 m -067.45.17.0 -22.53.23.0 <br />
</pre><br />
<br />
This output shows that three sources were observed in each data set: 3c279, Titan, and the Antennae.<br />
<br />
* The '''Antennae''' are our science target. Note that the source name changes between the Northern Mosaic, where it is "NGC4038 - Antennae", and the Southern Mosaic, where it is just "Antennae". Also note that the source corresponds to a number of individual fields (see the Field ID column). These are the individual mosaic pointings. There are 23 for the Northern Mosaic and 29 for the Southern Mosaic.<br />
* '''Titan''' is observed once and will be used to set the absolute flux scale of the data.<br />
* '''3c279''' plays two roles: it will serve as our bandpass calibrator, to characterize the frequency response of the antennas, and because it is fairly close on the sky to the Antennae (18.6 degrees away) it will serve as our secondary calibrator (also referred to as the "phase calibrator" or "gain calibrator"), to track changes in the phase and amplitude response of the telescopes over time. Observations of 3c279 are interleaved with observations of the Antennae.<br />
<br />
The output also shows that the data contain many spectral windows. Using the labeling scheme in the listobs above these are:<br />
<br />
* '''spw 0''' targets ~185 GHz and holds water vapor radiometer data<br />
* '''spw 1''' and '''spw 3''' hold our science data. These are "Frequency Domain Mode" (FDM) data with small (0.49 MHz) channel width and wide (1.875 GHz) total bandwidth. As a result these have a lot of channels (3840). spw 1 holds the lower sideband (LSB) data and includes the CO(3-2) line. We will focus on these data. For the CO(3-2) line the channel width corresponds to 0.426 km/s and the bandwidth of spw 1 to 1634 km/s.<br />
* '''spw 2''' and '''spw 4''' hold frequency-averaged versions of spw 1 and 3 ("Channel 0" for those familiar with AIPS). These are used for some quick automated inspection. We will not use them here but we will carry out an equivalent inspection using spw 1.<br />
* '''spw 5''' and '''spw 7''' hold lower a resolution processing ("Time Domain Mode", TDM) of the data from the same part of the spectrum (baseband) as spws 1 and 3. These data have only 128 channels across 2 GHz bandwidth and so have a much coarser channel spacing than the FDM data. These were used to generate the calibration tables that we include in the tarball but will not otherwise appear in this guide.<br />
<br />
The final column of the listobs output in the logger (not shown above) gives the scan intent. Later we will use this information to flag the pointing scans and the hot and ambient load calibration scans.<br />
<br />
We'll now have a look at the configuration of the antennas used to take the data using the task {{plotants}} (<xr id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"><br />
[[File:Uid_A002_X1ff7b0_Xb.ANT_6.1.png|200px|thumb|right|<caption> Position of antennas in dataset uid_A002_X1ff7b0_Xb obtained using task plotants. </caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Antenna configuration for : "+asdm)<br />
plotants(vis=asdm+'.ms', figfile=asdm+'.plotants.png')<br />
clearstat()<br />
dummy_string = input("Hit <Enter> to see the antenna configuration for the next data set.")<br />
</source> <br />
<br />
This will loop through all 10 data sets, show you the antenna position for each, and save that as a file named, e.g., "uid___A002_X1ff7b0_Xb.plotants.png" for the first data set. The "input" command asks CASA to wait for your input before proceeding. If you would prefer to just browse the .png files after the fact you can remove this. Notice that the antenna setup changes, but only slightly, over the course of the 10 data sets.<br />
<br />
==How to Deal With 10 Measurement Sets==<br />
<br />
It should already be clear from the initial inspection that dealing with 10 data sets at the same time can be a bit problematic. This is especially tricky in our case because the Antennae data contain two distinct sets of observations: the Northern and Southern Mosaics. The source name changes between these two scripts and there are different numbers of fields in the mosaic.<br />
<br />
''As a general rule one would reduce each individual observation separately or at the very least only group data observed in a uniform way and very close in time.'' <br />
<br />
Unfortunately, a CASA Guide stepping through the reduction for each of 10 data sets would quickly become unwieldy. Therefore we will use a few tricks to reduce the Antennae data in a kind of batch mode. You have already seen the first trick: we can define a python list holding the names of each data set and then loop over this list to execute the same command on each data set. For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print (asdm)<br />
</source><br />
<br />
You only need to define your list of MS files once per CASA session. Then "basename_all" will be a variable in the casapy shell. You can check if it exists by typing "print (basename_all)". In the interests of allowing you to easily exit and restart CASA and pick this guide up at any point we will redefine "basename_all" in each section of the guide. Feel free to skip this step if you've already defined it in your session.<br />
<br />
This page will step you through the reduction of the whole Antennae Band 7 SV data set using these 'for' loops. We will not be able to show every diagnostic plot but we give an example of each and the syntax to generate the rest. Also please be aware that even on a very fast machine this whole process can take a while, we are simply dealing with a lot of data.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
One potential "gotcha" is that the source name changes between the two data sets. Therefore at several points we will break apart our loop to iterate separately over the Northern and Southern Mosaics, where the source can be referred unambiguously. Another subtle point is that 3c279 appears with two distinct field IDs in the Southern Mosaic, but only one in the Northern Mosaic. We will largely avoid this by referring to the source by its name but if you tried to use field ID numbers and mingled the two data sets this could cause confusion.<br />
</pre><br />
<br />
==''A Priori'' Flagging==<br />
<br />
Even before we look in detail, we know that there are some data that we wish to exclude. We will start by flagging "shadowed" data where one antenna blocks the line of sight of another. We will also flag scans that were used to carry out pointing and atmospheric calibration, identified by their scan intent. Finally, we'll flag the autocorrelation data (the correlation of the signal from an antenna with itself) as we are only interested in cross-correlation data to make an interferometric image.<br />
<br />
Start by defining our list of MS files:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
You may want to reset the flagging if you have tried this step before and are starting over though this is not necessary on your first time through. Do so using {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Resetting flags for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='unflag', flagbackup=False)<br />
</source><br />
<br />
Then flag shadowed data using the command {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging shadowed data for "+asdm)<br />
flagdata(vis=asdm+'.ms',mode = 'shadow', flagbackup = False)<br />
</source><br />
<br />
In the {{flagdata}} task we choose:<br />
<br />
* '''vis''' = asdm+'.ms' : each measurement set<br />
* '''mode''' = 'shadow': flag shadowed data<br />
* '''flagbackup''' = False: Do not automatically back up the flag files. We will save all of the ''a priori'' flags together using {{flagmanager}} at the end of this subsection and save some space and time.<br />
<br />
The relevant calibration information has already been extracted from the pointing and atmospheric scans and we will not need them below. Now flag the pointing scans using {{flagdata}} in 'manualflag' mode and selecting on 'intent':<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging calibration scans for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='manual', intent='*POINTING*', flagbackup = False)<br />
</source><br />
<br />
Note that because the atmospheric calibration scans contain only TDM spectral windows, they will be removed automatically when we separate out the FDM data below.<br />
<br />
Now flag the autocorrelation data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging autocorrelation data for "+asdm)<br />
flagdata(vis=asdm+'.ms',autocorr=True,flagbackup=False)<br />
</source><br />
<br />
Finally store the current flags information using {{flagmanager}}: <br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Backing up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'save', versionname = 'Apriori')<br />
</source><br />
<br />
Where '''versionname''' is just the name we assign to the current flagging state in the data. We can now roll back the flags to match the current version, called 'Apriori', whenever we want. There is no reason to do this now, but the syntax would be:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Restoring up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'restore', versionname = 'Apriori')<br />
</source><br />
<br />
<br />
It would have been possible to set {{flagdata}} to '''flagbackup'''=True so that it stores the flags at each of the flagging step automatically, but this way it is a bit more efficient with regard to time and disk space. More important, lumping all the ''a priori'' flagging together gives us a natural point to roll back to if we get in trouble.<br />
<br />
<br />
The flagmanager task will also allow you to view the saved flagging versions,<br />
including those created by running flagdata with flagbackup=True.<br />
<br />
For example try <br />
<br />
<source lang="python"><br />
# In CASA<br />
flagmanager(vis='uid___A002_X2181fb_X49.ms', mode='list')<br />
</source><br />
<br />
The output in the logger should list the Apriori flagging that we have applied.<br />
It will also indicate versions associated with any flagdata command where you<br />
did not set flagbackup=False. Other tasks, for example applycal, will also create<br />
flag version tables.<br />
<br />
==Create and Apply Tsys, WVR, and Antenna Position Calibration Tables==<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
===Tsys===<br />
<br />
The Tsys calibration gives a first-order correction for the atmospheric opacity as a function of time and frequency and associates weights with each visibility that persists through imaging.<br />
<br />
Use gencal to create the Tsys calibration tables from the spectral windows with CALIBRATE_ATMOSPHERE intents in listobs (i.e. the TDM spectral windows with 128 channels), these are spectral windows 5 and 7.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#Removing existing Tsys information<br />
os.system('rm -rf *tdm.tsys')<br />
for asdm in basename_all:<br />
print ("Creating TDM Tsys Table for "+asdm)<br />
gencal(vis=asdm+'.ms',caltable=asdm+'.tdm.tsys',spw='5,7',caltype='tsys')<br />
</source><br />
<br />
Later in the applycal stage this TDM Tsys table will be interpolated to the FDM (3840 channels per spw) science spectral windows 1 and 3.<br />
<br />
Next we inspect the Tsys tables for the spectral window '''spw''' = 5 with the task {{plotms}}. In previous CASA versions, we used {{plotcal}} for this task, but most of '''plotcal''''s functionality is now included in {{plotms}}, and '''plotcal''' will be deprecated in a future CASA release. We want to check that Tsys data have reasonable values and identify any unexpected features as a function of either time or frequency. To get an idea of sensible Tsys under average atmospheric observations consult the ALMA sensitivity calculator, accessible from http://www.almascience.org (via the "Documents & Tools" link).<br />
<br />
We start by plotting the Tsys for all the antennas and polarizations (XX and YY) as a function of time for each. <!--Here and throughout we focus on spw 1, which contains CO(3-2): --><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Note that right now, plotms can't select individual channels when plotting caltables (as was possible with plotcal). In addition, when iteraxis is set, plotms appends the axes being iterated over to the output filename specified in plotfile; this can make for rather unwieldy filenames (particularly when iteraxis='antenna'!) but is useful for the ALMA pipeline. <br />
</pre><br />
<br />
<figure id="Xb.Tsys_vs_time.page1.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page1.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 8 antennas. Note the high y-axis values for DV04. The two different colors indicate the two polarizations (XX and YY).</caption>]]<br />
</figure><br />
<figure id="Xb.Tsys_vs_time.page2.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page2.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting Tsys vs. time for "+asdm)<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='0~7',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page1.png',overwrite=True)<br />
#dummy_string = input("First eight antennas for "+asdm+" . Hit <Enter> to continue.")<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='8~15',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page2.png',overwrite=True)<br />
#dummy_string = input("Remaining antennas for "+asdm+" . Hit <Enter> to continue.")<br />
</source><br />
<br />
This sequence loops over all of our files and plots Tsys as a function of time for channel 50 in spectral window 5. In the call to {{plotms}}:<br />
<br />
* '''gridrows'''=4 and '''gridcols'''=2 sets up a 4 x 2 panel grid. <br />
* '''iteraxis'''='antenna' tells {{plotms}} to make a separate plot for each antenna.<br />
* '''spw'''='5:50~50' selects spw '5' channel 50-50. This allows us to cleanly separate time variations from frequency variations. '''Note that this is a functionality in plotcal but not yet in {{plotms}}, and plotms is actually showing all channels from spw 5 at this time.'''<br />
<br />
Because 8 panels (2 panels for each antenna - LSB and USB) is not enough to show all antennas on one page, there are two {{plotms}} calls: one for the first 8 antennas ('''antenna'''='0~7'), and then for the remaining antennas ('''antenna'''='8~15').<br />
<br />
The 'input' commands will wait for you to hit Enter before issuing the next plot command. In the example above these are commented out (the leading "#" means that CASA will ignore them). If you would like to interactively cycle through the plots, uncomment them by removing the "#". Otherwise, the '''plotfile''' parameter directs the output to .png files for later inspection. The easiest way to look at the 20 plots produced here is to simply inspect the .png files using your favorite viewer. As noted above, here plotms is adding the antenna information to the filenames because we set '''iteraxis''' = 'antenna', so check your directory for the impressively long filenames to view them. <br />
<br />
The Tsys values in <xr id="Xb.Tsys_vs_time.page1.6.1.png"/> and <xr id="Xb.Tsys_vs_time.page2.6.1.png"/> look reliable, with typical values ~150 K except for some large values of Tsys at ~400 and 500 K for DV04. We will flag the data for that antenna later. <br />
<br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV02.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 4 antennas. Note the high y-axis values for DV04 and the mesospheric line near 343.2 GHz.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV08.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Next 4 antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"><br />
[[File:uid___A002_X215db8_X392.tdm.tsys.3c279.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid___A002_X215db8_X392. Note the pathological behavior for DV12.</caption>]]<br />
</figure><br />
<br />
We will also want to look at Tsys as a function of frequency. <br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
os.system('rm -rf cal_plots/Tsys_plots/'+asdm+'.tdm.tsys*')<br />
tsysfields=['3c279','Titan','*Antennae*']<br />
caltable=asdm+'.tdm.tsys'<br />
for field in tsysfields:<br />
plotbandpass(caltable=caltable,yaxis='amp',field=field,xaxis='freq',<br />
showatm=True,overlay='time',<br />
figfile='cal_plots/Tsys_plots/'+caltable+'.'+field,<br />
buildpdf=False,interactive=False,chanrange='8~120',subplot=42)<br />
</source><br />
<br />
You will see the following statement in the logger, but this is fine: <br />
<br />
<pre style="background-color: #fffacd;"><br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
</pre><br />
<br />
Now have a look at the Tsys vs. frequency plots or see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/>, <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"/>, and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/> for examples on the first data set. You can see the effect of a close pair of atmospheric ozone absorption lines at about 343.2 GHz that makes Tsys larger near that frequency in all antennas. Applying the Tsys calibration tables will minimize the contribution of these atmospheric lines. Again DV04 stands out with its very high Tsys. Although not present in the first data sets, Antenna DV12 exhibits periodic spikes in Tsys vs. frequency for one polarization (see <xr id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"/> for an example from a later data set). It may or may not be possible to calibrate that behavior out. We will make a note to look carefully at DV12 further on in the calibration process.<br />
<br />
===WVR===<br />
The WVR calibration uses observations of the wings of the 183 GHz atmospheric water line to correct for phase variations as a function of time. As noted in the tsys section, this run of gencal will append to existing WVR produced tables. To avoid this, preexisting wvrgcal data is removed. <br />
<source lang="python"><br />
#In CASA<br />
#Removing existing WVR information<br />
os.system('rm -rf *.wvrgcal')<br />
for asdm in basename_all:<br />
wvrgcal(vis=asdm+'.ms',caltable=asdm+'.wvrgcal',toffset=-1)<br />
</source><br />
<br />
===Antenna Positions===<br />
<br />
In general, the most appropriate antenna positions for the dataset will be determined and updated if needed during QA2. If the antenna positions need to be updated after QA2, we inform the PIs of the affected datasets and provide instructions on how to update the antenna positions. For the data in this guide, we do need to update the antenna positions. <br />
<br />
The antenna position table reflects refinements in the measured positions of the antennas from those stored in the data. {{gencal}} will now be used put antenna position data into each observation. Again, {{gencal}} will merely append to existing antenna position data, ruining any subsequent results. We start by removing any existing antenna position refinements, followed by defining the antenna names, then their refinements (both as arrays), finally running {{gencal}} to create the information CASA can refer to for antenna positions.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_Xb.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:21]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3a.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3b9.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X2181fb_X49.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV01,DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
-0.00004, 0.00026, 0.00019, #DV01-A137<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_X1c8.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X1f7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X4d7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X18.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X1d5.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X392.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
</source><br />
<br />
===Applycal===<br />
<br />
We are now ready to apply the Tsys and the WVR calibration tables to the data with {{applycal}}, which reads the specified gain calibration tables, applies them to the (raw) data column, and writes the calibrated results into the corrected column. Again, we loop through all the datasets. It is important to only apply Tsys and WVR corrections obtained close in time to the data being corrected, so in addition to looping over data sets we define the list of unique source names and loop over these. Then by setting '''gainfield''' and '''field''' to the same value we ensure that Tsys and WVR calibrations are only applied to the source for which they are measured. Because the source has a different name in the Northern Mosaic and the Southern Mosaic, we will carry out two loops. We will only correct '''spw''' 1 and 3, our science windows, because we will drop the other data in a moment.<br />
<br />
The applycal task now has much more flexibility for interpolating and applying calibrations derived in one spectral window to another, even if they do not share the same spectral shape (number of channels and channel width). This new functionality is used below to interpolate the TDM (128 channel) Tsys measurements to the FDM (3840 channel) spectral windows. This is controlled through the spectral window mapping parameter *spwmap*. Because this can be a bit confusing, we've written a "helper" function that will tell you what you should put for the Tsys calibration table part of spwmap. We only need to run it on one of the datasets because they are all the same in this regard<br />
<br />
<source lang="python"><br />
# In CASA<br />
from casarecipes.almahelpers import tsysspwmap<br />
tsysspwmap(vis='uid___A002_X207fe4_X3a.ms',tsystable='uid___A002_X207fe4_X3a.tdm.tsys')<br />
</source><br />
<br />
This will print to your screen: [0, 5, 5, 7, 5, 5, 5, 7]. Recall that the TDM spectral windows are spw=5 and 7 and the FDM spectral windows are 1 and 3. This spwmap tells applycal to use the Tsys information in spectral window 5 for spectral window 1; and to use the information in spectral window 7 for spectral window 3. Beyond that, it is only important that there are placeholders for the other spectral windows, its also useful to note that you need not give placeholders for spectral window ids larger than the largest spectral window you need to use, in this case 7.<br />
<br />
You will also need to put in placeholders for other tables that you give the gaintables. So if the Tsys table is 2nd in the list, spwmap=[[],[0,5,5,7,5,5,5,7],[]]<br />
<br />
Now run the applycal commands.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# A new list of file names that contain only data from the Northern Mosaic<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names_north = ['Titan','3c279','NGC*']<br />
<br />
for asdm in basename_north:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_north:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=['',field,field],<br />
interp=['','linear,spline','nearest'], <br />
gaintable=[asdm+'.antpos',asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]],<br />
flagbackup=False, calwt=True)<br />
<br />
# A new list of file names that contain only data from the Southern Mosaic<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names_south = ['Titan','3c279','Ant*']<br />
<br />
for asdm in basename_south:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_south:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=["",field,field],<br />
interp=['','linear,spline','nearest'],<br />
gaintable=[asdm+".antpos",asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]], <br />
flagbackup=False, calwt=True)<br />
</source><br />
<br />
where:<br />
<br />
*'''field''': the field ''to'' which we will apply the calibration, <br />
*'''gainfield''': the field ''from'' which we wish to take the calibration table<br />
*'''interp''' = 'nearest' : apply the nearest solution from the calibration table rather than interpolating.<br />
<br />
As you browse through the whole data set, you will probably note some problems along the same lines as the DV04 issue we saw above. We'll apply these as additional data flagging in just a moment.<br />
<br />
==Inspect Data==<br />
We are not quite done with the original ".ms" data sets yet. Before going further it will be useful to use {{plotms}} to show the effects of applying the calibration. In the process we'll take a quick look at each antenna and search for pathologies in the data.<br />
<br />
For this basic inspection, we want to compare the phase and amplitude as a function of frequency and time in the DATA and CORRECTED columns of each measurement set. The CORRECTED column has had the Tsys and WVR calibrations applied and so we expect lower phase scatter and flatter amplitude response as a function of time and frequency. We are looking for antenna-based issues, so cycling through a set of baselines that includes each antenna once will be a good start. We'll focus these plots on the phase+bandpass calibrator, 3c279, and on baselines that include antenna DV11, which we will make our reference antenna in just a bit.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
Each CASA Measurement Set has up to three "columns" of data: DATA, CORRECTED, and MODEL (though it is possible<br />
for a MS to hold only a DATA column if it has not been processed at all). <br />
<br />
A column entry exists for each data point (baseline, frequency, time). <br />
<br />
The DATA column holds the current raw data, though using split as we just did we can change the definition of<br />
"raw" data. <br />
<br />
The CORRECTED column holds the result of applying one or more calibration tables (e.g., via applycal) to the<br />
DATA column and so represents a corrected version of the DATA column. <br />
<br />
The MODEL column is now deprecated (though it is still possible to use it by explicitly setting usescratch=True).<br />
Instead, the model is stored in the header of the ms. This is a great step forward in terms of saving space and time <br />
to create scratch columns <br />
<br />
To get an intuitive feel for the columns you may wish to explore using plotms (which can plot different data <br />
columns, as seen below) or the browsetable task.<br />
<br />
</pre><br />
<br />
<figure id="plotms_amp_vs_freq_example-data.png"><br />
[[File:plotms_amp_vs_freq_example-data_6.1.png|200px|thumb|right|<caption> Example of Amplitude vs. Frequency before correction for the 3c 279.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_example-corr.png"><br />
[[File:plotms_amp_vs_freq_example-corr_6.1.png|200px|thumb|right|<caption> Same baseline as Figure 8 but now after correction using WVR and Tsys calibrations.</caption>]]<br />
</figure><br />
<br />
First, we plot amplitude as a function of frequency for 3c279. We start by plotting the DATA column, set color to indicate the two correlations (i.e., the XX and YY polarizations), and ask plotms to iterate over baseline. By setting '''antenna''' to 'DV11&*' we select only baselines that include DV11. We ask plotms to average all data over a very long timescale, '''avgtime''' = 1e8 seconds ~ 3 years or much longer than the time spanned by the whole data set. By setting '''avgscan''' = True we allow {{plotms}} to average across scan boundaries. The result is a plot of average amplitude per channel vs. frequency.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
asdm=basename_all[0]<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='amp',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Notice the green arrows along the bottom of the {{plotms}} window. We asked {{plotms}} to iterate over baseline. As you click the arrows, the plot will rotate from baseline to baseline, always with DV11 so that each antenna shows up once. To see the effect of the calibration, go to the "Axes" tab along the left of the {{plotms}} window and pull down the Data Column menu under the Y Axis. Set this from DATA to CORRECTED and you should see the effects of the calibration. You may need to ensure that the "Force Reload" box is checked before clicking "Plot" (both buttons lie at the bottom of the panel). For the most part things get better (flatter), but as we noted before DV04 is problematic.<br />
<br />
<figure id="plotms_amp_vs_time_north.png"><br />
[[File:plotms_amp_vs_time_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_time_south.png"><br />
[[File:plotms_amp_vs_time_south_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a southern mosaic data set.</caption>]]<br />
</figure><br />
<br />
You can now make analogous calls to examine the phase vs. frequency, amplitude vs. time, and phase vs. time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='phase',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='amp',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='phase',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Where:<br />
<br />
* '''spw''' is set to cover only channels 1200~1300 for the time plots in order to isolate time dependent variations from frequency-dependent behavior. Those 101 channels represent only a small part of the total spw 1 bandpass.<br />
* '''avgchannel''' set to a large number causes the plots of phase and amplitude vs. time to average data at all frequencies into a single point for each measurement.<br />
* '''coloraxis''' corr sets the colors to correspond to the two polarizations of the data.<br />
<br />
In each case, you will want to examine each baseline, alternating between the DATA and CORRECTED columns.<br />
<br />
This is a lot of data inspection and that's only for one of 10 data sets! You can iterate across the data by hand, updating "asdm" to refer to each data set in order and cycling between baselines and DATA/CORRECTED. It is also possible to script CASA to show you the key plots in succession (see the next block down). However you approach the infrastructure, you are looking for:<br />
<br />
* Improved scatter and lower variability in phase and amplitude vs. frequency and time. This indicates that the WVR and Tsys calibrations helped. <br />
* Sudden jumps in phase or amplitude as a function of either time or frequency. These may indicate problems with the antenna during that observation.<br />
* Large gradients, especially full wraps, in phase as a function of frequency. This may indicate a problem in the delays, the signal path length to the telescopes.<br />
* Unusual magnitude, scatter, or patterns in any plot - though this may be better explored using plots that show all data together, which we'll make in a moment.<br />
* Missing data. For example, if the phase calibrator drops out for a period of time we will not be able to calibrate and will need to flag the data.<br />
<br />
As you look through, note individual potentially problematic antennas. If ''all'' antennas in a data set appear problematic it may be that your "reference" antenna, DV11 in the example above, is the source of the problem. In this case swap this reference antenna for another and see whether the problem is isolated to your original reference antenna.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
A brief aside on structure:<br />
<br />
This section (Data Inspection) and the next (Apply Flags) are closely linked. We will present them as two<br />
separate steps. The idea here is that you look through your data, note problems, and then write commands to<br />
flag problematic data. This mimics one approach to writing data reduction scripts for CASA, where you will<br />
group all flagging together into one convenient place. Other CASA guides take a different approach, interleaving <br />
flagging and plotting. There is no "right" answer here. Find an approach to data inspection that works for you.<br />
<br />
</pre><br />
<br />
If you do wish to semi-automate the plot generation, the following sequence will cycle between data and corrected plots for each data set in turn. Type "stop" at any input call to break out.<br />
<br />
<!--<br />
'''Note:''' In loops like this involving {{plotms}}, hitting enter before the last dataset completes loading may cause {{plotms}} to stop refreshing the plot window at each step, or cause the window to disappear altogether. This will be fixed in an upcoming CASA release. Right now, you may need to exit CASA and restart to bring up the {{plotms}} window again, but you should be able to continue in the script where you left off.<br />
--><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
user_input = ""<br />
for asdm in basename_all:<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
# Extract antenna list for this data set.<br />
tb.open(asdm+'.ms/ANTENNA', nomodify=True)<br />
ants = tb.getcol('NAME')<br />
tb.close<br />
# Define the reference antenna to make baselines with<br />
ref_ant = 'DV11'<br />
# Loop over antennas<br />
for ant in ants:<br />
# Check if the user wants to stop<br />
if user_input == "stop":<br />
break<br />
# Skip correlation of reference antenna with itself (autocorrelations are flagged anyhow) <br />
if ant == ref_ant:<br />
continue<br />
# Define the baseline with the reference antenna for current antenna<br />
ant_str = ref_ant+'&'+ant<br />
print ("Showing baseline "+ant_str+" for data set "+asdm)<br />
print ("Use this to inspect effect of applying wvrcal and Tsys calibrations.")<br />
# Loop over phase and amplitude as axes<br />
for y_axis in ["amp", "phase"]:<br />
# Make 'before' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'before' plot for time x-axis<br />
print ("... "+y_axis+" vs. time for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for time y-axis<br />
print ("... "+y_axis+" vs. time for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<figure id="plotms_amp_vs_uvdist_north.png"><br />
[[File:plotms_amp_vs_uvdist_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. uv-distance for 3c279 in the first northern mosaic data set.</caption>]]<br />
</figure><br />
<br />
<figure id="plotms_amp_vs_freq_3c279.png"><br />
[[File:plotms_amp_vs_freq_3c279_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for 3c279 in the second northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Titan.png"><br />
[[File:plotms_amp_vs_freq_Titan_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for Titan in the second northern mosaic data set. Note the strong line (this is CO 3-2)!</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Antennae.png"><br />
[[File:plotms_amp_vs_freq_Antennae_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for the Antennae in the second northern mosaic data set. The CO(3-2) line is visible.</caption>]]<br />
</figure><br />
<br />
A detailed explanation of the procedure is a bit outside the scope of this guide (for more on python see http://www.python.org/ and for more on the CASA toolkit see http://casa.nrao.edu/), but the basic process is to loop over each data set, baseline with the reference antenna (here DV11), and y-axis of interest (phase or amplitude) then plot the effect of the calibration vs. frequency and time for each combination. Running this to step through the data will give you about 200 "before and after" plots from which you could note a subset of problematic cases to be followed up by hand. Many other strategies to inspect the data are also viable.<br />
<br />
With the Tsys and WVR calibrations applied successfully and the ''a priori'' flagging taken care of we will now {{split}} out the corrected data. We will keep only the corrected data, specified via '''datacolumn''', and only spectral window 1, which contains the FDM (high spectral resolution) observations of the CO(3-2) line. Setting '''keepflags'''=False tells {{split}} not to carry over any fully flagged rows from the original data set to the new MS. We give the new MS files the extension ".wvrtsys.ms" to indicate that they have been corrected for WVR and Tsys effects. Because split will not overwrite existing files, we remove any previous versions of the new MS before beginning.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm -rf '+asdm+'.wvrtsys.ms')<br />
print ("Splitting out corrected data for "+asdm)<br />
split(vis=asdm+'.ms', outputvis=asdm+'.wvrtsys.ms', <br />
datacolumn='corrected', spw='1', keepflags=False)<br />
</source><br />
<br />
Be patient, {{split}} may take awhile. The WVR and Tsys-corrected data now sit in the DATA column of the new measurement sets, which have only one spectral window (now labeled spectral window 0 though it was spectral window 1 in the original data). You may wish to run {{listobs}} to illustrate the changes:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.wvrtsys.listobs.txt')<br />
listobs(vis=asdm+'.wvrtsys.ms', listfile=asdm+'.wvrtsys.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note the new spectral window information:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
2011-08-05 01:07:08 INFO listobs Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
2011-08-05 01:07:08 INFO listobs SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
2011-08-05 01:07:08 INFO listobs 0 3840 TOPO 344845.586 488.28125 1875000 344908.33 XX YY <br />
<br />
</pre><br />
<br />
<br />
Next we will do a bit more inspection using {{plotms}} to look at whole data sets. This will help us identify missing data or look for egregious outliers.<br />
<br />
First we plot amplitude versus time (see <xr id="plotms_amp_vs_time_north.png"/> and <xr id="plotms_amp_vs_time_south.png"/>), averaging over all channels (by setting '''avgchannel''' to the very large value 10,000). We colorize by field so that scans on Titan are red, the bandpass and phase calibrator 3c279 is black (and orange in the Southern Mosaic where it has two field IDs), and the Antennae mosaic appears as a range of colors (one per pointing).<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='amp', <br />
avgchannel='3840',coloraxis='field', showgui = True)<br />
user_input = input("Examining amplitude vs. time for "+asdm+" . Hit <Enter> to proceed.[type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
Here look for:<br />
<br />
* Missing data. The source needs to be flanked by phase calibrator scans, if those are missing for any reason we need to flag the appropriate time range.<br />
* Dramatic outliers. Does the source suddenly get very bright or the otherwise bright calibrator appear anomalously faint for a brief time? This likely indicates problematic data that should be identified and flagged. You can use the "select" (box with green plus along the bottom row in plotms) and "locate" (magnifying glass) buttons in {{plotms}} to isolate and identify problem data (it will print to the log).<br />
* Smooth variation with time. A sudden jump may indicate a problem and often the safest approach is to flag data near a discontinuity.<br />
<br />
Look through the amplitudes vs. time for each data set (remember that we've already examined the phases vs. time and amplitude vs. time for individual baselines above).<br />
<br />
There are two other very useful "averaging" plots worth making. First, we plot amplitude as a function of u-v distance (projected antenna separation). Discontinuities and spikes in this plot are often from non-astrophysical sources. In the phase analog to the plot, the effects of atmospheric decorrelation can be assessed from increased scatter at longer u-v distances. While using the moon Titan as our flux calibrator, we may want to watch for flaring amplitudes at short u-v distances. These may indicate that Saturn is contaminating our beam. For a perfect, bright point source, we expect flat amplitudes as a function of u-v distance at the source amplitudes. <xr id="plotms_amp_vs_uvdist_north.png"/> shows an example of this plot, generated via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='3c279',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. UV Distance for 3c279 for "+asdm+" . Hit <Enter> to proceed.")<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='Titan',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
user_input = input("Examining amplitude vs. UV Distance for Titan for "+asdm+" . Hit <Enter> to proceed [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
<br />
<br />
It can also be useful to examine the average amplitude as a function of frequency for each target. This allows one to check for lingering atmospheric effects, unexpected line emission or absorption in the calibrators, or decreased sensitivity due to "roll-off" of the telescope sensitivity at the band edges. These plots are created by the sequence of commands below, where we have broken up the script to loop separately over the Northern and Southern Mosaics to reflect the different source names.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names = ["3c279","Titan","NGC*"]<br />
<br />
for asdm in basename_north:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+". Hit <Enter> to proceed.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names = ["3c279","Titan","Ant*"]<br />
<br />
for asdm in basename_south:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+" . Hit <Enter> to proceed.")<br />
<br />
</source><br />
<br />
<br />
For this command notice that we can see the CO(3-2) line in the Antennae even before calibration (see <xr id="plotms_amp_vs_freq_Antennae.png"/>) and that Titan also shows evidence of a strong line (also <xr id="plotms_amp_vs_freq_Titan.png"/>)! This will need to be flagged before we can use Titan to calibrate the flux scale of our data.<br />
<br />
This suite of plots (along with the earlier inspection of the Tsys tables) gives us the tools we need to identify problematic data through the data sets. We use this to generate a set of inspection-driven {{flagdata}} commands for each data set. We apply these before the bandpass and gain calibration.<br />
<br />
==Apply Flagging==<br />
Based on this inspection and the other plots we have made, we now flag problematic portions of the data. We break up the flags by reason for flagging in order to illustrate the process. As you reduce your own data it may be more efficient to group flags by data set and make use of the flagcmd command. Except for the "post-calibration" flagging, the inspection plots that we just looked through have already revealed all of the problems that we flag. We structure the guide so that the flagging is grouped in one place.<br />
<br />
As before, we may wish to reset our flags before beginning (particularly if one iterates this process) via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms',mode='unflag', flagbackup = False)<br />
</source><br />
<br />
Remember that we dropped the flagged data when splitting out after the WVR and Tsys calibration, so this should not undo your "A Priori" flagging of shadowed data, autocorrelations, etc.. In any case this unflagging step is not necessary during the first iteration.<br />
<br />
* '''Edge Channels'''<br />
<br />
ALMA's sensitivity decreases near the edge of the baseband and it is often useful to check for a 'roll-off' in sensitivity near the edge of the band. This will appear as a downturn in amplitude as a function of channel near the edge of the window in the uncalibrated data, as a flaring due to increased noise at the spw edges in the calibrated data. It will also be visible in the amplitude part of the bandpass calibration table. Because our FDM spw does not cover the full baseband, we do not see a strong roll off in our data (see <xr id="amp_vs_channel_example.png"/>), where there is only a mild hint of a roll-off at the high end) but we do flag a (very) few channels at the high and low-frequency edge of the data set to be safe.<br />
<br />
<figure id="amp_vs_channel_example.png"><br />
[[File:amp_vs_channel_example.png|200px|thumb|right|<caption> Amplitude vs. channel for one uncalibrated antenna pair. This kind of plot can be inspected to get an idea of the presence or magnitude of any roll-off in sensitivity near the edges of the spectral window.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:0~7,0:3831~3839', flagbackup = False)<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:3260~3320', flagbackup = False)<br />
</source><br />
<br />
* '''Problematic Tsys measurements'''<br />
<br />
Above we noted issues with the Tsys measurements for both DV04 and DV12. We flag the affected data. Each of these issues should be visible in the Tsys plots you made above (e.g., see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/> and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/>).<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04',flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X1d5"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X392"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
</source><br />
<br />
* '''Unreliable Short-Spacing Measurements on Titan'''<br />
<br />
<figure id="amp_vs_uv_titan_obs.png"><br />
[[File:amp_vs_uv_titan_obs.png|200px|thumb|right|<caption> Observed amplitude vs. uv-distance for observations of Titan in the first data set. Note the scatter for low projected antenna separations. We will flag these short-spacing data, which may reflect contamination by Saturn, and use only the more extended baselines for flux calibration.</caption>]]<br />
</figure><br />
<br />
Saturn may contaminate the short u-v spacings from Titan. In any case these often show significant scatter (<xr id="amp_vs_uv_titan_obs.png"/>), so we flag them. There are still enough baselines to determine a good amplitude calibration for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~40', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
</source><br />
<br />
* '''Delay Issues''' <br />
<br />
<figure id="phase_vs_freq_DV13.png"><br />
[[File:phase_vs_freq_DV13.png|200px|thumb|right|<caption> Phase vs. frequency for DV13 in a data set where this antenna shows evidence of imperfect delay calibration.</caption>]]<br />
</figure><br />
<br />
DV13 and a few other antennas show signatures of an imperfect delay calibration. This is most easily identified via strong "wrapping" of phase as a function of frequency (see <xr id="phase_vs_freq_DV13.png"/>). Such effects can be calibrated out with mild delay issues largely accounted for by the bandpass solution. The phase wrapping in DV13 seems weak enough that we will trust the calibrations to remove it. For a more extreme example see the CASA guide describing the calibration of [[NGC3256Band3]].<br />
<br />
* '''Missing Phase Calibrator Observations'''<br />
<br />
<figure id="amp_vs_time_missing_scans.png"><br />
[[File:amp_vs_time_missing_scans.png|200px|thumb|right|<caption> Amplitude vs. time colored by field for a data set where the final visit to the phase calibrator is missing. We will flag the last set of source data to ensure that each visit to the source is flanked in time by visits to the phase calibrator.</caption>]]<br />
</figure><br />
<br />
As a general rule, we want to be sure that observations of the phase calibrator (3c279) bracket each source observation. Two of the data sets do not include a final phase calibrator observation (see <xr id="amp_vs_time_missing_scans.png"/>) and for those two cases we flag the affected source observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='00:53:47~01:08:00',flagbackup = False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV10',timerange='19:46:20~20:34:40',flagbackup=False)<br />
</source><br />
<br />
* '''Unexpected Scatter or Discontinuity in the Data'''<br />
<br />
For several antennas we find sudden jumps in the phase of the phase calibrator as a function of time. These are visible in the plots of uncalibrated phase vs. time for single baselines above, and we show an example in <xr id="phase_vs_time_DV09.png"/>. It will not be possible to effectively interpolate the phase between measurements when we see these discontinuities. The safest approach is to flag the source data across these jumps. We do so here (though note that the last two flaggings are borderline cases).<br />
<br />
<figure id="phase_vs_time_DV09.png"><br />
[[File:phase_vs_time_DV09.png|200px|thumb|right|<caption> Phase vs. time for DV09 on a problematic day. It may prove problematic to calibrate the data near this discontinuity so we flag data near this time.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09', timerange='21:24:09~21:35:35', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09',timerange='23:30:52~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM01',timerange='23:16:50~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM03',timerange='23:16:50~24:10:00',flagbackup=False)<br />
</source><br />
<br />
* '''Outliers Visible After Calibration'''<br />
<br />
<figure id="amp_vs_uvdist_outliers.png"><br />
[[File:amp_vs_uvdist_outliers.png|200px|thumb|right|<caption> Amplitude vs. u-v distance ''after'' calibration. Note the outlying data. We track these down using the select (box with green "+") and locate (magnifying glass) features inside plotms and identify several problematic baselines across our data. ''Note that you cannot make this plot at this point in the guide, these pathologies become evident after calibration, requiring an iterative approach to reduction.''</caption>]]<br />
</figure><br />
<br />
Often issues with the data may become evident after calibration (i.e., after the next few steps that we apply). These data can appear as outliers in diagnostic plots for the calibrated data or even show up in the imaging stages. Once these are identified, best practice is to apply this new flagging then redo the calibration (if the issue is very minor, then re-calibrating may not be necessary).<br />
<br />
<source lang="python"><br />
# In CASA<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='21:18:00~21:22:15', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV01&DV04', flagbackup=False)<br />
</source><br />
<br />
Now that we've applied our flagging, back up the flags as version "User" using {{flagmanager}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis=asdm+'.wvrtsys.ms',mode='save',versionname ='User')<br />
</source><br />
<br />
Applying this flagging will remove the most egregious pathologies from the data. We are now ready to calibrate the data.<br />
<br />
==Bandpass Calibration==<br />
<br />
We begin by calibrating the phase and amplitude response of each antenna as a function of frequency, called "bandpass calibration." We have already seen that the data contain smooth but systematic variations in both phase and amplitude as a function of frequency. We can see this again in a more compact form by plotting phase as a function of frequency for all baselines associated with each antenna (<xr id="plotms_phase_vs_freq_example.png"/>).<br />
<br />
<figure id="plotms_phase_vs_freq_example.png"><br />
[[File:plotms_phase_vs_freq_example_6.1.png|200px|thumb|right|<caption> Phase vs. frequency for the bandpass calibrator, 3c279 in the first data set. We plot all baselines with DV02, averaged over time, and show only the 'XX' correlation.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='freq', yaxis='phase', <br />
selectdata=True, field='3c279', correlation='XX',<br />
avgtime='1e8', avgscan=True, antenna='*&*',<br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. frequency for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
Each plot shows phase as a function of frequency for all baselines with one antenna for 3c279. We plot only the 'XX' correlation, colorizing by baseline. With '''iteraxis''' set to antenna the green arrows at the bottom of {{plotms}} will cycle through antennas. By using '''avgscan''' and a large '''avgtime''' we average all scans and integrations. <br />
<br />
The phase (and amplitude) also varies as a function of time, as we saw before. Here are the similar plots for phase vs. time (see <xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb-phasecont.png"><br />
[[File:Uid_A002_X1ff7b0_Xb-phasecont_6.1.png|200px|thumb|right|<caption> Phase vs. time for the bandpass calibrator, 3c279. Averaged over channel. Only baselines with antenna DV02, and corr='XX'</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='phase', <br />
selectdata=True, field='3c279', <br />
spw='0:1200~1299', antenna='*&*',correlation='XX',<br />
avgchannel='100', avgscan=True, <br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. time for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
<xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/> shows that the phase varies with time. We need to take this temporal variation into account when we solve for the frequency variations. Therefore we carry out the bandpass calibration in two steps. First, we use {{gaincal}} to solve for the variation of phase as a function of time for 3c279 on very short timescales. We set {{gaincal}} to derive a separate phase solution for each antenna every integration by setting '''solint''' to 'int'. We solve, averaging together only a small fraction of the total bandpass (channels 1100-1300) to avoid the effects of the phase vs. frequency behavior. We will then apply this solution to remove time-dependent behavior when we solve for the frequency response of the antennas with {{bandpass}}.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
An integration is the smallest time quantum of observation in the data, usually a few seconds. <br />
You can check the integration length for each scan in listobs. <br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
for asdm in basename_all:<br />
print ("Running a short solution interval phase calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bpphase.gcal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
selectdata=True,field = '3c279',spw = '0:1100~1300',<br />
caltable = asdm+'.bpphase.gcal',<br />
solint = 'int',refant = 'DV11',calmode='p')<br />
</source><br />
<br />
Now we use {{bandpass}} to solve for the frequency response of each antenna. To do this, we average all data in time by setting '''solint''' to 'inf' (that is, 'infinite'). We allow combination across scans and the different field IDs found for 3c279 by setting '''combine''' to "scan,field". We apply the phase vs. time calibration that we just derived on-the-fly using the parameter "gaintable".<br />
<br />
<source lang="python"><br />
for asdm in basename_all:<br />
print ("Running a bandpass calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bandpass.bcal')<br />
bandpass(vis = asdm+'.wvrtsys.ms',<br />
field = '3c279',<br />
gaintable = asdm+'.bpphase.gcal',<br />
caltable = asdm+'.bandpass.bcal',<br />
bandtype='B',<br />
solint = 'inf',combine = 'scan,field', solnorm=True,refant = 'DV11',<br />
minblperant=3,minsnr=2,fillgaps=62)<br />
</source><br />
<br />
in these calls:<br />
<br />
*'''caltable''' specifies the output calibration table<br />
*'''gaintable''' specifies any calibration tables to be applied "on the fly" to the data before solving.<br />
*'''solint''' sets the time interval for which solutions are derived for each antenna.<br />
*'''refant''' set the reference antenna, here DV11, which is defined to have zero correction by construction.<br />
*'''calmode''' 'p' sets {{gaincal}} to calibrate the phase only, other options are 'a'mplitude or 'ap' - amplitude and phase.<br />
*'''minblperant''' sets the minimum baselines required per antenna for a successful solution.<br />
*'''minsnr''' sets the minimum signal-to-noise ratio required for a successful solution.<br />
*'''bandtype''' here 'B' tells {{bandpass}} to solve for the phase and frequency response of each antenna in each channel, averaging data in time across the solution interval.<br />
*'''fillgaps''' tells {{bandpass}} to interpolate across channel gaps 1 channel wide.<br />
*'''solnorm''' tells {{bandpass}} to normalize the bandpass amplitude and phase corrections to have magnitude unity. The absolute scale of the calibration will come from our later {{gaincal}} solutions.<br />
<br />
Do not worry about the message "Insufficient unflagged antennas" when running the {{bandpass}} task. This indicates that {{bandpass}} is failing on the flagged edge channels, which is expected.<br />
<br />
It is now a good idea to plot both sets of solutions to look for irregularities, especially:<br />
<br />
* discontinuities in the phase vs. time solution<br />
* rapid wrapping of phase in either phase vs. time or bandpass solution<br />
* large roll-off in the amplitude response near the band edge in the bandpass solution<br />
* large scatter in any solution.<br />
<br />
We loop through and using analysis utils, again generating .png files of each calibration. '''For what systems is this true?''' As the bandpass plots take a while you may want to go have a cup of coffee and inspect them using your favorite image viewer. Otherwise, switch the '''interactive''' parameter to True to see them in real time instead.<br />
<br />
<figure id="uid___A002_X1ff7b0_X1c8.bpphase.page1.png"><br />
[[File:uid___A002_X1ff7b0_X1c8.bpphase.page1_6.1.png|200px|thumb|right|<caption> Short interval phase vs. time solution carried out and applied during bandpass calibration, here for the first set of antennas for the first data set. This solution removes any systematic variations in phase vs. time.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1.CASA3.4.png"><br />
[[File:Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1_6.1.png|200px|thumb|right|<caption> Bandpass amplitude solution for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X1ff7b0_Xb.bcal_phase.page1.png"><br />
[[File:uid___A002_X1ff7b0_Xb.bcal_phase.page1.png|200px|thumb|right|<caption> Phase vs. frequency calibration from the bandpass calibration for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<br />
<!--<br />
Again this warning:<br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
--><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
os.system('rm -rf cal_plots/*bandpass*.png')<br />
for asdm in basename_all:<br />
plotbandpass(caltable=asdm+'.bandpass.bcal',<br />
field='',xaxis='freq',yaxis='both',<br />
figfile='cal_plots/'+asdm+'.bandpass.png',<br />
showatm=True,interactive=False,subplot=42)<br />
</source><br />
<br />
==Absolute Flux Calibration==<br />
<br />
The bandpass calibration will account for the phase and amplitude response of our antennas as a function of frequency. We now solve for the absolute flux scale of the data by referencing to Titan and in the next section we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
Before using Titan to set the flux, there is an important systematic to account for. When we looked at the integrated spectra of our targets above, remember that Titan showed a whopping spectral line, in fact the same CO(3-2) line that we wish to observe in the Antennae. We will set the flux of Titan (and thus all of our data) by referencing to a model in casa that does not account for this line. Therefore we need to flag the part of the Titan observations contaminated by the line before we calibrate (you can see the affected channel range in <xr id="Antennae-TitanLine.png"/>). We run the following additional flagging step:<br />
<br />
<figure id="Antennae-TitanLine.png"><br />
[[File:Antennae-TitanLine_6.1.png|200px|thumb|right|<caption> Uncalibrated amplitude vs. channel plot for the flux calibrator, Titan (uid___A002_X1ff7b0_Xb dataset). Averaged over time, corr='XX', and colorized by baseline.</caption>]]<br />
</figure><br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Flagging CO(3-2) in Titan for "+asdm)<br />
flagdata(vis=asdm+'.wvrtsys.ms',flagbackup=False, <br />
field='Titan', spw='0:1100~1700')<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis =asdm+'.wvrtsys.ms',mode = 'save',versionname = 'Calibration')<br />
</source><br />
<br />
Next, we will use the {{setjy}} task to read the predicted complex visibilities for Titan into the MODEL column of each data set.<br />
<br />
<source lang="python"><br />
# in CASA<br />
for asdm in basename_all:<br />
print ("Reading model for Titan into "+asdm)<br />
setjy(vis = asdm+'.wvrtsys.ms',field = 'Titan',<br />
usescratch=True,scalebychan=True,<br />
standard = 'Butler-JPL-Horizons 2012')<br />
</source><br />
<br />
{{setjy}} will output the flux of Titan to the CASA logger and it is worth recording this information. The flux of Titan at these frequencies is about 3.3 Jy. For example, for dataset uid___A002_X1ff7b0_Xb.wvrtsys.ms:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Titan: spw0 Flux:[I=3.2637,Q=0.0,U=0.0,V=0.0] +/- [I=0.0,Q=0.0,U=0.0,V=0.0] Jy @ 344.85GHz<br />
</pre><br />
<br />
Now we are going to take a look at the Titan model for one dataset:<br />
<br />
<source lang="python"><br />
# in CASA<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
</source><br />
<br />
<figure id="2012_titan_model_5.1.png">[[File:2012_titan_model_6.1.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2012'.</caption>]]</figure><br />
<figure id="2010_titan_model.png">[[File:2010_titan_model.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2010'.</caption>]]</figure><br />
<br />
<br/><br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
The setjy invocation made in this section uses the flux density standard '''standard='Butler-JPL-Horizons 2012' '''. Previous versions of this guide used an older flux density standard '''standard='Butler-JPL-Horizons 2010' '''. <xr id="2012_titan_model_5.1.png"/> and <xr id="2010_titan_model.png"/> show the differences in the Titan models produced using these two standards. <br />
</div><br />
<br />
==Gain (Phase and Amplitude) Calibration==<br />
<br />
With the flux now properly scaled, we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
We begin by running a short-solution interval {{gaincal}} to solve for phase variation on short timescales during observations of our two calibrators, with '''solint''' set to "int". By applying this on-the-fly, we can remove any decorrelation in the data due to phase scatter when we solve for the amplitude calibration. However, there is no benefit to using this short-timescale solution to calibrate the source because we only have information on the gain during calibrator visits (though see the Imaging portion of this guide). Instead we will solve for the gains to apply to the source using a longer '''solint''' in just a moment.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out short timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.intphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.intphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='int',minsnr=2.0, minblperant=4)<br />
</source><br />
<br />
Now we derive the longer timescale phase calibration table using '''solint''' set to "inf", but not allowing scan combination. This calibration has higher signal to noise due to combining more data, and for the purposes of correcting the source, it is just as precise as the short timescale solution.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out longer timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.scanphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.scanphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='inf',minsnr=2.0,minblperant=4)<br />
</source><br />
<br />
Now we apply the short-timescale phase solution and carry out a scan length ('''solint''' set to "inf") calibration of the data using '''calmode''' of 'ap'.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Solving for longer (scan) interval amplitude solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.amp.cal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
gaintable =[asdm+'.bandpass.bcal',asdm+'.intphase.gcal'],<br />
caltable = asdm+'.amp.cal',<br />
calmode='ap',<br />
field = 'Titan,3c279',<br />
spw='0:40~3800',<br />
refant = 'DV11',solint = 'inf', minblperant=4)<br />
</source><br />
<br />
This "amp.cal" solution gives us the amplitude variations as a function of time, but they are not yet pinned to a realistic scale except in the case of Titan, where we have solved using the model input by {{setjy}}. We will set the flux of our secondary calibrator 3c279 with reference to Titan using {{fluxscale}}.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Scaling amplitude calibration to match Titan for "+asdm)<br />
os.system('rm -rf '+asdm+'.flux.cal')<br />
fluxscale(vis = asdm+'.wvrtsys.ms',<br />
caltable = asdm+'.amp.cal',<br />
fluxtable = asdm+'.flux.cal',<br />
reference = 'Titan',<br />
transfer = '3c279')<br />
</source><br />
<br />
This new correctly-scaled flux table ".flux.cal" replaces the previous ".amp.cal" table as the correct amplitude calibration table to apply to the data, i.e., the ".flux.cal" contains both the time variability of the amplitude solved for in ".amp.cal" and the correct flux scaling set with {{fluxscale}}.<br />
<br />
Fluxscale will output the derived flux for 3c279 to the CASA logger. This information is worth noting. We find that the flux of 3c279 is 10.79 Jy, by averaging the fluxes obtained from the ten available datasets. If we check this value against reported flux measurements in the SMA calibrator list [http://sma1.sma.hawaii.edu/callist/callist.html], we find that a flux of 10.79 Jy agrees within a few per cent of a linear interpolation between the two 0.85 mm measurements closest in time to the ALMA observations: (23 May 2011, SMA 11.644 ± 0.583; 01 July 2011, 9.748 ± 0.488).<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used the older, Butler-JPL-Horizons 2010, flux density standard when you ran {{setjy}} earlier in this tutorial, the derived flux values for 3c279 will be slightly lower. The flux of 3c279, when averaged over all 10 measurement sets, will be 10.41 Jy.<br />
</div><br />
<br />
Now we plot the final phase and amplitude calibration tables for each data set. A well-behaved calibration table will show smooth variations as a function of time. Sudden jumps or wild variations among the antenna amplitude gains should prompt further investigation and possibly additional flagging.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting solutions for "+asdm)<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis='antenna',antenna='0~7',plotrange=[0,0,-180,180],<br />
gridrows=4,gridcols=1,showgui=False,<br />
plotfile=asdm+'.scanphase.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis = 'antenna', antenna='8~15', plotrange=[0,0,-180,180],<br />
showgui=False, gridrows=4, gridcols=1, <br />
plotfile=asdm+'.scanphase.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='0~7', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='8~15', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
<br />
</source><br />
<br />
==Apply the Calibrations and Inspect ==<br />
Now we will use {{applycal}} to apply the bandpass, phase, and amplitude calibration tables that we generated in the previous sections to the data. We apply the solutions separately to the bandpass and secondary ("phase") calibrator 3c279, the flux calibrator Titan, and the target source. In most data sets, the bandpass and secondary calibrator will not be the same and this step would include one additional {{applycal}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
for asdm in basename_north: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='NGC*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_south: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Ant*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
</source><br />
<br />
Here:<br />
* '''vis''' and '''field''' specify the measurement set and field to calibrate.<br />
* '''gaintable''' specifies the tables to apply to the data. There may be several tables applied all at once, here we apply the bandpass, phase, and flux calibrations.<br />
* '''interp''' specifies the type of interpolation used to match calibration tables to the data. If there are several gaintables then interp may be either a single value (e.g., "linear" or "nearest") or a list of values with size equal to the list of gaintables. In the case where interp is a list, applycal will match each element to the corresponding gaintable (e.g., first gaintable with first interp parameter).<br />
* '''gainfield''' specifies field from which to draw the calibration. As with interp, this can be a list of size matched to gaintable, so that the first element of gainfield will be the field used for the first table. For example, in the above commands the bandpass calibration (the first table) will always be applied from '3c279' (the first gainfield).<br />
* '''calwt''' indicates that the weights, which were derived from the Tsys measurements, should also be calibrated. Note that '''calwt''' is True by default.<br />
<br />
Once calibrations are applied, it is important to go back and inspect the calibrated data. New problematic antennas or baselines may be visible after calibration. Repeat the steps above, focusing on the CORRECTED data column. Bear in mind that for any point source calibrators we now expect to find phase scattering around zero and to find flat amplitudes as a function of u-v distance. Look for outliers and other signatures of problematic data. As a general rule, you will want to incorporate these data into your overall flagging script then rerun the whole calibration process, so that reduction is iterative. If the data only represent a minor problem, however, it may not be terribly harmful to flag them after the fact so that they do not interfere with imaging but trust that the calibrations are mostly unaffected.<br />
<br />
As an example of this inspection, we cycle through the corrected amplitudes and phases of 3c279 and Titan as a function u-v distance, to check that the phases are close to zero and the amplitudes are constant. <br />
<br />
<figure id="xb-checkcal-pha-cha.png"><br />
[[File:xb-checkcal-pha-cha_6.1.png|200px|thumb|right|<caption> Calibrated phase vs. channel plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<figure id="xb-checkcal-amp-time.png"><br />
[[File:xb-checkcal-amp-time.png|200px|thumb|right|<caption> Calibrated amplitude vs. time plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='phase',<br />
ydatacolumn='corrected', field='3c279',<br />
avgchannel='3840', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
In <xr id="xb-checkcal-pha-cha.png"/> and <xr id="xb-checkcal-amp-time.png"/> we plot phase vs. channel and amp vs. time for 3c279 for the uid___A002_X1ff7b0_Xb dataset. <br />
<br />
Finally we can use {{plotms}} to examine the corrected amplitude and phase of Antennae galaxies as a function of time and uv-distance (plots not shown):<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
for asdm in basename_north:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
avgtime='1e8', avgscan=True, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
for asdm in basename_south:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
avgtime='1e8', avgscan=True,avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
</source><br />
<br />
==Split and Concatenate Data for Northern and Southern Mosaics==<br />
The individual data sets are now calibrated. We can safely split out the calibrated data for our science target and drop the calibrators. As we do so, we will smooth the data in frequency, averaging together groups of 23 channels by setting '''width=23''' in {{split}}. The new data will have a channel width corresponding to about ~10 km/s, very similar to the SMA data being verified. The factor of >20 drop in data volume will also make the imaging steps ''much'' more tractable.<br />
<br />
Note that you will see a warning that the last output channel in the new spw 0 will be dropped, as it has less than 23 channels over which to average:<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO MSTransformDataHandler The last output channel of spw 0 has only 22 input channels.<br />
WARN MSTransformManager Not enough input channels to populate output channel n# 166 from SPW 0.<br />
WARN MSTransformManager The channel will be dropped in order to have an uniform grid.<br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_north:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'NGC*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
<br />
for asdm in basename_south:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'Ant*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
</source><br />
<br />
For convenience we concatenate all data for the Northern Mosaic into a single big MS and place all data for the Southern Mosaic into another file. To do this, we construct a list that holds the names of all the Southern Mosaic MS files and another that holds the name of all the Northern Mosaic MS files then feed these into the {{concat}} task. <br />
<br />
Before we do this, we'll take a brief aside to remove Pointing information from the calibrated data. Normally, the pointing information would apply important corrections to be used while imaging the data. However, some aspects of this are still under development and the pointing information in these data interacts poorly with CASA. We will remove the pointing information using the CASA toolkit Table tool (tb). ''This kind of operation is dangerous and should not be a regular feature of your CASA reduction.''<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Manually removing pointing table from "+asdm+".cal.ms ... Please be careful!")<br />
tb.open(asdm+'.cal.ms/POINTING',nomodify=False)<br />
a = tb.rownumbers()<br />
tb.removerows(a)<br />
tb.close()<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
cal_south_vis = [vis+'.cal.ms' for vis in basename_south]<br />
cal_north_vis = [vis+'.cal.ms' for vis in basename_north]<br />
<br />
os.system('rm -rf Antennae_South.cal.ms')<br />
concat(vis=cal_south_vis, concatvis='Antennae_South.cal.ms', timesort=True)<br />
<br />
os.system('rm -rf Antennae_North.cal.ms')<br />
concat(vis=cal_north_vis, concatvis='Antennae_North.cal.ms', timesort=True)<br />
</source><br />
<br />
The syntax used to construct the 'cal_south_vis' variable loops over basename_south and makes a list after adding '.cal.ms' to each member. To see the list 'print (cal_south_vis)'.<br />
<br />
==Continue on to Imaging of the Science Target==<br />
Now you can continue on to the [http://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_6.1 imaging guide].<br />
{{Checked 6.1}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:2012_titan_model_6.1.png&diff=29407File:2012 titan model 6.1.png2020-10-01T18:59:24Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Calibration_6.1&diff=29406AntennaeBand7 Calibration 6.12020-10-01T18:40:28Z<p>Dkim: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide is written for CASA 6.1 and uses Python 3. The same functionality is implemented in Python 2 using CASA 5.7 at [[AntennaeBand7 Calibration 5.7]]'''<br />
<br />
*'''This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are provided at [[AntennaeBand7]]<br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see: [[AntennaeBand7_Imaging 6.1]]'''.<br />
<br />
==Overview==<br />
<br />
This part of the Antennae Band 7 CASA guide will step through the calibration of the visibility data. We will begin by flagging (marking as bad) data known to be useless before any inspection; for example, data where one telescope blocks the line of sight of another. We will then apply telescope-generated calibration tables to partially correct for atmospheric effects. After inspecting the data, we will flag some additional data that exhibit pathologies. Using observations of the calibrators Titan and 3c279, it will be shown how to derive the phase and amplitude response of individual antennas as a function of time and frequency ("phase", "amplitude", and "bandpass" calibrations). We will apply these solutions to the data and then extract the calibrated source data into a file appropriate for imaging in the [[AntennaeBand7_Imaging | Antennae Band 7 imaging guide]].<br />
<br />
The general procedure in this guide follows the other ALMA CASA guides: [[NGC3256Band3]] and [[TWHydraBand7]].<br />
<br />
==Unpack the Data==<br />
<br />
This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]. <br />
<br />
Once you have downloaded the data, unpack the file in a terminal outside CASA using<br />
<br />
<source lang="bash"><br />
<br />
tar -xvzf Antennae_Band7_UnCalibratedMSandTablesForReduction.tgz<br />
<br />
</source><br />
<br />
then change directory to the new directory <br />
<br />
<source lang="bash"><br />
<br />
cd Antennae_Band7_UnCalibratedMSandTablesForReduction<br />
<br />
</source><br />
<br />
You may wish to type<br />
<br />
<source lang="bash"><br />
<br />
ls<br />
<br />
</source><br />
<br />
to look at the files present. You should see a set of files with extension ".ms". These are CASA measurement set (MS) files. The data have already been converted to MS format from the native ALMA format using the CASA task {{importasdm}}. In addition to the data, we provide you with calibration tables containing system temperature (Tsys), water vapor radiometer (WVR), and antenna position information. For Early Science, these tables will either be pre-applied or supplied with the data.<br />
<br />
To begin, start CASA by typing<br />
<br />
<source lang="bash"><br />
<br />
casa<br />
<br />
</source><br />
<br />
Be sure that you are using the version indicated at the top of this page.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 6.1. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casalith<br />
version = casalith.version_string()<br />
print("You are using {}".format(version))<br />
if (version < '6.1'):<br />
print ("YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE.")<br />
print ("PLEASE UPDATE IT BEFORE PROCEEDING.")<br />
else:<br />
print ("Your version of CASA is appropriate for this guide.")<br />
</source><br />
<br />
==Initial Inspection==<br />
<br />
First we will take stock of what we have. If you have not already done so, begin by reviewing the description of the observations here: [[AntennaeBand7]]. The 10 data sets each target either the Northern or the Southern Mosaic, as follows:<br />
<br />
Northern Mosaic:<br />
*uid___A002_X1ff7b0_Xb.ms<br />
*uid___A002_X207fe4_X3a.ms<br />
*uid___A002_X207fe4_X3b9.ms<br />
*uid___A002_X2181fb_X49.ms<br />
<br />
Southern Mosaic:<br />
*uid___A002_X1ff7b0_X1c8.ms<br />
*uid___A002_X207fe4_X1f7.ms<br />
*uid___A002_X207fe4_X4d7.ms<br />
*uid___A002_X215db8_X18.ms<br />
*uid___A002_X215db8_X1d5.ms<br />
*uid___A002_X215db8_X392.ms<br />
<br />
The first step is to get basic information about the data: targets observed, time range, spectral setup, and so on. We do this using the task {{listobs}}, which will output a detailed summary of each dataset. Enter the following commands into CASA:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Define a python list holding the names of all of our data sets<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
# Initialize user-input string. (for Python testing)<br />
dummy_string = ''<br />
<br />
# Loop over each element in the list and create summary file using listobs<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.listobs.txt')<br />
listobs(vis=asdm+'.ms', listfile=asdm+'.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note that after cutting and pasting a 'for' loop like this you often have to press return twice to execute. You may also want to take care to paste a line at a time if you are having trouble copy and pasting. Even better, you can use "cpaste" to paste blocks of code. To do so type "cpaste" at the CASA prompt, paste your commands, and then type "--" and hit return on the final (otherwise empty) line. This should look something like this:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
CASA <8>: cpaste<br />
Pasting code; enter '--' alone on the line to stop.<br />
:basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
: "uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
: "uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
: "uid___A002_X215db8_X392"]<br />
:<br />
:for asdm in basename_all:<br />
: print (asdm)<br />
:--<br />
uid___A002_X1ff7b0_Xb<br />
uid___A002_X207fe4_X3a<br />
uid___A002_X207fe4_X3b9<br />
uid___A002_X2181fb_X49<br />
uid___A002_X1ff7b0_X1c8<br />
uid___A002_X207fe4_X1f7<br />
uid___A002_X207fe4_X4d7<br />
uid___A002_X215db8_X18<br />
uid___A002_X215db8_X1d5<br />
uid___A002_X215db8_X392<br />
<br />
CASA <9>: <br />
<br />
</pre><br />
<br />
cpaste should be ''much'' more robust than copying-and-pasting directly into the shell but if you have trouble, just carefully paste one line at a time directly into CASA and hit return until the desired command executes.<br />
<br />
These commands define a python list called "basename_all", which contains the name of all 10 MS files. The "for" loop executes for each element in basename_all, calling listobs and directing the output to a file called, e.g., "uid___A002_X1ff7b0_Xb.listobs.txt" for the first measurement set. You can browse through the listobs output as you would normally look at a text file (use emacs, vi, or another editor). You can also send the output to the terminal from inside of CASA. To do so type:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
or<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('more uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
CASA knows a few basic shell commands like 'cat', 'ls', and 'rm' but for more complex commands you will need to run them inside 'os.system("command")'. For more information see http://casa.nrao.edu/ .<br />
<br />
Here is an example of the (abridged) output from {{listobs}} for the first dataset in the list, uid___A002_X1ff7b0_Xb.ms, which targets the Northern Mosaic. You would see this if you had specified '''verbose''' to be False in the listobs call:<br />
<br />
<pre style="background-color: #fffacd;"><br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_Xb.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA(11 antennas)<br />
Data records: 181357 Total integration time = 4931.71 seconds<br />
Observed from 28-May-2011/01:25:27.6 to 28-May-2011/02:47:39.3 (UTC)<br />
<br />
Fields: 26<br />
ID Code Name RA Decl Epoch SrcId nRows <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 39116 <br />
1 none Titan 12:42:43.94813 -01.43.38.3190 J2000 1 10626 <br />
2 none NGC4038 - Antennae *12:01:53.17008 -18.52.37.9200 J2000 2 4818 <br />
3 none NGC4038 - Antennae *12:01:51.90301 -18.51.49.9437 J2000 2 6435 <br />
4 none NGC4038 - Antennae *12:01:52.43086 -18.51.49.9437 J2000 2 6424 <br />
5 none NGC4038 - Antennae *12:01:52.95871 -18.51.49.9437 J2000 2 5478 <br />
6 none NGC4038 - Antennae *12:01:53.48656 -18.51.49.9436 J2000 2 6435 <br />
7 none NGC4038 - Antennae *12:01:54.01441 -18.51.49.9436 J2000 2 6446 <br />
8 none NGC4038 - Antennae *12:01:52.16693 -18.51.56.4319 J2000 2 6435 <br />
9 none NGC4038 - Antennae *12:01:52.69478 -18.51.56.4318 J2000 2 6424 <br />
10 none NGC4038 - Antennae *12:01:53.22263 -18.51.56.4318 J2000 2 6446 <br />
11 none NGC4038 - Antennae *12:01:53.75049 -18.51.56.4318 J2000 2 6446 <br />
12 none NGC4038 - Antennae *12:01:51.90301 -18.52.02.9201 J2000 2 6435 <br />
13 none NGC4038 - Antennae *12:01:52.43086 -18.52.02.9200 J2000 2 6424 <br />
14 none NGC4038 - Antennae *12:01:52.95871 -18.52.02.9200 J2000 2 4818 <br />
15 none NGC4038 - Antennae *12:01:53.48656 -18.52.02.9200 J2000 2 4829 <br />
16 none NGC4038 - Antennae *12:01:54.01441 -18.52.02.9199 J2000 2 4829 <br />
17 none NGC4038 - Antennae *12:01:52.16694 -18.52.09.4082 J2000 2 4829 <br />
18 none NGC4038 - Antennae *12:01:52.69479 -18.52.09.4082 J2000 2 4829 <br />
19 none NGC4038 - Antennae *12:01:53.22264 -18.52.09.4082 J2000 2 3872 <br />
20 none NGC4038 - Antennae *12:01:53.75049 -18.52.09.4081 J2000 2 4829 <br />
21 none NGC4038 - Antennae *12:01:51.90301 -18.52.15.8964 J2000 2 4829 <br />
22 none NGC4038 - Antennae *12:01:52.43087 -18.52.15.8964 J2000 2 4829 <br />
23 none NGC4038 - Antennae *12:01:52.95872 -18.52.15.8963 J2000 2 4818 <br />
24 none NGC4038 - Antennae *12:01:53.48657 -18.52.15.8963 J2000 2 4818 <br />
25 none NGC4038 - Antennae *12:01:54.01442 -18.52.15.8963 J2000 2 4840 <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 354971.074 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 354916.143 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11 'name'='station' <br />
ID= 0-3: 'DV02'='A015', 'DV04'='J505', 'DV06'='T704', 'DV07'='A004', <br />
ID= 4-7: 'DV08'='A072', 'DV09'='A008', 'DV10'='A009', 'DV11'='A016', <br />
ID= 8-10: 'PM01'='T702', 'PM02'='A017', 'PM03'='J504'<br />
================================================================================<br />
<br />
</pre><br />
<br />
And here is an extract from the full '''verbose''' {{listobs}} for uid___A002_X1ff7b0_X1c8.ms, which targets the Southern Mosaic (note that we have snipped out the record of individual scans):<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_X1c8.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA<br />
Data records: 175615 Total integration time = 4927.1 seconds<br />
Observed from 28-May-2011/02:50:18.2 to 28-May-2011/04:12:25.3 (UTC)<br />
<br />
<snip><br />
<br />
Fields: 33<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 12232 <br />
1 none Titan 12:42:44.82765 -01.43.41.4224 J2000 1 10615 <br />
2 none 3c279 12:56:11.16600 -05.47.21.5250 J2000 2 27764 <br />
3 none Antennae 12:01:53.17008 -18.52.37.9200 J2000 3 4829 <br />
4 none Antennae 12:01:52.18699 -18.53.30.3952 J2000 3 3883 <br />
5 none Antennae 12:01:52.64413 -18.53.26.6494 J2000 3 3883 <br />
6 none Antennae 12:01:53.10127 -18.53.22.9035 J2000 3 3872 <br />
7 none Antennae 12:01:53.55841 -18.53.19.1577 J2000 3 4818 <br />
8 none Antennae 12:01:54.01554 -18.53.15.4119 J2000 3 4829 <br />
9 none Antennae 12:01:54.47268 -18.53.11.6661 J2000 3 4829 <br />
10 none Antennae 12:01:54.92982 -18.53.07.9203 J2000 3 3872 <br />
11 none Antennae 12:01:55.38696 -18.53.04.1744 J2000 3 3883 <br />
12 none Antennae 12:01:55.84409 -18.53.00.4286 J2000 3 4840 <br />
13 none Antennae 12:01:56.30123 -18.52.56.6828 J2000 3 4818 <br />
14 none Antennae 12:01:52.18700 -18.53.22.9033 J2000 3 4829 <br />
15 none Antennae 12:01:52.64414 -18.53.19.1575 J2000 3 4818 <br />
16 none Antennae 12:01:53.10128 -18.53.15.4116 J2000 3 4818 <br />
17 none Antennae 12:01:53.55842 -18.53.11.6658 J2000 3 4840 <br />
18 none Antennae 12:01:54.01555 -18.53.07.9200 J2000 3 3872 <br />
19 none Antennae 12:01:54.47269 -18.53.04.1742 J2000 3 4829 <br />
20 none Antennae 12:01:54.92983 -18.53.00.4284 J2000 3 4829 <br />
21 none Antennae 12:01:55.38697 -18.52.56.6825 J2000 3 4829 <br />
22 none Antennae 12:01:55.84410 -18.52.52.9367 J2000 3 4829 <br />
23 none Antennae 12:01:51.72988 -18.53.19.1572 J2000 3 4818 <br />
24 none Antennae 12:01:52.18702 -18.53.15.4114 J2000 3 4829 <br />
25 none Antennae 12:01:52.64415 -18.53.11.6656 J2000 3 4829 <br />
26 none Antennae 12:01:53.10129 -18.53.07.9197 J2000 3 2266 <br />
27 none Antennae 12:01:53.55843 -18.53.04.1739 J2000 3 2266 <br />
28 none Antennae 12:01:54.01557 -18.53.00.4281 J2000 3 3212 <br />
29 none Antennae 12:01:54.47270 -18.52.56.6823 J2000 3 3234 <br />
30 none Antennae 12:01:54.92984 -18.52.52.9365 J2000 3 3212 <br />
31 none Antennae 12:01:55.38698 -18.52.49.1906 J2000 3 2266 <br />
32 none Antennae 12:01:55.84411 -18.52.45.4448 J2000 3 3223 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 356845.586 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 356900.518 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11:<br />
ID Name Station Diam. Long. Lat. <br />
0 DV02 A015 12.0 m -067.45.15.3 -22.53.26.0 <br />
1 DV04 J505 12.0 m -067.45.18.0 -22.53.22.8 <br />
2 DV06 T704 12.0 m -067.45.16.2 -22.53.22.1 <br />
3 DV07 A004 12.0 m -067.45.15.9 -22.53.28.0 <br />
4 DV08 A072 12.0 m -067.45.12.6 -22.53.24.0 <br />
5 DV09 A008 12.0 m -067.45.15.4 -22.53.26.8 <br />
6 DV10 A009 12.0 m -067.45.16.1 -22.53.26.1 <br />
7 DV11 A016 12.0 m -067.45.16.4 -22.53.25.1 <br />
8 PM01 T702 12.0 m -067.45.18.6 -22.53.24.1 <br />
9 PM02 A017 12.0 m -067.45.15.9 -22.53.26.8 <br />
10 PM03 J504 12.0 m -067.45.17.0 -22.53.23.0 <br />
</pre><br />
<br />
This output shows that three sources were observed in each data set: 3c279, Titan, and the Antennae.<br />
<br />
* The '''Antennae''' are our science target. Note that the source name changes between the Northern Mosaic, where it is "NGC4038 - Antennae", and the Southern Mosaic, where it is just "Antennae". Also note that the source corresponds to a number of individual fields (see the Field ID column). These are the individual mosaic pointings. There are 23 for the Northern Mosaic and 29 for the Southern Mosaic.<br />
* '''Titan''' is observed once and will be used to set the absolute flux scale of the data.<br />
* '''3c279''' plays two roles: it will serve as our bandpass calibrator, to characterize the frequency response of the antennas, and because it is fairly close on the sky to the Antennae (18.6 degrees away) it will serve as our secondary calibrator (also referred to as the "phase calibrator" or "gain calibrator"), to track changes in the phase and amplitude response of the telescopes over time. Observations of 3c279 are interleaved with observations of the Antennae.<br />
<br />
The output also shows that the data contain many spectral windows. Using the labeling scheme in the listobs above these are:<br />
<br />
* '''spw 0''' targets ~185 GHz and holds water vapor radiometer data<br />
* '''spw 1''' and '''spw 3''' hold our science data. These are "Frequency Domain Mode" (FDM) data with small (0.49 MHz) channel width and wide (1.875 GHz) total bandwidth. As a result these have a lot of channels (3840). spw 1 holds the lower sideband (LSB) data and includes the CO(3-2) line. We will focus on these data. For the CO(3-2) line the channel width corresponds to 0.426 km/s and the bandwidth of spw 1 to 1634 km/s.<br />
* '''spw 2''' and '''spw 4''' hold frequency-averaged versions of spw 1 and 3 ("Channel 0" for those familiar with AIPS). These are used for some quick automated inspection. We will not use them here but we will carry out an equivalent inspection using spw 1.<br />
* '''spw 5''' and '''spw 7''' hold lower a resolution processing ("Time Domain Mode", TDM) of the data from the same part of the spectrum (baseband) as spws 1 and 3. These data have only 128 channels across 2 GHz bandwidth and so have a much coarser channel spacing than the FDM data. These were used to generate the calibration tables that we include in the tarball but will not otherwise appear in this guide.<br />
<br />
The final column of the listobs output in the logger (not shown above) gives the scan intent. Later we will use this information to flag the pointing scans and the hot and ambient load calibration scans.<br />
<br />
We'll now have a look at the configuration of the antennas used to take the data using the task {{plotants}} (<xr id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"><br />
[[File:Uid_A002_X1ff7b0_Xb.ANT_6.1.png|200px|thumb|right|<caption> Position of antennas in dataset uid_A002_X1ff7b0_Xb obtained using task plotants. </caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Antenna configuration for : "+asdm)<br />
plotants(vis=asdm+'.ms', figfile=asdm+'.plotants.png')<br />
clearstat()<br />
dummy_string = input("Hit <Enter> to see the antenna configuration for the next data set.")<br />
</source> <br />
<br />
This will loop through all 10 data sets, show you the antenna position for each, and save that as a file named, e.g., "uid___A002_X1ff7b0_Xb.plotants.png" for the first data set. The "input" command asks CASA to wait for your input before proceeding. If you would prefer to just browse the .png files after the fact you can remove this. Notice that the antenna setup changes, but only slightly, over the course of the 10 data sets.<br />
<br />
==How to Deal With 10 Measurement Sets==<br />
<br />
It should already be clear from the initial inspection that dealing with 10 data sets at the same time can be a bit problematic. This is especially tricky in our case because the Antennae data contain two distinct sets of observations: the Northern and Southern Mosaics. The source name changes between these two scripts and there are different numbers of fields in the mosaic.<br />
<br />
''As a general rule one would reduce each individual observation separately or at the very least only group data observed in a uniform way and very close in time.'' <br />
<br />
Unfortunately, a CASA Guide stepping through the reduction for each of 10 data sets would quickly become unwieldy. Therefore we will use a few tricks to reduce the Antennae data in a kind of batch mode. You have already seen the first trick: we can define a python list holding the names of each data set and then loop over this list to execute the same command on each data set. For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print (asdm)<br />
</source><br />
<br />
You only need to define your list of MS files once per CASA session. Then "basename_all" will be a variable in the casapy shell. You can check if it exists by typing "print (basename_all)". In the interests of allowing you to easily exit and restart CASA and pick this guide up at any point we will redefine "basename_all" in each section of the guide. Feel free to skip this step if you've already defined it in your session.<br />
<br />
This page will step you through the reduction of the whole Antennae Band 7 SV data set using these 'for' loops. We will not be able to show every diagnostic plot but we give an example of each and the syntax to generate the rest. Also please be aware that even on a very fast machine this whole process can take a while, we are simply dealing with a lot of data.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
One potential "gotcha" is that the source name changes between the two data sets. Therefore at several points we will break apart our loop to iterate separately over the Northern and Southern Mosaics, where the source can be referred unambiguously. Another subtle point is that 3c279 appears with two distinct field IDs in the Southern Mosaic, but only one in the Northern Mosaic. We will largely avoid this by referring to the source by its name but if you tried to use field ID numbers and mingled the two data sets this could cause confusion.<br />
</pre><br />
<br />
==''A Priori'' Flagging==<br />
<br />
Even before we look in detail, we know that there are some data that we wish to exclude. We will start by flagging "shadowed" data where one antenna blocks the line of sight of another. We will also flag scans that were used to carry out pointing and atmospheric calibration, identified by their scan intent. Finally, we'll flag the autocorrelation data (the correlation of the signal from an antenna with itself) as we are only interested in cross-correlation data to make an interferometric image.<br />
<br />
Start by defining our list of MS files:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
You may want to reset the flagging if you have tried this step before and are starting over though this is not necessary on your first time through. Do so using {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Resetting flags for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='unflag', flagbackup=False)<br />
</source><br />
<br />
Then flag shadowed data using the command {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging shadowed data for "+asdm)<br />
flagdata(vis=asdm+'.ms',mode = 'shadow', flagbackup = False)<br />
</source><br />
<br />
In the {{flagdata}} task we choose:<br />
<br />
* '''vis''' = asdm+'.ms' : each measurement set<br />
* '''mode''' = 'shadow': flag shadowed data<br />
* '''flagbackup''' = False: Do not automatically back up the flag files. We will save all of the ''a priori'' flags together using {{flagmanager}} at the end of this subsection and save some space and time.<br />
<br />
The relevant calibration information has already been extracted from the pointing and atmospheric scans and we will not need them below. Now flag the pointing scans using {{flagdata}} in 'manualflag' mode and selecting on 'intent':<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging calibration scans for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='manual', intent='*POINTING*', flagbackup = False)<br />
</source><br />
<br />
Note that because the atmospheric calibration scans contain only TDM spectral windows, they will be removed automatically when we separate out the FDM data below.<br />
<br />
Now flag the autocorrelation data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging autocorrelation data for "+asdm)<br />
flagdata(vis=asdm+'.ms',autocorr=True,flagbackup=False)<br />
</source><br />
<br />
Finally store the current flags information using {{flagmanager}}: <br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Backing up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'save', versionname = 'Apriori')<br />
</source><br />
<br />
Where '''versionname''' is just the name we assign to the current flagging state in the data. We can now roll back the flags to match the current version, called 'Apriori', whenever we want. There is no reason to do this now, but the syntax would be:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Restoring up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'restore', versionname = 'Apriori')<br />
</source><br />
<br />
<br />
It would have been possible to set {{flagdata}} to '''flagbackup'''=True so that it stores the flags at each of the flagging step automatically, but this way it is a bit more efficient with regard to time and disk space. More important, lumping all the ''a priori'' flagging together gives us a natural point to roll back to if we get in trouble.<br />
<br />
<br />
The flagmanager task will also allow you to view the saved flagging versions,<br />
including those created by running flagdata with flagbackup=True.<br />
<br />
For example try <br />
<br />
<source lang="python"><br />
# In CASA<br />
flagmanager(vis='uid___A002_X2181fb_X49.ms', mode='list')<br />
</source><br />
<br />
The output in the logger should list the Apriori flagging that we have applied.<br />
It will also indicate versions associated with any flagdata command where you<br />
did not set flagbackup=False. Other tasks, for example applycal, will also create<br />
flag version tables.<br />
<br />
==Create and Apply Tsys, WVR, and Antenna Position Calibration Tables==<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
===Tsys===<br />
<br />
The Tsys calibration gives a first-order correction for the atmospheric opacity as a function of time and frequency and associates weights with each visibility that persists through imaging.<br />
<br />
Use gencal to create the Tsys calibration tables from the spectral windows with CALIBRATE_ATMOSPHERE intents in listobs (i.e. the TDM spectral windows with 128 channels), these are spectral windows 5 and 7.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#Removing existing Tsys information<br />
os.system('rm -rf *tdm.tsys')<br />
for asdm in basename_all:<br />
print ("Creating TDM Tsys Table for "+asdm)<br />
gencal(vis=asdm+'.ms',caltable=asdm+'.tdm.tsys',spw='5,7',caltype='tsys')<br />
</source><br />
<br />
Later in the applycal stage this TDM Tsys table will be interpolated to the FDM (3840 channels per spw) science spectral windows 1 and 3.<br />
<br />
Next we inspect the Tsys tables for the spectral window '''spw''' = 5 with the task {{plotms}}. In previous CASA versions, we used {{plotcal}} for this task, but most of '''plotcal''''s functionality is now included in {{plotms}}, and '''plotcal''' will be deprecated in a future CASA release. We want to check that Tsys data have reasonable values and identify any unexpected features as a function of either time or frequency. To get an idea of sensible Tsys under average atmospheric observations consult the ALMA sensitivity calculator, accessible from http://www.almascience.org (via the "Documents & Tools" link).<br />
<br />
We start by plotting the Tsys for all the antennas and polarizations (XX and YY) as a function of time for each. <!--Here and throughout we focus on spw 1, which contains CO(3-2): --><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Note that right now, plotms can't select individual channels when plotting caltables (as was possible with plotcal). In addition, when iteraxis is set, plotms appends the axes being iterated over to the output filename specified in plotfile; this can make for rather unwieldy filenames (particularly when iteraxis='antenna'!) but is useful for the ALMA pipeline. <br />
</pre><br />
<br />
<figure id="Xb.Tsys_vs_time.page1.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page1.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 8 antennas. Note the high y-axis values for DV04. The two different colors indicate the two polarizations (XX and YY).</caption>]]<br />
</figure><br />
<figure id="Xb.Tsys_vs_time.page2.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page2.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting Tsys vs. time for "+asdm)<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='0~7',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page1.png',overwrite=True)<br />
#dummy_string = input("First eight antennas for "+asdm+" . Hit <Enter> to continue.")<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='8~15',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page2.png',overwrite=True)<br />
#dummy_string = input("Remaining antennas for "+asdm+" . Hit <Enter> to continue.")<br />
</source><br />
<br />
This sequence loops over all of our files and plots Tsys as a function of time for channel 50 in spectral window 5. In the call to {{plotms}}:<br />
<br />
* '''gridrows'''=4 and '''gridcols'''=2 sets up a 4 x 2 panel grid. <br />
* '''iteraxis'''='antenna' tells {{plotms}} to make a separate plot for each antenna.<br />
* '''spw'''='5:50~50' selects spw '5' channel 50-50. This allows us to cleanly separate time variations from frequency variations. '''Note that this is a functionality in plotcal but not yet in {{plotms}}, and plotms is actually showing all channels from spw 5 at this time.'''<br />
<br />
Because 8 panels (2 panels for each antenna - LSB and USB) is not enough to show all antennas on one page, there are two {{plotms}} calls: one for the first 8 antennas ('''antenna'''='0~7'), and then for the remaining antennas ('''antenna'''='8~15').<br />
<br />
The 'input' commands will wait for you to hit Enter before issuing the next plot command. In the example above these are commented out (the leading "#" means that CASA will ignore them). If you would like to interactively cycle through the plots, uncomment them by removing the "#". Otherwise, the '''plotfile''' parameter directs the output to .png files for later inspection. The easiest way to look at the 20 plots produced here is to simply inspect the .png files using your favorite viewer. As noted above, here plotms is adding the antenna information to the filenames because we set '''iteraxis''' = 'antenna', so check your directory for the impressively long filenames to view them. <br />
<br />
The Tsys values in <xr id="Xb.Tsys_vs_time.page1.6.1.png"/> and <xr id="Xb.Tsys_vs_time.page2.6.1.png"/> look reliable, with typical values ~150 K except for some large values of Tsys at ~400 and 500 K for DV04. We will flag the data for that antenna later. <br />
<br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV02.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 4 antennas. Note the high y-axis values for DV04 and the mesospheric line near 343.2 GHz.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV08.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Next 4 antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"><br />
[[File:uid___A002_X215db8_X392.tdm.tsys.3c279.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid___A002_X215db8_X392. Note the pathological behavior for DV12.</caption>]]<br />
</figure><br />
<br />
We will also want to look at Tsys as a function of frequency. <br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
os.system('rm -rf cal_plots/Tsys_plots/'+asdm+'.tdm.tsys*')<br />
tsysfields=['3c279','Titan','*Antennae*']<br />
caltable=asdm+'.tdm.tsys'<br />
for field in tsysfields:<br />
plotbandpass(caltable=caltable,yaxis='amp',field=field,xaxis='freq',<br />
showatm=True,overlay='time',<br />
figfile='cal_plots/Tsys_plots/'+caltable+'.'+field,<br />
buildpdf=False,interactive=False,chanrange='8~120',subplot=42)<br />
</source><br />
<br />
You will see the following statement in the logger, but this is fine: <br />
<br />
<pre style="background-color: #fffacd;"><br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
</pre><br />
<br />
Now have a look at the Tsys vs. frequency plots or see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/>, <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"/>, and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/> for examples on the first data set. You can see the effect of a close pair of atmospheric ozone absorption lines at about 343.2 GHz that makes Tsys larger near that frequency in all antennas. Applying the Tsys calibration tables will minimize the contribution of these atmospheric lines. Again DV04 stands out with its very high Tsys. Although not present in the first data sets, Antenna DV12 exhibits periodic spikes in Tsys vs. frequency for one polarization (see <xr id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"/> for an example from a later data set). It may or may not be possible to calibrate that behavior out. We will make a note to look carefully at DV12 further on in the calibration process.<br />
<br />
===WVR===<br />
The WVR calibration uses observations of the wings of the 183 GHz atmospheric water line to correct for phase variations as a function of time. As noted in the tsys section, this run of gencal will append to existing WVR produced tables. To avoid this, preexisting wvrgcal data is removed. <br />
<source lang="python"><br />
#In CASA<br />
#Removing existing WVR information<br />
os.system('rm -rf *.wvrgcal')<br />
for asdm in basename_all:<br />
wvrgcal(vis=asdm+'.ms',caltable=asdm+'.wvrgcal',toffset=-1)<br />
</source><br />
<br />
===Antenna Positions===<br />
<br />
In general, the most appropriate antenna positions for the dataset will be determined and updated if needed during QA2. If the antenna positions need to be updated after QA2, we inform the PIs of the affected datasets and provide instructions on how to update the antenna positions. For the data in this guide, we do need to update the antenna positions. <br />
<br />
The antenna position table reflects refinements in the measured positions of the antennas from those stored in the data. {{gencal}} will now be used put antenna position data into each observation. Again, {{gencal}} will merely append to existing antenna position data, ruining any subsequent results. We start by removing any existing antenna position refinements, followed by defining the antenna names, then their refinements (both as arrays), finally running {{gencal}} to create the information CASA can refer to for antenna positions.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_Xb.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:21]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3a.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3b9.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X2181fb_X49.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV01,DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
-0.00004, 0.00026, 0.00019, #DV01-A137<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_X1c8.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X1f7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X4d7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X18.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X1d5.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X392.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
</source><br />
<br />
===Applycal===<br />
<br />
We are now ready to apply the Tsys and the WVR calibration tables to the data with {{applycal}}, which reads the specified gain calibration tables, applies them to the (raw) data column, and writes the calibrated results into the corrected column. Again, we loop through all the datasets. It is important to only apply Tsys and WVR corrections obtained close in time to the data being corrected, so in addition to looping over data sets we define the list of unique source names and loop over these. Then by setting '''gainfield''' and '''field''' to the same value we ensure that Tsys and WVR calibrations are only applied to the source for which they are measured. Because the source has a different name in the Northern Mosaic and the Southern Mosaic, we will carry out two loops. We will only correct '''spw''' 1 and 3, our science windows, because we will drop the other data in a moment.<br />
<br />
The applycal task now has much more flexibility for interpolating and applying calibrations derived in one spectral window to another, even if they do not share the same spectral shape (number of channels and channel width). This new functionality is used below to interpolate the TDM (128 channel) Tsys measurements to the FDM (3840 channel) spectral windows. This is controlled through the spectral window mapping parameter *spwmap*. Because this can be a bit confusing, we've written a "helper" function that will tell you what you should put for the Tsys calibration table part of spwmap. We only need to run it on one of the datasets because they are all the same in this regard<br />
<br />
<source lang="python"><br />
# In CASA<br />
from casarecipes.almahelpers import tsysspwmap<br />
tsysspwmap(vis='uid___A002_X207fe4_X3a.ms',tsystable='uid___A002_X207fe4_X3a.tdm.tsys')<br />
</source><br />
<br />
This will print to your screen: [0, 5, 5, 7, 5, 5, 5, 7]. Recall that the TDM spectral windows are spw=5 and 7 and the FDM spectral windows are 1 and 3. This spwmap tells applycal to use the Tsys information in spectral window 5 for spectral window 1; and to use the information in spectral window 7 for spectral window 3. Beyond that, it is only important that there are placeholders for the other spectral windows, its also useful to note that you need not give placeholders for spectral window ids larger than the largest spectral window you need to use, in this case 7.<br />
<br />
You will also need to put in placeholders for other tables that you give the gaintables. So if the Tsys table is 2nd in the list, spwmap=[[],[0,5,5,7,5,5,5,7],[]]<br />
<br />
Now run the applycal commands.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# A new list of file names that contain only data from the Northern Mosaic<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names_north = ['Titan','3c279','NGC*']<br />
<br />
for asdm in basename_north:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_north:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=['',field,field],<br />
interp=['','linear,spline','nearest'], <br />
gaintable=[asdm+'.antpos',asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]],<br />
flagbackup=False, calwt=True)<br />
<br />
# A new list of file names that contain only data from the Southern Mosaic<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names_south = ['Titan','3c279','Ant*']<br />
<br />
for asdm in basename_south:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_south:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=["",field,field],<br />
interp=['','linear,spline','nearest'],<br />
gaintable=[asdm+".antpos",asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]], <br />
flagbackup=False, calwt=True)<br />
</source><br />
<br />
where:<br />
<br />
*'''field''': the field ''to'' which we will apply the calibration, <br />
*'''gainfield''': the field ''from'' which we wish to take the calibration table<br />
*'''interp''' = 'nearest' : apply the nearest solution from the calibration table rather than interpolating.<br />
<br />
As you browse through the whole data set, you will probably note some problems along the same lines as the DV04 issue we saw above. We'll apply these as additional data flagging in just a moment.<br />
<br />
==Inspect Data==<br />
We are not quite done with the original ".ms" data sets yet. Before going further it will be useful to use {{plotms}} to show the effects of applying the calibration. In the process we'll take a quick look at each antenna and search for pathologies in the data.<br />
<br />
For this basic inspection, we want to compare the phase and amplitude as a function of frequency and time in the DATA and CORRECTED columns of each measurement set. The CORRECTED column has had the Tsys and WVR calibrations applied and so we expect lower phase scatter and flatter amplitude response as a function of time and frequency. We are looking for antenna-based issues, so cycling through a set of baselines that includes each antenna once will be a good start. We'll focus these plots on the phase+bandpass calibrator, 3c279, and on baselines that include antenna DV11, which we will make our reference antenna in just a bit.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
Each CASA Measurement Set has up to three "columns" of data: DATA, CORRECTED, and MODEL (though it is possible<br />
for a MS to hold only a DATA column if it has not been processed at all). <br />
<br />
A column entry exists for each data point (baseline, frequency, time). <br />
<br />
The DATA column holds the current raw data, though using split as we just did we can change the definition of<br />
"raw" data. <br />
<br />
The CORRECTED column holds the result of applying one or more calibration tables (e.g., via applycal) to the<br />
DATA column and so represents a corrected version of the DATA column. <br />
<br />
The MODEL column is now deprecated (though it is still possible to use it by explicitly setting usescratch=True).<br />
Instead, the model is stored in the header of the ms. This is a great step forward in terms of saving space and time <br />
to create scratch columns <br />
<br />
To get an intuitive feel for the columns you may wish to explore using plotms (which can plot different data <br />
columns, as seen below) or the browsetable task.<br />
<br />
</pre><br />
<br />
<figure id="plotms_amp_vs_freq_example-data.png"><br />
[[File:plotms_amp_vs_freq_example-data_6.1.png|200px|thumb|right|<caption> Example of Amplitude vs. Frequency before correction for the 3c 279.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_example-corr.png"><br />
[[File:plotms_amp_vs_freq_example-corr_6.1.png|200px|thumb|right|<caption> Same baseline as Figure 8 but now after correction using WVR and Tsys calibrations.</caption>]]<br />
</figure><br />
<br />
First, we plot amplitude as a function of frequency for 3c279. We start by plotting the DATA column, set color to indicate the two correlations (i.e., the XX and YY polarizations), and ask plotms to iterate over baseline. By setting '''antenna''' to 'DV11&*' we select only baselines that include DV11. We ask plotms to average all data over a very long timescale, '''avgtime''' = 1e8 seconds ~ 3 years or much longer than the time spanned by the whole data set. By setting '''avgscan''' = True we allow {{plotms}} to average across scan boundaries. The result is a plot of average amplitude per channel vs. frequency.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
asdm=basename_all[0]<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='amp',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Notice the green arrows along the bottom of the {{plotms}} window. We asked {{plotms}} to iterate over baseline. As you click the arrows, the plot will rotate from baseline to baseline, always with DV11 so that each antenna shows up once. To see the effect of the calibration, go to the "Axes" tab along the left of the {{plotms}} window and pull down the Data Column menu under the Y Axis. Set this from DATA to CORRECTED and you should see the effects of the calibration. You may need to ensure that the "Force Reload" box is checked before clicking "Plot" (both buttons lie at the bottom of the panel). For the most part things get better (flatter), but as we noted before DV04 is problematic.<br />
<br />
<figure id="plotms_amp_vs_time_north.png"><br />
[[File:plotms_amp_vs_time_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_time_south.png"><br />
[[File:plotms_amp_vs_time_south_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a southern mosaic data set.</caption>]]<br />
</figure><br />
<br />
You can now make analogous calls to examine the phase vs. frequency, amplitude vs. time, and phase vs. time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='phase',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='amp',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='phase',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Where:<br />
<br />
* '''spw''' is set to cover only channels 1200~1300 for the time plots in order to isolate time dependent variations from frequency-dependent behavior. Those 101 channels represent only a small part of the total spw 1 bandpass.<br />
* '''avgchannel''' set to a large number causes the plots of phase and amplitude vs. time to average data at all frequencies into a single point for each measurement.<br />
* '''coloraxis''' corr sets the colors to correspond to the two polarizations of the data.<br />
<br />
In each case, you will want to examine each baseline, alternating between the DATA and CORRECTED columns.<br />
<br />
This is a lot of data inspection and that's only for one of 10 data sets! You can iterate across the data by hand, updating "asdm" to refer to each data set in order and cycling between baselines and DATA/CORRECTED. It is also possible to script CASA to show you the key plots in succession (see the next block down). However you approach the infrastructure, you are looking for:<br />
<br />
* Improved scatter and lower variability in phase and amplitude vs. frequency and time. This indicates that the WVR and Tsys calibrations helped. <br />
* Sudden jumps in phase or amplitude as a function of either time or frequency. These may indicate problems with the antenna during that observation.<br />
* Large gradients, especially full wraps, in phase as a function of frequency. This may indicate a problem in the delays, the signal path length to the telescopes.<br />
* Unusual magnitude, scatter, or patterns in any plot - though this may be better explored using plots that show all data together, which we'll make in a moment.<br />
* Missing data. For example, if the phase calibrator drops out for a period of time we will not be able to calibrate and will need to flag the data.<br />
<br />
As you look through, note individual potentially problematic antennas. If ''all'' antennas in a data set appear problematic it may be that your "reference" antenna, DV11 in the example above, is the source of the problem. In this case swap this reference antenna for another and see whether the problem is isolated to your original reference antenna.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
A brief aside on structure:<br />
<br />
This section (Data Inspection) and the next (Apply Flags) are closely linked. We will present them as two<br />
separate steps. The idea here is that you look through your data, note problems, and then write commands to<br />
flag problematic data. This mimics one approach to writing data reduction scripts for CASA, where you will<br />
group all flagging together into one convenient place. Other CASA guides take a different approach, interleaving <br />
flagging and plotting. There is no "right" answer here. Find an approach to data inspection that works for you.<br />
<br />
</pre><br />
<br />
If you do wish to semi-automate the plot generation, the following sequence will cycle between data and corrected plots for each data set in turn. Type "stop" at any input call to break out.<br />
<br />
<!--<br />
'''Note:''' In loops like this involving {{plotms}}, hitting enter before the last dataset completes loading may cause {{plotms}} to stop refreshing the plot window at each step, or cause the window to disappear altogether. This will be fixed in an upcoming CASA release. Right now, you may need to exit CASA and restart to bring up the {{plotms}} window again, but you should be able to continue in the script where you left off.<br />
--><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
user_input = ""<br />
for asdm in basename_all:<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
# Extract antenna list for this data set.<br />
tb.open(asdm+'.ms/ANTENNA', nomodify=True)<br />
ants = tb.getcol('NAME')<br />
tb.close<br />
# Define the reference antenna to make baselines with<br />
ref_ant = 'DV11'<br />
# Loop over antennas<br />
for ant in ants:<br />
# Check if the user wants to stop<br />
if user_input == "stop":<br />
break<br />
# Skip correlation of reference antenna with itself (autocorrelations are flagged anyhow) <br />
if ant == ref_ant:<br />
continue<br />
# Define the baseline with the reference antenna for current antenna<br />
ant_str = ref_ant+'&'+ant<br />
print ("Showing baseline "+ant_str+" for data set "+asdm)<br />
print ("Use this to inspect effect of applying wvrcal and Tsys calibrations.")<br />
# Loop over phase and amplitude as axes<br />
for y_axis in ["amp", "phase"]:<br />
# Make 'before' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'before' plot for time x-axis<br />
print ("... "+y_axis+" vs. time for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for time y-axis<br />
print ("... "+y_axis+" vs. time for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<figure id="plotms_amp_vs_uvdist_north.png"><br />
[[File:plotms_amp_vs_uvdist_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. uv-distance for 3c279 in the first northern mosaic data set.</caption>]]<br />
</figure><br />
<br />
<figure id="plotms_amp_vs_freq_3c279.png"><br />
[[File:plotms_amp_vs_freq_3c279_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for 3c279 in the second northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Titan.png"><br />
[[File:plotms_amp_vs_freq_Titan_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for Titan in the second northern mosaic data set. Note the strong line (this is CO 3-2)!</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Antennae.png"><br />
[[File:plotms_amp_vs_freq_Antennae_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for the Antennae in the second northern mosaic data set. The CO(3-2) line is visible.</caption>]]<br />
</figure><br />
<br />
A detailed explanation of the procedure is a bit outside the scope of this guide (for more on python see http://www.python.org/ and for more on the CASA toolkit see http://casa.nrao.edu/), but the basic process is to loop over each data set, baseline with the reference antenna (here DV11), and y-axis of interest (phase or amplitude) then plot the effect of the calibration vs. frequency and time for each combination. Running this to step through the data will give you about 200 "before and after" plots from which you could note a subset of problematic cases to be followed up by hand. Many other strategies to inspect the data are also viable.<br />
<br />
With the Tsys and WVR calibrations applied successfully and the ''a priori'' flagging taken care of we will now {{split}} out the corrected data. We will keep only the corrected data, specified via '''datacolumn''', and only spectral window 1, which contains the FDM (high spectral resolution) observations of the CO(3-2) line. Setting '''keepflags'''=False tells {{split}} not to carry over any fully flagged rows from the original data set to the new MS. We give the new MS files the extension ".wvrtsys.ms" to indicate that they have been corrected for WVR and Tsys effects. Because split will not overwrite existing files, we remove any previous versions of the new MS before beginning.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm -rf '+asdm+'.wvrtsys.ms')<br />
print ("Splitting out corrected data for "+asdm)<br />
split(vis=asdm+'.ms', outputvis=asdm+'.wvrtsys.ms', <br />
datacolumn='corrected', spw='1', keepflags=False)<br />
</source><br />
<br />
Be patient, {{split}} may take awhile. The WVR and Tsys-corrected data now sit in the DATA column of the new measurement sets, which have only one spectral window (now labeled spectral window 0 though it was spectral window 1 in the original data). You may wish to run {{listobs}} to illustrate the changes:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.wvrtsys.listobs.txt')<br />
listobs(vis=asdm+'.wvrtsys.ms', listfile=asdm+'.wvrtsys.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note the new spectral window information:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
2011-08-05 01:07:08 INFO listobs Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
2011-08-05 01:07:08 INFO listobs SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
2011-08-05 01:07:08 INFO listobs 0 3840 TOPO 344845.586 488.28125 1875000 344908.33 XX YY <br />
<br />
</pre><br />
<br />
<br />
Next we will do a bit more inspection using {{plotms}} to look at whole data sets. This will help us identify missing data or look for egregious outliers.<br />
<br />
First we plot amplitude versus time (see <xr id="plotms_amp_vs_time_north.png"/> and <xr id="plotms_amp_vs_time_south.png"/>), averaging over all channels (by setting '''avgchannel''' to the very large value 10,000). We colorize by field so that scans on Titan are red, the bandpass and phase calibrator 3c279 is black (and orange in the Southern Mosaic where it has two field IDs), and the Antennae mosaic appears as a range of colors (one per pointing).<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='amp', <br />
avgchannel='3840',coloraxis='field', showgui = True)<br />
user_input = input("Examining amplitude vs. time for "+asdm+" . Hit <Enter> to proceed.[type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
Here look for:<br />
<br />
* Missing data. The source needs to be flanked by phase calibrator scans, if those are missing for any reason we need to flag the appropriate time range.<br />
* Dramatic outliers. Does the source suddenly get very bright or the otherwise bright calibrator appear anomalously faint for a brief time? This likely indicates problematic data that should be identified and flagged. You can use the "select" (box with green plus along the bottom row in plotms) and "locate" (magnifying glass) buttons in {{plotms}} to isolate and identify problem data (it will print to the log).<br />
* Smooth variation with time. A sudden jump may indicate a problem and often the safest approach is to flag data near a discontinuity.<br />
<br />
Look through the amplitudes vs. time for each data set (remember that we've already examined the phases vs. time and amplitude vs. time for individual baselines above).<br />
<br />
There are two other very useful "averaging" plots worth making. First, we plot amplitude as a function of u-v distance (projected antenna separation). Discontinuities and spikes in this plot are often from non-astrophysical sources. In the phase analog to the plot, the effects of atmospheric decorrelation can be assessed from increased scatter at longer u-v distances. While using the moon Titan as our flux calibrator, we may want to watch for flaring amplitudes at short u-v distances. These may indicate that Saturn is contaminating our beam. For a perfect, bright point source, we expect flat amplitudes as a function of u-v distance at the source amplitudes. <xr id="plotms_amp_vs_uvdist_north.png"/> shows an example of this plot, generated via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='3c279',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. UV Distance for 3c279 for "+asdm+" . Hit <Enter> to proceed.")<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='Titan',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
user_input = input("Examining amplitude vs. UV Distance for Titan for "+asdm+" . Hit <Enter> to proceed [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
<br />
<br />
It can also be useful to examine the average amplitude as a function of frequency for each target. This allows one to check for lingering atmospheric effects, unexpected line emission or absorption in the calibrators, or decreased sensitivity due to "roll-off" of the telescope sensitivity at the band edges. These plots are created by the sequence of commands below, where we have broken up the script to loop separately over the Northern and Southern Mosaics to reflect the different source names.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names = ["3c279","Titan","NGC*"]<br />
<br />
for asdm in basename_north:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+". Hit <Enter> to proceed.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names = ["3c279","Titan","Ant*"]<br />
<br />
for asdm in basename_south:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+" . Hit <Enter> to proceed.")<br />
<br />
</source><br />
<br />
<br />
For this command notice that we can see the CO(3-2) line in the Antennae even before calibration (see <xr id="plotms_amp_vs_freq_Antennae.png"/>) and that Titan also shows evidence of a strong line (also <xr id="plotms_amp_vs_freq_Titan.png"/>)! This will need to be flagged before we can use Titan to calibrate the flux scale of our data.<br />
<br />
This suite of plots (along with the earlier inspection of the Tsys tables) gives us the tools we need to identify problematic data through the data sets. We use this to generate a set of inspection-driven {{flagdata}} commands for each data set. We apply these before the bandpass and gain calibration.<br />
<br />
==Apply Flagging==<br />
Based on this inspection and the other plots we have made, we now flag problematic portions of the data. We break up the flags by reason for flagging in order to illustrate the process. As you reduce your own data it may be more efficient to group flags by data set and make use of the flagcmd command. Except for the "post-calibration" flagging, the inspection plots that we just looked through have already revealed all of the problems that we flag. We structure the guide so that the flagging is grouped in one place.<br />
<br />
As before, we may wish to reset our flags before beginning (particularly if one iterates this process) via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms',mode='unflag', flagbackup = False)<br />
</source><br />
<br />
Remember that we dropped the flagged data when splitting out after the WVR and Tsys calibration, so this should not undo your "A Priori" flagging of shadowed data, autocorrelations, etc.. In any case this unflagging step is not necessary during the first iteration.<br />
<br />
* '''Edge Channels'''<br />
<br />
ALMA's sensitivity decreases near the edge of the baseband and it is often useful to check for a 'roll-off' in sensitivity near the edge of the band. This will appear as a downturn in amplitude as a function of channel near the edge of the window in the uncalibrated data, as a flaring due to increased noise at the spw edges in the calibrated data. It will also be visible in the amplitude part of the bandpass calibration table. Because our FDM spw does not cover the full baseband, we do not see a strong roll off in our data (see <xr id="amp_vs_channel_example.png"/>), where there is only a mild hint of a roll-off at the high end) but we do flag a (very) few channels at the high and low-frequency edge of the data set to be safe.<br />
<br />
<figure id="amp_vs_channel_example.png"><br />
[[File:amp_vs_channel_example.png|200px|thumb|right|<caption> Amplitude vs. channel for one uncalibrated antenna pair. This kind of plot can be inspected to get an idea of the presence or magnitude of any roll-off in sensitivity near the edges of the spectral window.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:0~7,0:3831~3839', flagbackup = False)<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:3260~3320', flagbackup = False)<br />
</source><br />
<br />
* '''Problematic Tsys measurements'''<br />
<br />
Above we noted issues with the Tsys measurements for both DV04 and DV12. We flag the affected data. Each of these issues should be visible in the Tsys plots you made above (e.g., see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/> and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/>).<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04',flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X1d5"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X392"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
</source><br />
<br />
* '''Unreliable Short-Spacing Measurements on Titan'''<br />
<br />
<figure id="amp_vs_uv_titan_obs.png"><br />
[[File:amp_vs_uv_titan_obs.png|200px|thumb|right|<caption> Observed amplitude vs. uv-distance for observations of Titan in the first data set. Note the scatter for low projected antenna separations. We will flag these short-spacing data, which may reflect contamination by Saturn, and use only the more extended baselines for flux calibration.</caption>]]<br />
</figure><br />
<br />
Saturn may contaminate the short u-v spacings from Titan. In any case these often show significant scatter (<xr id="amp_vs_uv_titan_obs.png"/>), so we flag them. There are still enough baselines to determine a good amplitude calibration for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~40', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
</source><br />
<br />
* '''Delay Issues''' <br />
<br />
<figure id="phase_vs_freq_DV13.png"><br />
[[File:phase_vs_freq_DV13.png|200px|thumb|right|<caption> Phase vs. frequency for DV13 in a data set where this antenna shows evidence of imperfect delay calibration.</caption>]]<br />
</figure><br />
<br />
DV13 and a few other antennas show signatures of an imperfect delay calibration. This is most easily identified via strong "wrapping" of phase as a function of frequency (see <xr id="phase_vs_freq_DV13.png"/>). Such effects can be calibrated out with mild delay issues largely accounted for by the bandpass solution. The phase wrapping in DV13 seems weak enough that we will trust the calibrations to remove it. For a more extreme example see the CASA guide describing the calibration of [[NGC3256Band3]].<br />
<br />
* '''Missing Phase Calibrator Observations'''<br />
<br />
<figure id="amp_vs_time_missing_scans.png"><br />
[[File:amp_vs_time_missing_scans.png|200px|thumb|right|<caption> Amplitude vs. time colored by field for a data set where the final visit to the phase calibrator is missing. We will flag the last set of source data to ensure that each visit to the source is flanked in time by visits to the phase calibrator.</caption>]]<br />
</figure><br />
<br />
As a general rule, we want to be sure that observations of the phase calibrator (3c279) bracket each source observation. Two of the data sets do not include a final phase calibrator observation (see <xr id="amp_vs_time_missing_scans.png"/>) and for those two cases we flag the affected source observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='00:53:47~01:08:00',flagbackup = False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV10',timerange='19:46:20~20:34:40',flagbackup=False)<br />
</source><br />
<br />
* '''Unexpected Scatter or Discontinuity in the Data'''<br />
<br />
For several antennas we find sudden jumps in the phase of the phase calibrator as a function of time. These are visible in the plots of uncalibrated phase vs. time for single baselines above, and we show an example in <xr id="phase_vs_time_DV09.png"/>. It will not be possible to effectively interpolate the phase between measurements when we see these discontinuities. The safest approach is to flag the source data across these jumps. We do so here (though note that the last two flaggings are borderline cases).<br />
<br />
<figure id="phase_vs_time_DV09.png"><br />
[[File:phase_vs_time_DV09.png|200px|thumb|right|<caption> Phase vs. time for DV09 on a problematic day. It may prove problematic to calibrate the data near this discontinuity so we flag data near this time.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09', timerange='21:24:09~21:35:35', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09',timerange='23:30:52~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM01',timerange='23:16:50~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM03',timerange='23:16:50~24:10:00',flagbackup=False)<br />
</source><br />
<br />
* '''Outliers Visible After Calibration'''<br />
<br />
<figure id="amp_vs_uvdist_outliers.png"><br />
[[File:amp_vs_uvdist_outliers.png|200px|thumb|right|<caption> Amplitude vs. u-v distance ''after'' calibration. Note the outlying data. We track these down using the select (box with green "+") and locate (magnifying glass) features inside plotms and identify several problematic baselines across our data. ''Note that you cannot make this plot at this point in the guide, these pathologies become evident after calibration, requiring an iterative approach to reduction.''</caption>]]<br />
</figure><br />
<br />
Often issues with the data may become evident after calibration (i.e., after the next few steps that we apply). These data can appear as outliers in diagnostic plots for the calibrated data or even show up in the imaging stages. Once these are identified, best practice is to apply this new flagging then redo the calibration (if the issue is very minor, then re-calibrating may not be necessary).<br />
<br />
<source lang="python"><br />
# In CASA<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='21:18:00~21:22:15', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV01&DV04', flagbackup=False)<br />
</source><br />
<br />
Now that we've applied our flagging, back up the flags as version "User" using {{flagmanager}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis=asdm+'.wvrtsys.ms',mode='save',versionname ='User')<br />
</source><br />
<br />
Applying this flagging will remove the most egregious pathologies from the data. We are now ready to calibrate the data.<br />
<br />
==Bandpass Calibration==<br />
<br />
We begin by calibrating the phase and amplitude response of each antenna as a function of frequency, called "bandpass calibration." We have already seen that the data contain smooth but systematic variations in both phase and amplitude as a function of frequency. We can see this again in a more compact form by plotting phase as a function of frequency for all baselines associated with each antenna (<xr id="plotms_phase_vs_freq_example.png"/>).<br />
<br />
<figure id="plotms_phase_vs_freq_example.png"><br />
[[File:plotms_phase_vs_freq_example_6.1.png|200px|thumb|right|<caption> Phase vs. frequency for the bandpass calibrator, 3c279 in the first data set. We plot all baselines with DV02, averaged over time, and show only the 'XX' correlation.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='freq', yaxis='phase', <br />
selectdata=True, field='3c279', correlation='XX',<br />
avgtime='1e8', avgscan=True, antenna='*&*',<br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. frequency for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
Each plot shows phase as a function of frequency for all baselines with one antenna for 3c279. We plot only the 'XX' correlation, colorizing by baseline. With '''iteraxis''' set to antenna the green arrows at the bottom of {{plotms}} will cycle through antennas. By using '''avgscan''' and a large '''avgtime''' we average all scans and integrations. <br />
<br />
The phase (and amplitude) also varies as a function of time, as we saw before. Here are the similar plots for phase vs. time (see <xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb-phasecont.png"><br />
[[File:Uid_A002_X1ff7b0_Xb-phasecont_6.1.png|200px|thumb|right|<caption> Phase vs. time for the bandpass calibrator, 3c279. Averaged over channel. Only baselines with antenna DV02, and corr='XX'</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='phase', <br />
selectdata=True, field='3c279', <br />
spw='0:1200~1299', antenna='*&*',correlation='XX',<br />
avgchannel='100', avgscan=True, <br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. time for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
<xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/> shows that the phase varies with time. We need to take this temporal variation into account when we solve for the frequency variations. Therefore we carry out the bandpass calibration in two steps. First, we use {{gaincal}} to solve for the variation of phase as a function of time for 3c279 on very short timescales. We set {{gaincal}} to derive a separate phase solution for each antenna every integration by setting '''solint''' to 'int'. We solve, averaging together only a small fraction of the total bandpass (channels 1100-1300) to avoid the effects of the phase vs. frequency behavior. We will then apply this solution to remove time-dependent behavior when we solve for the frequency response of the antennas with {{bandpass}}.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
An integration is the smallest time quantum of observation in the data, usually a few seconds. <br />
You can check the integration length for each scan in listobs. <br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
for asdm in basename_all:<br />
print ("Running a short solution interval phase calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bpphase.gcal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
selectdata=True,field = '3c279',spw = '0:1100~1300',<br />
caltable = asdm+'.bpphase.gcal',<br />
solint = 'int',refant = 'DV11',calmode='p')<br />
</source><br />
<br />
Now we use {{bandpass}} to solve for the frequency response of each antenna. To do this, we average all data in time by setting '''solint''' to 'inf' (that is, 'infinite'). We allow combination across scans and the different field IDs found for 3c279 by setting '''combine''' to "scan,field". We apply the phase vs. time calibration that we just derived on-the-fly using the parameter "gaintable".<br />
<br />
<source lang="python"><br />
for asdm in basename_all:<br />
print ("Running a bandpass calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bandpass.bcal')<br />
bandpass(vis = asdm+'.wvrtsys.ms',<br />
field = '3c279',<br />
gaintable = asdm+'.bpphase.gcal',<br />
caltable = asdm+'.bandpass.bcal',<br />
bandtype='B',<br />
solint = 'inf',combine = 'scan,field', solnorm=True,refant = 'DV11',<br />
minblperant=3,minsnr=2,fillgaps=62)<br />
</source><br />
<br />
in these calls:<br />
<br />
*'''caltable''' specifies the output calibration table<br />
*'''gaintable''' specifies any calibration tables to be applied "on the fly" to the data before solving.<br />
*'''solint''' sets the time interval for which solutions are derived for each antenna.<br />
*'''refant''' set the reference antenna, here DV11, which is defined to have zero correction by construction.<br />
*'''calmode''' 'p' sets {{gaincal}} to calibrate the phase only, other options are 'a'mplitude or 'ap' - amplitude and phase.<br />
*'''minblperant''' sets the minimum baselines required per antenna for a successful solution.<br />
*'''minsnr''' sets the minimum signal-to-noise ratio required for a successful solution.<br />
*'''bandtype''' here 'B' tells {{bandpass}} to solve for the phase and frequency response of each antenna in each channel, averaging data in time across the solution interval.<br />
*'''fillgaps''' tells {{bandpass}} to interpolate across channel gaps 1 channel wide.<br />
*'''solnorm''' tells {{bandpass}} to normalize the bandpass amplitude and phase corrections to have magnitude unity. The absolute scale of the calibration will come from our later {{gaincal}} solutions.<br />
<br />
Do not worry about the message "Insufficient unflagged antennas" when running the {{bandpass}} task. This indicates that {{bandpass}} is failing on the flagged edge channels, which is expected.<br />
<br />
It is now a good idea to plot both sets of solutions to look for irregularities, especially:<br />
<br />
* discontinuities in the phase vs. time solution<br />
* rapid wrapping of phase in either phase vs. time or bandpass solution<br />
* large roll-off in the amplitude response near the band edge in the bandpass solution<br />
* large scatter in any solution.<br />
<br />
We loop through and using analysis utils, again generating .png files of each calibration. '''For what systems is this true?''' As the bandpass plots take a while you may want to go have a cup of coffee and inspect them using your favorite image viewer. Otherwise, switch the '''interactive''' parameter to True to see them in real time instead.<br />
<br />
<figure id="uid___A002_X1ff7b0_X1c8.bpphase.page1.png"><br />
[[File:uid___A002_X1ff7b0_X1c8.bpphase.page1_6.1.png|200px|thumb|right|<caption> Short interval phase vs. time solution carried out and applied during bandpass calibration, here for the first set of antennas for the first data set. This solution removes any systematic variations in phase vs. time.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1.CASA3.4.png"><br />
[[File:Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1_6.1.png|200px|thumb|right|<caption> Bandpass amplitude solution for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X1ff7b0_Xb.bcal_phase.page1.png"><br />
[[File:uid___A002_X1ff7b0_Xb.bcal_phase.page1.png|200px|thumb|right|<caption> Phase vs. frequency calibration from the bandpass calibration for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<br />
<!--<br />
Again this warning:<br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
--><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
os.system('rm -rf cal_plots/*bandpass*.png')<br />
for asdm in basename_all:<br />
plotbandpass(caltable=asdm+'.bandpass.bcal',<br />
field='',xaxis='freq',yaxis='both',<br />
figfile='cal_plots/'+asdm+'.bandpass.png',<br />
showatm=True,interactive=False,subplot=42)<br />
</source><br />
<br />
==Absolute Flux Calibration==<br />
<br />
The bandpass calibration will account for the phase and amplitude response of our antennas as a function of frequency. We now solve for the absolute flux scale of the data by referencing to Titan and in the next section we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
Before using Titan to set the flux, there is an important systematic to account for. When we looked at the integrated spectra of our targets above, remember that Titan showed a whopping spectral line, in fact the same CO(3-2) line that we wish to observe in the Antennae. We will set the flux of Titan (and thus all of our data) by referencing to a model in casa that does not account for this line. Therefore we need to flag the part of the Titan observations contaminated by the line before we calibrate (you can see the affected channel range in <xr id="Antennae-TitanLine.png"/>). We run the following additional flagging step:<br />
<br />
<figure id="Antennae-TitanLine.png"><br />
[[File:Antennae-TitanLine_6.1.png|200px|thumb|right|<caption> Uncalibrated amplitude vs. channel plot for the flux calibrator, Titan (uid___A002_X1ff7b0_Xb dataset). Averaged over time, corr='XX', and colorized by baseline.</caption>]]<br />
</figure><br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Flagging CO(3-2) in Titan for "+asdm)<br />
flagdata(vis=asdm+'.wvrtsys.ms',flagbackup=False, <br />
field='Titan', spw='0:1100~1700')<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis =asdm+'.wvrtsys.ms',mode = 'save',versionname = 'Calibration')<br />
</source><br />
<br />
Next, we will use the {{setjy}} task to read the predicted complex visibilities for Titan into the MODEL column of each data set.<br />
<br />
<source lang="python"><br />
# in CASA<br />
for asdm in basename_all:<br />
print ("Reading model for Titan into "+asdm)<br />
setjy(vis = asdm+'.wvrtsys.ms',field = 'Titan',<br />
usescratch=True,scalebychan=True,<br />
standard = 'Butler-JPL-Horizons 2012')<br />
</source><br />
<br />
{{setjy}} will output the flux of Titan to the CASA logger and it is worth recording this information. The flux of Titan at these frequencies is about 3.3 Jy. For example, for dataset uid___A002_X1ff7b0_Xb.wvrtsys.ms:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Titan: spw0 Flux:[I=3.2637,Q=0.0,U=0.0,V=0.0] +/- [I=0.0,Q=0.0,U=0.0,V=0.0] Jy @ 344.85GHz<br />
</pre><br />
<br />
Now we are going to take a look at the Titan model for one dataset:<br />
<br />
<source lang="python"><br />
# in CASA<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
</source><br />
<br />
<figure id="2012_titan_model_5.1.png">[[File:2012_titan_model_6.1.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2012'.</caption>]]</figure><br />
<figure id="2010_titan_model.png">[[File:2010_titan_model.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2010'.</caption>]]</figure><br />
<br />
<br/><br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
The setjy invocation made in this section uses the flux density standard '''standard='Butler-JPL-Horizons 2012' '''. Previous versions of this guide used an older flux density standard '''standard='Butler-JPL-Horizons 2010' '''. <xr id="2012_titan_model_5.1.png"/> and <xr id="2010_titan_model.png"/> show the differences in the Titan models produced using these two standards. <br />
</div><br />
<br />
==Gain (Phase and Amplitude) Calibration==<br />
<br />
With the flux now properly scaled, we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
We begin by running a short-solution interval {{gaincal}} to solve for phase variation on short timescales during observations of our two calibrators, with '''solint''' set to "int". By applying this on-the-fly, we can remove any decorrelation in the data due to phase scatter when we solve for the amplitude calibration. However, there is no benefit to using this short-timescale solution to calibrate the source because we only have information on the gain during calibrator visits (though see the Imaging portion of this guide). Instead we will solve for the gains to apply to the source using a longer '''solint''' in just a moment.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out short timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.intphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.intphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='int',minsnr=2.0, minblperant=4)<br />
</source><br />
<br />
Now we derive the longer timescale phase calibration table using '''solint''' set to "inf", but not allowing scan combination. This calibration has higher signal to noise due to combining more data, and for the purposes of correcting the source, it is just as precise as the short timescale solution.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out longer timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.scanphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.scanphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='inf',minsnr=2.0,minblperant=4)<br />
</source><br />
<br />
Now we apply the short-timescale phase solution and carry out a scan length ('''solint''' set to "inf") calibration of the data using '''calmode''' of 'ap'.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Solving for longer (scan) interval amplitude solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.amp.cal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
gaintable =[asdm+'.bandpass.bcal',asdm+'.intphase.gcal'],<br />
caltable = asdm+'.amp.cal',<br />
calmode='ap',<br />
field = 'Titan,3c279',<br />
spw='0:40~3800',<br />
refant = 'DV11',solint = 'inf', minblperant=4)<br />
</source><br />
<br />
This "amp.cal" solution gives us the amplitude variations as a function of time, but they are not yet pinned to a realistic scale except in the case of Titan, where we have solved using the model input by {{setjy}}. We will set the flux of our secondary calibrator 3c279 with reference to Titan using {{fluxscale}}.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Scaling amplitude calibration to match Titan for "+asdm)<br />
os.system('rm -rf '+asdm+'.flux.cal')<br />
fluxscale(vis = asdm+'.wvrtsys.ms',<br />
caltable = asdm+'.amp.cal',<br />
fluxtable = asdm+'.flux.cal',<br />
reference = 'Titan',<br />
transfer = '3c279')<br />
</source><br />
<br />
This new correctly-scaled flux table ".flux.cal" replaces the previous ".amp.cal" table as the correct amplitude calibration table to apply to the data, i.e., the ".flux.cal" contains both the time variability of the amplitude solved for in ".amp.cal" and the correct flux scaling set with {{fluxscale}}.<br />
<br />
Fluxscale will output the derived flux for 3c279 to the CASA logger. This information is worth noting. We find that the flux of 3c279 is 10.79 Jy, by averaging the fluxes obtained from the ten available datasets. If we check this value against reported flux measurements in the SMA calibrator list [http://sma1.sma.hawaii.edu/callist/callist.html], we find that a flux of 10.79 Jy agrees within a few per cent of a linear interpolation between the two 0.85 mm measurements closest in time to the ALMA observations: (23 May 2011, SMA 11.644 ± 0.583; 01 July 2011, 9.748 ± 0.488).<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used the older, Butler-JPL-Horizons 2010, flux density standard when you ran {{setjy}} earlier in this tutorial, the derived flux values for 3c279 will be slightly lower. The flux of 3c279, when averaged over all 10 measurement sets, will be 10.41 Jy.<br />
</div><br />
<br />
Now we plot the final phase and amplitude calibration tables for each data set. A well-behaved calibration table will show smooth variations as a function of time. Sudden jumps or wild variations among the antenna amplitude gains should prompt further investigation and possibly additional flagging.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting solutions for "+asdm)<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis='antenna',antenna='0~7',plotrange=[0,0,-180,180],<br />
gridrows=4,gridcols=1,showgui=False,<br />
plotfile=asdm+'.scanphase.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis = 'antenna', antenna='8~15', plotrange=[0,0,-180,180],<br />
showgui=False, gridrows=4, gridcols=1, <br />
plotfile=asdm+'.scanphase.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='0~7', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='8~15', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
<br />
</source><br />
<br />
==Apply the Calibrations and Inspect ==<br />
Now we will use {{applycal}} to apply the bandpass, phase, and amplitude calibration tables that we generated in the previous sections to the data. We apply the solutions separately to the bandpass and secondary ("phase") calibrator 3c279, the flux calibrator Titan, and the target source. In most data sets, the bandpass and secondary calibrator will not be the same and this step would include one additional {{applycal}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
for asdm in basename_north: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='NGC*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_south: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Ant*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
</source><br />
<br />
Here:<br />
* '''vis''' and '''field''' specify the measurement set and field to calibrate.<br />
* '''gaintable''' specifies the tables to apply to the data. There may be several tables applied all at once, here we apply the bandpass, phase, and flux calibrations.<br />
* '''interp''' specifies the type of interpolation used to match calibration tables to the data. If there are several gaintables then interp may be either a single value (e.g., "linear" or "nearest") or a list of values with size equal to the list of gaintables. In the case where interp is a list, applycal will match each element to the corresponding gaintable (e.g., first gaintable with first interp parameter).<br />
* '''gainfield''' specifies field from which to draw the calibration. As with interp, this can be a list of size matched to gaintable, so that the first element of gainfield will be the field used for the first table. For example, in the above commands the bandpass calibration (the first table) will always be applied from '3c279' (the first gainfield).<br />
* '''calwt''' indicates that the weights, which were derived from the Tsys measurements, should also be calibrated. Note that '''calwt''' is True by default.<br />
<br />
Once calibrations are applied, it is important to go back and inspect the calibrated data. New problematic antennas or baselines may be visible after calibration. Repeat the steps above, focusing on the CORRECTED data column. Bear in mind that for any point source calibrators we now expect to find phase scattering around zero and to find flat amplitudes as a function of u-v distance. Look for outliers and other signatures of problematic data. As a general rule, you will want to incorporate these data into your overall flagging script then rerun the whole calibration process, so that reduction is iterative. If the data only represent a minor problem, however, it may not be terribly harmful to flag them after the fact so that they do not interfere with imaging but trust that the calibrations are mostly unaffected.<br />
<br />
As an example of this inspection, we cycle through the corrected amplitudes and phases of 3c279 and Titan as a function u-v distance, to check that the phases are close to zero and the amplitudes are constant. <br />
<br />
<figure id="xb-checkcal-pha-cha.png"><br />
[[File:xb-checkcal-pha-cha.png|200px|thumb|right|<caption> Calibrated phase vs. channel plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<figure id="xb-checkcal-amp-time.png"><br />
[[File:xb-checkcal-amp-time.png|200px|thumb|right|<caption> Calibrated amplitude vs. time plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='phase',<br />
ydatacolumn='corrected', field='3c279',<br />
avgchannel='3840', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
In <xr id="xb-checkcal-pha-cha.png"/> and <xr id="xb-checkcal-amp-time.png"/> we plot phase vs. channel and amp vs. time for 3c279 for the uid___A002_X1ff7b0_Xb dataset. <br />
<br />
Finally we can use {{plotms}} to examine the corrected amplitude and phase of Antennae galaxies as a function of time and uv-distance (plots not shown):<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
for asdm in basename_north:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
avgtime='1e8', avgscan=True, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
for asdm in basename_south:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
avgtime='1e8', avgscan=True,avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
</source><br />
<br />
==Split and Concatenate Data for Northern and Southern Mosaics==<br />
The individual data sets are now calibrated. We can safely split out the calibrated data for our science target and drop the calibrators. As we do so, we will smooth the data in frequency, averaging together groups of 23 channels by setting '''width=23''' in {{split}}. The new data will have a channel width corresponding to about ~10 km/s, very similar to the SMA data being verified. The factor of >20 drop in data volume will also make the imaging steps ''much'' more tractable.<br />
<br />
Note that you will see a warning that the last output channel in the new spw 0 will be dropped, as it has less than 23 channels over which to average:<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO MSTransformDataHandler The last output channel of spw 0 has only 22 input channels.<br />
WARN MSTransformManager Not enough input channels to populate output channel n# 166 from SPW 0.<br />
WARN MSTransformManager The channel will be dropped in order to have an uniform grid.<br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_north:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'NGC*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
<br />
for asdm in basename_south:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'Ant*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
</source><br />
<br />
For convenience we concatenate all data for the Northern Mosaic into a single big MS and place all data for the Southern Mosaic into another file. To do this, we construct a list that holds the names of all the Southern Mosaic MS files and another that holds the name of all the Northern Mosaic MS files then feed these into the {{concat}} task. <br />
<br />
Before we do this, we'll take a brief aside to remove Pointing information from the calibrated data. Normally, the pointing information would apply important corrections to be used while imaging the data. However, some aspects of this are still under development and the pointing information in these data interacts poorly with CASA. We will remove the pointing information using the CASA toolkit Table tool (tb). ''This kind of operation is dangerous and should not be a regular feature of your CASA reduction.''<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Manually removing pointing table from "+asdm+".cal.ms ... Please be careful!")<br />
tb.open(asdm+'.cal.ms/POINTING',nomodify=False)<br />
a = tb.rownumbers()<br />
tb.removerows(a)<br />
tb.close()<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
cal_south_vis = [vis+'.cal.ms' for vis in basename_south]<br />
cal_north_vis = [vis+'.cal.ms' for vis in basename_north]<br />
<br />
os.system('rm -rf Antennae_South.cal.ms')<br />
concat(vis=cal_south_vis, concatvis='Antennae_South.cal.ms', timesort=True)<br />
<br />
os.system('rm -rf Antennae_North.cal.ms')<br />
concat(vis=cal_north_vis, concatvis='Antennae_North.cal.ms', timesort=True)<br />
</source><br />
<br />
The syntax used to construct the 'cal_south_vis' variable loops over basename_south and makes a list after adding '.cal.ms' to each member. To see the list 'print (cal_south_vis)'.<br />
<br />
==Continue on to Imaging of the Science Target==<br />
Now you can continue on to the [http://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_6.1 imaging guide].<br />
{{Checked 6.1}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Calibration_6.1&diff=29405AntennaeBand7 Calibration 6.12020-10-01T18:38:22Z<p>Dkim: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide is written for CASA 6.1 and uses Python 3. The same functionality is implemented in Python 2 using CASA 5.7 at [[AntennaeBand7 Calibration 5.7]]'''<br />
<br />
*'''This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are provided at [[AntennaeBand7]]<br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see: [[AntennaeBand7_Imaging 6.1]]'''.<br />
<br />
==Overview==<br />
<br />
This part of the Antennae Band 7 CASA guide will step through the calibration of the visibility data. We will begin by flagging (marking as bad) data known to be useless before any inspection; for example, data where one telescope blocks the line of sight of another. We will then apply telescope-generated calibration tables to partially correct for atmospheric effects. After inspecting the data, we will flag some additional data that exhibit pathologies. Using observations of the calibrators Titan and 3c279, it will be shown how to derive the phase and amplitude response of individual antennas as a function of time and frequency ("phase", "amplitude", and "bandpass" calibrations). We will apply these solutions to the data and then extract the calibrated source data into a file appropriate for imaging in the [[AntennaeBand7_Imaging | Antennae Band 7 imaging guide]].<br />
<br />
The general procedure in this guide follows the other ALMA CASA guides: [[NGC3256Band3]] and [[TWHydraBand7]].<br />
<br />
==Unpack the Data==<br />
<br />
This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]. <br />
<br />
Once you have downloaded the data, unpack the file in a terminal outside CASA using<br />
<br />
<source lang="bash"><br />
<br />
tar -xvzf Antennae_Band7_UnCalibratedMSandTablesForReduction.tgz<br />
<br />
</source><br />
<br />
then change directory to the new directory <br />
<br />
<source lang="bash"><br />
<br />
cd Antennae_Band7_UnCalibratedMSandTablesForReduction<br />
<br />
</source><br />
<br />
You may wish to type<br />
<br />
<source lang="bash"><br />
<br />
ls<br />
<br />
</source><br />
<br />
to look at the files present. You should see a set of files with extension ".ms". These are CASA measurement set (MS) files. The data have already been converted to MS format from the native ALMA format using the CASA task {{importasdm}}. In addition to the data, we provide you with calibration tables containing system temperature (Tsys), water vapor radiometer (WVR), and antenna position information. For Early Science, these tables will either be pre-applied or supplied with the data.<br />
<br />
To begin, start CASA by typing<br />
<br />
<source lang="bash"><br />
<br />
casa<br />
<br />
</source><br />
<br />
Be sure that you are using the version indicated at the top of this page.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 6.1. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casalith<br />
version = casalith.version_string()<br />
print("You are using {}".format(version))<br />
if (version < '6.1'):<br />
print ("YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE.")<br />
print ("PLEASE UPDATE IT BEFORE PROCEEDING.")<br />
else:<br />
print ("Your version of CASA is appropriate for this guide.")<br />
</source><br />
<br />
==Initial Inspection==<br />
<br />
First we will take stock of what we have. If you have not already done so, begin by reviewing the description of the observations here: [[AntennaeBand7]]. The 10 data sets each target either the Northern or the Southern Mosaic, as follows:<br />
<br />
Northern Mosaic:<br />
*uid___A002_X1ff7b0_Xb.ms<br />
*uid___A002_X207fe4_X3a.ms<br />
*uid___A002_X207fe4_X3b9.ms<br />
*uid___A002_X2181fb_X49.ms<br />
<br />
Southern Mosaic:<br />
*uid___A002_X1ff7b0_X1c8.ms<br />
*uid___A002_X207fe4_X1f7.ms<br />
*uid___A002_X207fe4_X4d7.ms<br />
*uid___A002_X215db8_X18.ms<br />
*uid___A002_X215db8_X1d5.ms<br />
*uid___A002_X215db8_X392.ms<br />
<br />
The first step is to get basic information about the data: targets observed, time range, spectral setup, and so on. We do this using the task {{listobs}}, which will output a detailed summary of each dataset. Enter the following commands into CASA:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Define a python list holding the names of all of our data sets<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
# Initialize user-input string. (for Python testing)<br />
dummy_string = ''<br />
<br />
# Loop over each element in the list and create summary file using listobs<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.listobs.txt')<br />
listobs(vis=asdm+'.ms', listfile=asdm+'.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note that after cutting and pasting a 'for' loop like this you often have to press return twice to execute. You may also want to take care to paste a line at a time if you are having trouble copy and pasting. Even better, you can use "cpaste" to paste blocks of code. To do so type "cpaste" at the CASA prompt, paste your commands, and then type "--" and hit return on the final (otherwise empty) line. This should look something like this:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
CASA <8>: cpaste<br />
Pasting code; enter '--' alone on the line to stop.<br />
:basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
: "uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
: "uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
: "uid___A002_X215db8_X392"]<br />
:<br />
:for asdm in basename_all:<br />
: print (asdm)<br />
:--<br />
uid___A002_X1ff7b0_Xb<br />
uid___A002_X207fe4_X3a<br />
uid___A002_X207fe4_X3b9<br />
uid___A002_X2181fb_X49<br />
uid___A002_X1ff7b0_X1c8<br />
uid___A002_X207fe4_X1f7<br />
uid___A002_X207fe4_X4d7<br />
uid___A002_X215db8_X18<br />
uid___A002_X215db8_X1d5<br />
uid___A002_X215db8_X392<br />
<br />
CASA <9>: <br />
<br />
</pre><br />
<br />
cpaste should be ''much'' more robust than copying-and-pasting directly into the shell but if you have trouble, just carefully paste one line at a time directly into CASA and hit return until the desired command executes.<br />
<br />
These commands define a python list called "basename_all", which contains the name of all 10 MS files. The "for" loop executes for each element in basename_all, calling listobs and directing the output to a file called, e.g., "uid___A002_X1ff7b0_Xb.listobs.txt" for the first measurement set. You can browse through the listobs output as you would normally look at a text file (use emacs, vi, or another editor). You can also send the output to the terminal from inside of CASA. To do so type:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
or<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('more uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
CASA knows a few basic shell commands like 'cat', 'ls', and 'rm' but for more complex commands you will need to run them inside 'os.system("command")'. For more information see http://casa.nrao.edu/ .<br />
<br />
Here is an example of the (abridged) output from {{listobs}} for the first dataset in the list, uid___A002_X1ff7b0_Xb.ms, which targets the Northern Mosaic. You would see this if you had specified '''verbose''' to be False in the listobs call:<br />
<br />
<pre style="background-color: #fffacd;"><br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_Xb.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA(11 antennas)<br />
Data records: 181357 Total integration time = 4931.71 seconds<br />
Observed from 28-May-2011/01:25:27.6 to 28-May-2011/02:47:39.3 (UTC)<br />
<br />
Fields: 26<br />
ID Code Name RA Decl Epoch SrcId nRows <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 39116 <br />
1 none Titan 12:42:43.94813 -01.43.38.3190 J2000 1 10626 <br />
2 none NGC4038 - Antennae *12:01:53.17008 -18.52.37.9200 J2000 2 4818 <br />
3 none NGC4038 - Antennae *12:01:51.90301 -18.51.49.9437 J2000 2 6435 <br />
4 none NGC4038 - Antennae *12:01:52.43086 -18.51.49.9437 J2000 2 6424 <br />
5 none NGC4038 - Antennae *12:01:52.95871 -18.51.49.9437 J2000 2 5478 <br />
6 none NGC4038 - Antennae *12:01:53.48656 -18.51.49.9436 J2000 2 6435 <br />
7 none NGC4038 - Antennae *12:01:54.01441 -18.51.49.9436 J2000 2 6446 <br />
8 none NGC4038 - Antennae *12:01:52.16693 -18.51.56.4319 J2000 2 6435 <br />
9 none NGC4038 - Antennae *12:01:52.69478 -18.51.56.4318 J2000 2 6424 <br />
10 none NGC4038 - Antennae *12:01:53.22263 -18.51.56.4318 J2000 2 6446 <br />
11 none NGC4038 - Antennae *12:01:53.75049 -18.51.56.4318 J2000 2 6446 <br />
12 none NGC4038 - Antennae *12:01:51.90301 -18.52.02.9201 J2000 2 6435 <br />
13 none NGC4038 - Antennae *12:01:52.43086 -18.52.02.9200 J2000 2 6424 <br />
14 none NGC4038 - Antennae *12:01:52.95871 -18.52.02.9200 J2000 2 4818 <br />
15 none NGC4038 - Antennae *12:01:53.48656 -18.52.02.9200 J2000 2 4829 <br />
16 none NGC4038 - Antennae *12:01:54.01441 -18.52.02.9199 J2000 2 4829 <br />
17 none NGC4038 - Antennae *12:01:52.16694 -18.52.09.4082 J2000 2 4829 <br />
18 none NGC4038 - Antennae *12:01:52.69479 -18.52.09.4082 J2000 2 4829 <br />
19 none NGC4038 - Antennae *12:01:53.22264 -18.52.09.4082 J2000 2 3872 <br />
20 none NGC4038 - Antennae *12:01:53.75049 -18.52.09.4081 J2000 2 4829 <br />
21 none NGC4038 - Antennae *12:01:51.90301 -18.52.15.8964 J2000 2 4829 <br />
22 none NGC4038 - Antennae *12:01:52.43087 -18.52.15.8964 J2000 2 4829 <br />
23 none NGC4038 - Antennae *12:01:52.95872 -18.52.15.8963 J2000 2 4818 <br />
24 none NGC4038 - Antennae *12:01:53.48657 -18.52.15.8963 J2000 2 4818 <br />
25 none NGC4038 - Antennae *12:01:54.01442 -18.52.15.8963 J2000 2 4840 <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 354971.074 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 354916.143 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11 'name'='station' <br />
ID= 0-3: 'DV02'='A015', 'DV04'='J505', 'DV06'='T704', 'DV07'='A004', <br />
ID= 4-7: 'DV08'='A072', 'DV09'='A008', 'DV10'='A009', 'DV11'='A016', <br />
ID= 8-10: 'PM01'='T702', 'PM02'='A017', 'PM03'='J504'<br />
================================================================================<br />
<br />
</pre><br />
<br />
And here is an extract from the full '''verbose''' {{listobs}} for uid___A002_X1ff7b0_X1c8.ms, which targets the Southern Mosaic (note that we have snipped out the record of individual scans):<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_X1c8.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA<br />
Data records: 175615 Total integration time = 4927.1 seconds<br />
Observed from 28-May-2011/02:50:18.2 to 28-May-2011/04:12:25.3 (UTC)<br />
<br />
<snip><br />
<br />
Fields: 33<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 12232 <br />
1 none Titan 12:42:44.82765 -01.43.41.4224 J2000 1 10615 <br />
2 none 3c279 12:56:11.16600 -05.47.21.5250 J2000 2 27764 <br />
3 none Antennae 12:01:53.17008 -18.52.37.9200 J2000 3 4829 <br />
4 none Antennae 12:01:52.18699 -18.53.30.3952 J2000 3 3883 <br />
5 none Antennae 12:01:52.64413 -18.53.26.6494 J2000 3 3883 <br />
6 none Antennae 12:01:53.10127 -18.53.22.9035 J2000 3 3872 <br />
7 none Antennae 12:01:53.55841 -18.53.19.1577 J2000 3 4818 <br />
8 none Antennae 12:01:54.01554 -18.53.15.4119 J2000 3 4829 <br />
9 none Antennae 12:01:54.47268 -18.53.11.6661 J2000 3 4829 <br />
10 none Antennae 12:01:54.92982 -18.53.07.9203 J2000 3 3872 <br />
11 none Antennae 12:01:55.38696 -18.53.04.1744 J2000 3 3883 <br />
12 none Antennae 12:01:55.84409 -18.53.00.4286 J2000 3 4840 <br />
13 none Antennae 12:01:56.30123 -18.52.56.6828 J2000 3 4818 <br />
14 none Antennae 12:01:52.18700 -18.53.22.9033 J2000 3 4829 <br />
15 none Antennae 12:01:52.64414 -18.53.19.1575 J2000 3 4818 <br />
16 none Antennae 12:01:53.10128 -18.53.15.4116 J2000 3 4818 <br />
17 none Antennae 12:01:53.55842 -18.53.11.6658 J2000 3 4840 <br />
18 none Antennae 12:01:54.01555 -18.53.07.9200 J2000 3 3872 <br />
19 none Antennae 12:01:54.47269 -18.53.04.1742 J2000 3 4829 <br />
20 none Antennae 12:01:54.92983 -18.53.00.4284 J2000 3 4829 <br />
21 none Antennae 12:01:55.38697 -18.52.56.6825 J2000 3 4829 <br />
22 none Antennae 12:01:55.84410 -18.52.52.9367 J2000 3 4829 <br />
23 none Antennae 12:01:51.72988 -18.53.19.1572 J2000 3 4818 <br />
24 none Antennae 12:01:52.18702 -18.53.15.4114 J2000 3 4829 <br />
25 none Antennae 12:01:52.64415 -18.53.11.6656 J2000 3 4829 <br />
26 none Antennae 12:01:53.10129 -18.53.07.9197 J2000 3 2266 <br />
27 none Antennae 12:01:53.55843 -18.53.04.1739 J2000 3 2266 <br />
28 none Antennae 12:01:54.01557 -18.53.00.4281 J2000 3 3212 <br />
29 none Antennae 12:01:54.47270 -18.52.56.6823 J2000 3 3234 <br />
30 none Antennae 12:01:54.92984 -18.52.52.9365 J2000 3 3212 <br />
31 none Antennae 12:01:55.38698 -18.52.49.1906 J2000 3 2266 <br />
32 none Antennae 12:01:55.84411 -18.52.45.4448 J2000 3 3223 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 356845.586 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 356900.518 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11:<br />
ID Name Station Diam. Long. Lat. <br />
0 DV02 A015 12.0 m -067.45.15.3 -22.53.26.0 <br />
1 DV04 J505 12.0 m -067.45.18.0 -22.53.22.8 <br />
2 DV06 T704 12.0 m -067.45.16.2 -22.53.22.1 <br />
3 DV07 A004 12.0 m -067.45.15.9 -22.53.28.0 <br />
4 DV08 A072 12.0 m -067.45.12.6 -22.53.24.0 <br />
5 DV09 A008 12.0 m -067.45.15.4 -22.53.26.8 <br />
6 DV10 A009 12.0 m -067.45.16.1 -22.53.26.1 <br />
7 DV11 A016 12.0 m -067.45.16.4 -22.53.25.1 <br />
8 PM01 T702 12.0 m -067.45.18.6 -22.53.24.1 <br />
9 PM02 A017 12.0 m -067.45.15.9 -22.53.26.8 <br />
10 PM03 J504 12.0 m -067.45.17.0 -22.53.23.0 <br />
</pre><br />
<br />
This output shows that three sources were observed in each data set: 3c279, Titan, and the Antennae.<br />
<br />
* The '''Antennae''' are our science target. Note that the source name changes between the Northern Mosaic, where it is "NGC4038 - Antennae", and the Southern Mosaic, where it is just "Antennae". Also note that the source corresponds to a number of individual fields (see the Field ID column). These are the individual mosaic pointings. There are 23 for the Northern Mosaic and 29 for the Southern Mosaic.<br />
* '''Titan''' is observed once and will be used to set the absolute flux scale of the data.<br />
* '''3c279''' plays two roles: it will serve as our bandpass calibrator, to characterize the frequency response of the antennas, and because it is fairly close on the sky to the Antennae (18.6 degrees away) it will serve as our secondary calibrator (also referred to as the "phase calibrator" or "gain calibrator"), to track changes in the phase and amplitude response of the telescopes over time. Observations of 3c279 are interleaved with observations of the Antennae.<br />
<br />
The output also shows that the data contain many spectral windows. Using the labeling scheme in the listobs above these are:<br />
<br />
* '''spw 0''' targets ~185 GHz and holds water vapor radiometer data<br />
* '''spw 1''' and '''spw 3''' hold our science data. These are "Frequency Domain Mode" (FDM) data with small (0.49 MHz) channel width and wide (1.875 GHz) total bandwidth. As a result these have a lot of channels (3840). spw 1 holds the lower sideband (LSB) data and includes the CO(3-2) line. We will focus on these data. For the CO(3-2) line the channel width corresponds to 0.426 km/s and the bandwidth of spw 1 to 1634 km/s.<br />
* '''spw 2''' and '''spw 4''' hold frequency-averaged versions of spw 1 and 3 ("Channel 0" for those familiar with AIPS). These are used for some quick automated inspection. We will not use them here but we will carry out an equivalent inspection using spw 1.<br />
* '''spw 5''' and '''spw 7''' hold lower a resolution processing ("Time Domain Mode", TDM) of the data from the same part of the spectrum (baseband) as spws 1 and 3. These data have only 128 channels across 2 GHz bandwidth and so have a much coarser channel spacing than the FDM data. These were used to generate the calibration tables that we include in the tarball but will not otherwise appear in this guide.<br />
<br />
The final column of the listobs output in the logger (not shown above) gives the scan intent. Later we will use this information to flag the pointing scans and the hot and ambient load calibration scans.<br />
<br />
We'll now have a look at the configuration of the antennas used to take the data using the task {{plotants}} (<xr id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"><br />
[[File:Uid_A002_X1ff7b0_Xb.ANT_6.1.png|200px|thumb|right|<caption> Position of antennas in dataset uid_A002_X1ff7b0_Xb obtained using task plotants. </caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Antenna configuration for : "+asdm)<br />
plotants(vis=asdm+'.ms', figfile=asdm+'.plotants.png')<br />
clearstat()<br />
dummy_string = input("Hit <Enter> to see the antenna configuration for the next data set.")<br />
</source> <br />
<br />
This will loop through all 10 data sets, show you the antenna position for each, and save that as a file named, e.g., "uid___A002_X1ff7b0_Xb.plotants.png" for the first data set. The "input" command asks CASA to wait for your input before proceeding. If you would prefer to just browse the .png files after the fact you can remove this. Notice that the antenna setup changes, but only slightly, over the course of the 10 data sets.<br />
<br />
==How to Deal With 10 Measurement Sets==<br />
<br />
It should already be clear from the initial inspection that dealing with 10 data sets at the same time can be a bit problematic. This is especially tricky in our case because the Antennae data contain two distinct sets of observations: the Northern and Southern Mosaics. The source name changes between these two scripts and there are different numbers of fields in the mosaic.<br />
<br />
''As a general rule one would reduce each individual observation separately or at the very least only group data observed in a uniform way and very close in time.'' <br />
<br />
Unfortunately, a CASA Guide stepping through the reduction for each of 10 data sets would quickly become unwieldy. Therefore we will use a few tricks to reduce the Antennae data in a kind of batch mode. You have already seen the first trick: we can define a python list holding the names of each data set and then loop over this list to execute the same command on each data set. For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print (asdm)<br />
</source><br />
<br />
You only need to define your list of MS files once per CASA session. Then "basename_all" will be a variable in the casapy shell. You can check if it exists by typing "print (basename_all)". In the interests of allowing you to easily exit and restart CASA and pick this guide up at any point we will redefine "basename_all" in each section of the guide. Feel free to skip this step if you've already defined it in your session.<br />
<br />
This page will step you through the reduction of the whole Antennae Band 7 SV data set using these 'for' loops. We will not be able to show every diagnostic plot but we give an example of each and the syntax to generate the rest. Also please be aware that even on a very fast machine this whole process can take a while, we are simply dealing with a lot of data.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
One potential "gotcha" is that the source name changes between the two data sets. Therefore at several points we will break apart our loop to iterate separately over the Northern and Southern Mosaics, where the source can be referred unambiguously. Another subtle point is that 3c279 appears with two distinct field IDs in the Southern Mosaic, but only one in the Northern Mosaic. We will largely avoid this by referring to the source by its name but if you tried to use field ID numbers and mingled the two data sets this could cause confusion.<br />
</pre><br />
<br />
==''A Priori'' Flagging==<br />
<br />
Even before we look in detail, we know that there are some data that we wish to exclude. We will start by flagging "shadowed" data where one antenna blocks the line of sight of another. We will also flag scans that were used to carry out pointing and atmospheric calibration, identified by their scan intent. Finally, we'll flag the autocorrelation data (the correlation of the signal from an antenna with itself) as we are only interested in cross-correlation data to make an interferometric image.<br />
<br />
Start by defining our list of MS files:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
You may want to reset the flagging if you have tried this step before and are starting over though this is not necessary on your first time through. Do so using {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Resetting flags for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='unflag', flagbackup=False)<br />
</source><br />
<br />
Then flag shadowed data using the command {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging shadowed data for "+asdm)<br />
flagdata(vis=asdm+'.ms',mode = 'shadow', flagbackup = False)<br />
</source><br />
<br />
In the {{flagdata}} task we choose:<br />
<br />
* '''vis''' = asdm+'.ms' : each measurement set<br />
* '''mode''' = 'shadow': flag shadowed data<br />
* '''flagbackup''' = False: Do not automatically back up the flag files. We will save all of the ''a priori'' flags together using {{flagmanager}} at the end of this subsection and save some space and time.<br />
<br />
The relevant calibration information has already been extracted from the pointing and atmospheric scans and we will not need them below. Now flag the pointing scans using {{flagdata}} in 'manualflag' mode and selecting on 'intent':<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging calibration scans for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='manual', intent='*POINTING*', flagbackup = False)<br />
</source><br />
<br />
Note that because the atmospheric calibration scans contain only TDM spectral windows, they will be removed automatically when we separate out the FDM data below.<br />
<br />
Now flag the autocorrelation data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging autocorrelation data for "+asdm)<br />
flagdata(vis=asdm+'.ms',autocorr=True,flagbackup=False)<br />
</source><br />
<br />
Finally store the current flags information using {{flagmanager}}: <br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Backing up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'save', versionname = 'Apriori')<br />
</source><br />
<br />
Where '''versionname''' is just the name we assign to the current flagging state in the data. We can now roll back the flags to match the current version, called 'Apriori', whenever we want. There is no reason to do this now, but the syntax would be:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Restoring up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'restore', versionname = 'Apriori')<br />
</source><br />
<br />
<br />
It would have been possible to set {{flagdata}} to '''flagbackup'''=True so that it stores the flags at each of the flagging step automatically, but this way it is a bit more efficient with regard to time and disk space. More important, lumping all the ''a priori'' flagging together gives us a natural point to roll back to if we get in trouble.<br />
<br />
<br />
The flagmanager task will also allow you to view the saved flagging versions,<br />
including those created by running flagdata with flagbackup=True.<br />
<br />
For example try <br />
<br />
<source lang="python"><br />
# In CASA<br />
flagmanager(vis='uid___A002_X2181fb_X49.ms', mode='list')<br />
</source><br />
<br />
The output in the logger should list the Apriori flagging that we have applied.<br />
It will also indicate versions associated with any flagdata command where you<br />
did not set flagbackup=False. Other tasks, for example applycal, will also create<br />
flag version tables.<br />
<br />
==Create and Apply Tsys, WVR, and Antenna Position Calibration Tables==<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
===Tsys===<br />
<br />
The Tsys calibration gives a first-order correction for the atmospheric opacity as a function of time and frequency and associates weights with each visibility that persists through imaging.<br />
<br />
Use gencal to create the Tsys calibration tables from the spectral windows with CALIBRATE_ATMOSPHERE intents in listobs (i.e. the TDM spectral windows with 128 channels), these are spectral windows 5 and 7.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#Removing existing Tsys information<br />
os.system('rm -rf *tdm.tsys')<br />
for asdm in basename_all:<br />
print ("Creating TDM Tsys Table for "+asdm)<br />
gencal(vis=asdm+'.ms',caltable=asdm+'.tdm.tsys',spw='5,7',caltype='tsys')<br />
</source><br />
<br />
Later in the applycal stage this TDM Tsys table will be interpolated to the FDM (3840 channels per spw) science spectral windows 1 and 3.<br />
<br />
Next we inspect the Tsys tables for the spectral window '''spw''' = 5 with the task {{plotms}}. In previous CASA versions, we used {{plotcal}} for this task, but most of '''plotcal''''s functionality is now included in {{plotms}}, and '''plotcal''' will be deprecated in a future CASA release. We want to check that Tsys data have reasonable values and identify any unexpected features as a function of either time or frequency. To get an idea of sensible Tsys under average atmospheric observations consult the ALMA sensitivity calculator, accessible from http://www.almascience.org (via the "Documents & Tools" link).<br />
<br />
We start by plotting the Tsys for all the antennas and polarizations (XX and YY) as a function of time for each. <!--Here and throughout we focus on spw 1, which contains CO(3-2): --><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Note that right now, plotms can't select individual channels when plotting caltables (as was possible with plotcal). In addition, when iteraxis is set, plotms appends the axes being iterated over to the output filename specified in plotfile; this can make for rather unwieldy filenames (particularly when iteraxis='antenna'!) but is useful for the ALMA pipeline. <br />
</pre><br />
<br />
<figure id="Xb.Tsys_vs_time.page1.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page1.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 8 antennas. Note the high y-axis values for DV04. The two different colors indicate the two polarizations (XX and YY).</caption>]]<br />
</figure><br />
<figure id="Xb.Tsys_vs_time.page2.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page2.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting Tsys vs. time for "+asdm)<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='0~7',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page1.png',overwrite=True)<br />
#dummy_string = input("First eight antennas for "+asdm+" . Hit <Enter> to continue.")<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='8~15',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page2.png',overwrite=True)<br />
#dummy_string = input("Remaining antennas for "+asdm+" . Hit <Enter> to continue.")<br />
</source><br />
<br />
This sequence loops over all of our files and plots Tsys as a function of time for channel 50 in spectral window 5. In the call to {{plotms}}:<br />
<br />
* '''gridrows'''=4 and '''gridcols'''=2 sets up a 4 x 2 panel grid. <br />
* '''iteraxis'''='antenna' tells {{plotms}} to make a separate plot for each antenna.<br />
* '''spw'''='5:50~50' selects spw '5' channel 50-50. This allows us to cleanly separate time variations from frequency variations. '''Note that this is a functionality in plotcal but not yet in {{plotms}}, and plotms is actually showing all channels from spw 5 at this time.'''<br />
<br />
Because 8 panels (2 panels for each antenna - LSB and USB) is not enough to show all antennas on one page, there are two {{plotms}} calls: one for the first 8 antennas ('''antenna'''='0~7'), and then for the remaining antennas ('''antenna'''='8~15').<br />
<br />
The 'input' commands will wait for you to hit Enter before issuing the next plot command. In the example above these are commented out (the leading "#" means that CASA will ignore them). If you would like to interactively cycle through the plots, uncomment them by removing the "#". Otherwise, the '''plotfile''' parameter directs the output to .png files for later inspection. The easiest way to look at the 20 plots produced here is to simply inspect the .png files using your favorite viewer. As noted above, here plotms is adding the antenna information to the filenames because we set '''iteraxis''' = 'antenna', so check your directory for the impressively long filenames to view them. <br />
<br />
The Tsys values in <xr id="Xb.Tsys_vs_time.page1.6.1.png"/> and <xr id="Xb.Tsys_vs_time.page2.6.1.png"/> look reliable, with typical values ~150 K except for some large values of Tsys at ~400 and 500 K for DV04. We will flag the data for that antenna later. <br />
<br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV02.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 4 antennas. Note the high y-axis values for DV04 and the mesospheric line near 343.2 GHz.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV08.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Next 4 antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"><br />
[[File:uid___A002_X215db8_X392.tdm.tsys.3c279.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid___A002_X215db8_X392. Note the pathological behavior for DV12.</caption>]]<br />
</figure><br />
<br />
We will also want to look at Tsys as a function of frequency. <br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
os.system('rm -rf cal_plots/Tsys_plots/'+asdm+'.tdm.tsys*')<br />
tsysfields=['3c279','Titan','*Antennae*']<br />
caltable=asdm+'.tdm.tsys'<br />
for field in tsysfields:<br />
plotbandpass(caltable=caltable,yaxis='amp',field=field,xaxis='freq',<br />
showatm=True,overlay='time',<br />
figfile='cal_plots/Tsys_plots/'+caltable+'.'+field,<br />
buildpdf=False,interactive=False,chanrange='8~120',subplot=42)<br />
</source><br />
<br />
You will see the following statement in the logger, but this is fine: <br />
<br />
<pre style="background-color: #fffacd;"><br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
</pre><br />
<br />
Now have a look at the Tsys vs. frequency plots or see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/>, <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"/>, and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/> for examples on the first data set. You can see the effect of a close pair of atmospheric ozone absorption lines at about 343.2 GHz that makes Tsys larger near that frequency in all antennas. Applying the Tsys calibration tables will minimize the contribution of these atmospheric lines. Again DV04 stands out with its very high Tsys. Although not present in the first data sets, Antenna DV12 exhibits periodic spikes in Tsys vs. frequency for one polarization (see <xr id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"/> for an example from a later data set). It may or may not be possible to calibrate that behavior out. We will make a note to look carefully at DV12 further on in the calibration process.<br />
<br />
===WVR===<br />
The WVR calibration uses observations of the wings of the 183 GHz atmospheric water line to correct for phase variations as a function of time. As noted in the tsys section, this run of gencal will append to existing WVR produced tables. To avoid this, preexisting wvrgcal data is removed. <br />
<source lang="python"><br />
#In CASA<br />
#Removing existing WVR information<br />
os.system('rm -rf *.wvrgcal')<br />
for asdm in basename_all:<br />
wvrgcal(vis=asdm+'.ms',caltable=asdm+'.wvrgcal',toffset=-1)<br />
</source><br />
<br />
===Antenna Positions===<br />
<br />
In general, the most appropriate antenna positions for the dataset will be determined and updated if needed during QA2. If the antenna positions need to be updated after QA2, we inform the PIs of the affected datasets and provide instructions on how to update the antenna positions. For the data in this guide, we do need to update the antenna positions. <br />
<br />
The antenna position table reflects refinements in the measured positions of the antennas from those stored in the data. {{gencal}} will now be used put antenna position data into each observation. Again, {{gencal}} will merely append to existing antenna position data, ruining any subsequent results. We start by removing any existing antenna position refinements, followed by defining the antenna names, then their refinements (both as arrays), finally running {{gencal}} to create the information CASA can refer to for antenna positions.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_Xb.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:21]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3a.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3b9.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X2181fb_X49.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV01,DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
-0.00004, 0.00026, 0.00019, #DV01-A137<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_X1c8.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X1f7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X4d7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X18.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X1d5.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X392.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
</source><br />
<br />
===Applycal===<br />
<br />
We are now ready to apply the Tsys and the WVR calibration tables to the data with {{applycal}}, which reads the specified gain calibration tables, applies them to the (raw) data column, and writes the calibrated results into the corrected column. Again, we loop through all the datasets. It is important to only apply Tsys and WVR corrections obtained close in time to the data being corrected, so in addition to looping over data sets we define the list of unique source names and loop over these. Then by setting '''gainfield''' and '''field''' to the same value we ensure that Tsys and WVR calibrations are only applied to the source for which they are measured. Because the source has a different name in the Northern Mosaic and the Southern Mosaic, we will carry out two loops. We will only correct '''spw''' 1 and 3, our science windows, because we will drop the other data in a moment.<br />
<br />
The applycal task now has much more flexibility for interpolating and applying calibrations derived in one spectral window to another, even if they do not share the same spectral shape (number of channels and channel width). This new functionality is used below to interpolate the TDM (128 channel) Tsys measurements to the FDM (3840 channel) spectral windows. This is controlled through the spectral window mapping parameter *spwmap*. Because this can be a bit confusing, we've written a "helper" function that will tell you what you should put for the Tsys calibration table part of spwmap. We only need to run it on one of the datasets because they are all the same in this regard<br />
<br />
<source lang="python"><br />
# In CASA<br />
from casarecipes.almahelpers import tsysspwmap<br />
tsysspwmap(vis='uid___A002_X207fe4_X3a.ms',tsystable='uid___A002_X207fe4_X3a.tdm.tsys')<br />
</source><br />
<br />
This will print to your screen: [0, 5, 5, 7, 5, 5, 5, 7]. Recall that the TDM spectral windows are spw=5 and 7 and the FDM spectral windows are 1 and 3. This spwmap tells applycal to use the Tsys information in spectral window 5 for spectral window 1; and to use the information in spectral window 7 for spectral window 3. Beyond that, it is only important that there are placeholders for the other spectral windows, its also useful to note that you need not give placeholders for spectral window ids larger than the largest spectral window you need to use, in this case 7.<br />
<br />
You will also need to put in placeholders for other tables that you give the gaintables. So if the Tsys table is 2nd in the list, spwmap=[[],[0,5,5,7,5,5,5,7],[]]<br />
<br />
Now run the applycal commands.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# A new list of file names that contain only data from the Northern Mosaic<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names_north = ['Titan','3c279','NGC*']<br />
<br />
for asdm in basename_north:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_north:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=['',field,field],<br />
interp=['','linear,spline','nearest'], <br />
gaintable=[asdm+'.antpos',asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]],<br />
flagbackup=False, calwt=True)<br />
<br />
# A new list of file names that contain only data from the Southern Mosaic<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names_south = ['Titan','3c279','Ant*']<br />
<br />
for asdm in basename_south:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_south:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=["",field,field],<br />
interp=['','linear,spline','nearest'],<br />
gaintable=[asdm+".antpos",asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]], <br />
flagbackup=False, calwt=True)<br />
</source><br />
<br />
where:<br />
<br />
*'''field''': the field ''to'' which we will apply the calibration, <br />
*'''gainfield''': the field ''from'' which we wish to take the calibration table<br />
*'''interp''' = 'nearest' : apply the nearest solution from the calibration table rather than interpolating.<br />
<br />
As you browse through the whole data set, you will probably note some problems along the same lines as the DV04 issue we saw above. We'll apply these as additional data flagging in just a moment.<br />
<br />
==Inspect Data==<br />
We are not quite done with the original ".ms" data sets yet. Before going further it will be useful to use {{plotms}} to show the effects of applying the calibration. In the process we'll take a quick look at each antenna and search for pathologies in the data.<br />
<br />
For this basic inspection, we want to compare the phase and amplitude as a function of frequency and time in the DATA and CORRECTED columns of each measurement set. The CORRECTED column has had the Tsys and WVR calibrations applied and so we expect lower phase scatter and flatter amplitude response as a function of time and frequency. We are looking for antenna-based issues, so cycling through a set of baselines that includes each antenna once will be a good start. We'll focus these plots on the phase+bandpass calibrator, 3c279, and on baselines that include antenna DV11, which we will make our reference antenna in just a bit.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
Each CASA Measurement Set has up to three "columns" of data: DATA, CORRECTED, and MODEL (though it is possible<br />
for a MS to hold only a DATA column if it has not been processed at all). <br />
<br />
A column entry exists for each data point (baseline, frequency, time). <br />
<br />
The DATA column holds the current raw data, though using split as we just did we can change the definition of<br />
"raw" data. <br />
<br />
The CORRECTED column holds the result of applying one or more calibration tables (e.g., via applycal) to the<br />
DATA column and so represents a corrected version of the DATA column. <br />
<br />
The MODEL column is now deprecated (though it is still possible to use it by explicitly setting usescratch=True).<br />
Instead, the model is stored in the header of the ms. This is a great step forward in terms of saving space and time <br />
to create scratch columns <br />
<br />
To get an intuitive feel for the columns you may wish to explore using plotms (which can plot different data <br />
columns, as seen below) or the browsetable task.<br />
<br />
</pre><br />
<br />
<figure id="plotms_amp_vs_freq_example-data.png"><br />
[[File:plotms_amp_vs_freq_example-data_6.1.png|200px|thumb|right|<caption> Example of Amplitude vs. Frequency before correction for the 3c 279.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_example-corr.png"><br />
[[File:plotms_amp_vs_freq_example-corr_6.1.png|200px|thumb|right|<caption> Same baseline as Figure 8 but now after correction using WVR and Tsys calibrations.</caption>]]<br />
</figure><br />
<br />
First, we plot amplitude as a function of frequency for 3c279. We start by plotting the DATA column, set color to indicate the two correlations (i.e., the XX and YY polarizations), and ask plotms to iterate over baseline. By setting '''antenna''' to 'DV11&*' we select only baselines that include DV11. We ask plotms to average all data over a very long timescale, '''avgtime''' = 1e8 seconds ~ 3 years or much longer than the time spanned by the whole data set. By setting '''avgscan''' = True we allow {{plotms}} to average across scan boundaries. The result is a plot of average amplitude per channel vs. frequency.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
asdm=basename_all[0]<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='amp',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Notice the green arrows along the bottom of the {{plotms}} window. We asked {{plotms}} to iterate over baseline. As you click the arrows, the plot will rotate from baseline to baseline, always with DV11 so that each antenna shows up once. To see the effect of the calibration, go to the "Axes" tab along the left of the {{plotms}} window and pull down the Data Column menu under the Y Axis. Set this from DATA to CORRECTED and you should see the effects of the calibration. You may need to ensure that the "Force Reload" box is checked before clicking "Plot" (both buttons lie at the bottom of the panel). For the most part things get better (flatter), but as we noted before DV04 is problematic.<br />
<br />
<figure id="plotms_amp_vs_time_north.png"><br />
[[File:plotms_amp_vs_time_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_time_south.png"><br />
[[File:plotms_amp_vs_time_south_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a southern mosaic data set.</caption>]]<br />
</figure><br />
<br />
You can now make analogous calls to examine the phase vs. frequency, amplitude vs. time, and phase vs. time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='phase',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='amp',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='phase',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Where:<br />
<br />
* '''spw''' is set to cover only channels 1200~1300 for the time plots in order to isolate time dependent variations from frequency-dependent behavior. Those 101 channels represent only a small part of the total spw 1 bandpass.<br />
* '''avgchannel''' set to a large number causes the plots of phase and amplitude vs. time to average data at all frequencies into a single point for each measurement.<br />
* '''coloraxis''' corr sets the colors to correspond to the two polarizations of the data.<br />
<br />
In each case, you will want to examine each baseline, alternating between the DATA and CORRECTED columns.<br />
<br />
This is a lot of data inspection and that's only for one of 10 data sets! You can iterate across the data by hand, updating "asdm" to refer to each data set in order and cycling between baselines and DATA/CORRECTED. It is also possible to script CASA to show you the key plots in succession (see the next block down). However you approach the infrastructure, you are looking for:<br />
<br />
* Improved scatter and lower variability in phase and amplitude vs. frequency and time. This indicates that the WVR and Tsys calibrations helped. <br />
* Sudden jumps in phase or amplitude as a function of either time or frequency. These may indicate problems with the antenna during that observation.<br />
* Large gradients, especially full wraps, in phase as a function of frequency. This may indicate a problem in the delays, the signal path length to the telescopes.<br />
* Unusual magnitude, scatter, or patterns in any plot - though this may be better explored using plots that show all data together, which we'll make in a moment.<br />
* Missing data. For example, if the phase calibrator drops out for a period of time we will not be able to calibrate and will need to flag the data.<br />
<br />
As you look through, note individual potentially problematic antennas. If ''all'' antennas in a data set appear problematic it may be that your "reference" antenna, DV11 in the example above, is the source of the problem. In this case swap this reference antenna for another and see whether the problem is isolated to your original reference antenna.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
A brief aside on structure:<br />
<br />
This section (Data Inspection) and the next (Apply Flags) are closely linked. We will present them as two<br />
separate steps. The idea here is that you look through your data, note problems, and then write commands to<br />
flag problematic data. This mimics one approach to writing data reduction scripts for CASA, where you will<br />
group all flagging together into one convenient place. Other CASA guides take a different approach, interleaving <br />
flagging and plotting. There is no "right" answer here. Find an approach to data inspection that works for you.<br />
<br />
</pre><br />
<br />
If you do wish to semi-automate the plot generation, the following sequence will cycle between data and corrected plots for each data set in turn. Type "stop" at any input call to break out.<br />
<br />
<!--<br />
'''Note:''' In loops like this involving {{plotms}}, hitting enter before the last dataset completes loading may cause {{plotms}} to stop refreshing the plot window at each step, or cause the window to disappear altogether. This will be fixed in an upcoming CASA release. Right now, you may need to exit CASA and restart to bring up the {{plotms}} window again, but you should be able to continue in the script where you left off.<br />
--><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
user_input = ""<br />
for asdm in basename_all:<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
# Extract antenna list for this data set.<br />
tb.open(asdm+'.ms/ANTENNA', nomodify=True)<br />
ants = tb.getcol('NAME')<br />
tb.close<br />
# Define the reference antenna to make baselines with<br />
ref_ant = 'DV11'<br />
# Loop over antennas<br />
for ant in ants:<br />
# Check if the user wants to stop<br />
if user_input == "stop":<br />
break<br />
# Skip correlation of reference antenna with itself (autocorrelations are flagged anyhow) <br />
if ant == ref_ant:<br />
continue<br />
# Define the baseline with the reference antenna for current antenna<br />
ant_str = ref_ant+'&'+ant<br />
print ("Showing baseline "+ant_str+" for data set "+asdm)<br />
print ("Use this to inspect effect of applying wvrcal and Tsys calibrations.")<br />
# Loop over phase and amplitude as axes<br />
for y_axis in ["amp", "phase"]:<br />
# Make 'before' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'before' plot for time x-axis<br />
print ("... "+y_axis+" vs. time for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for time y-axis<br />
print ("... "+y_axis+" vs. time for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<figure id="plotms_amp_vs_uvdist_north.png"><br />
[[File:plotms_amp_vs_uvdist_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. uv-distance for 3c279 in the first northern mosaic data set.</caption>]]<br />
</figure><br />
<br />
<figure id="plotms_amp_vs_freq_3c279.png"><br />
[[File:plotms_amp_vs_freq_3c279_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for 3c279 in the second northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Titan.png"><br />
[[File:plotms_amp_vs_freq_Titan_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for Titan in the second northern mosaic data set. Note the strong line (this is CO 3-2)!</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Antennae.png"><br />
[[File:plotms_amp_vs_freq_Antennae_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for the Antennae in the second northern mosaic data set. The CO(3-2) line is visible.</caption>]]<br />
</figure><br />
<br />
A detailed explanation of the procedure is a bit outside the scope of this guide (for more on python see http://www.python.org/ and for more on the CASA toolkit see http://casa.nrao.edu/), but the basic process is to loop over each data set, baseline with the reference antenna (here DV11), and y-axis of interest (phase or amplitude) then plot the effect of the calibration vs. frequency and time for each combination. Running this to step through the data will give you about 200 "before and after" plots from which you could note a subset of problematic cases to be followed up by hand. Many other strategies to inspect the data are also viable.<br />
<br />
With the Tsys and WVR calibrations applied successfully and the ''a priori'' flagging taken care of we will now {{split}} out the corrected data. We will keep only the corrected data, specified via '''datacolumn''', and only spectral window 1, which contains the FDM (high spectral resolution) observations of the CO(3-2) line. Setting '''keepflags'''=False tells {{split}} not to carry over any fully flagged rows from the original data set to the new MS. We give the new MS files the extension ".wvrtsys.ms" to indicate that they have been corrected for WVR and Tsys effects. Because split will not overwrite existing files, we remove any previous versions of the new MS before beginning.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm -rf '+asdm+'.wvrtsys.ms')<br />
print ("Splitting out corrected data for "+asdm)<br />
split(vis=asdm+'.ms', outputvis=asdm+'.wvrtsys.ms', <br />
datacolumn='corrected', spw='1', keepflags=False)<br />
</source><br />
<br />
Be patient, {{split}} may take awhile. The WVR and Tsys-corrected data now sit in the DATA column of the new measurement sets, which have only one spectral window (now labeled spectral window 0 though it was spectral window 1 in the original data). You may wish to run {{listobs}} to illustrate the changes:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.wvrtsys.listobs.txt')<br />
listobs(vis=asdm+'.wvrtsys.ms', listfile=asdm+'.wvrtsys.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note the new spectral window information:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
2011-08-05 01:07:08 INFO listobs Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
2011-08-05 01:07:08 INFO listobs SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
2011-08-05 01:07:08 INFO listobs 0 3840 TOPO 344845.586 488.28125 1875000 344908.33 XX YY <br />
<br />
</pre><br />
<br />
<br />
Next we will do a bit more inspection using {{plotms}} to look at whole data sets. This will help us identify missing data or look for egregious outliers.<br />
<br />
First we plot amplitude versus time (see <xr id="plotms_amp_vs_time_north.png"/> and <xr id="plotms_amp_vs_time_south.png"/>), averaging over all channels (by setting '''avgchannel''' to the very large value 10,000). We colorize by field so that scans on Titan are red, the bandpass and phase calibrator 3c279 is black (and orange in the Southern Mosaic where it has two field IDs), and the Antennae mosaic appears as a range of colors (one per pointing).<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='amp', <br />
avgchannel='3840',coloraxis='field', showgui = True)<br />
user_input = input("Examining amplitude vs. time for "+asdm+" . Hit <Enter> to proceed.[type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
Here look for:<br />
<br />
* Missing data. The source needs to be flanked by phase calibrator scans, if those are missing for any reason we need to flag the appropriate time range.<br />
* Dramatic outliers. Does the source suddenly get very bright or the otherwise bright calibrator appear anomalously faint for a brief time? This likely indicates problematic data that should be identified and flagged. You can use the "select" (box with green plus along the bottom row in plotms) and "locate" (magnifying glass) buttons in {{plotms}} to isolate and identify problem data (it will print to the log).<br />
* Smooth variation with time. A sudden jump may indicate a problem and often the safest approach is to flag data near a discontinuity.<br />
<br />
Look through the amplitudes vs. time for each data set (remember that we've already examined the phases vs. time and amplitude vs. time for individual baselines above).<br />
<br />
There are two other very useful "averaging" plots worth making. First, we plot amplitude as a function of u-v distance (projected antenna separation). Discontinuities and spikes in this plot are often from non-astrophysical sources. In the phase analog to the plot, the effects of atmospheric decorrelation can be assessed from increased scatter at longer u-v distances. While using the moon Titan as our flux calibrator, we may want to watch for flaring amplitudes at short u-v distances. These may indicate that Saturn is contaminating our beam. For a perfect, bright point source, we expect flat amplitudes as a function of u-v distance at the source amplitudes. <xr id="plotms_amp_vs_uvdist_north.png"/> shows an example of this plot, generated via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='3c279',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. UV Distance for 3c279 for "+asdm+" . Hit <Enter> to proceed.")<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='Titan',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
user_input = input("Examining amplitude vs. UV Distance for Titan for "+asdm+" . Hit <Enter> to proceed [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
<br />
<br />
It can also be useful to examine the average amplitude as a function of frequency for each target. This allows one to check for lingering atmospheric effects, unexpected line emission or absorption in the calibrators, or decreased sensitivity due to "roll-off" of the telescope sensitivity at the band edges. These plots are created by the sequence of commands below, where we have broken up the script to loop separately over the Northern and Southern Mosaics to reflect the different source names.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names = ["3c279","Titan","NGC*"]<br />
<br />
for asdm in basename_north:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+". Hit <Enter> to proceed.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names = ["3c279","Titan","Ant*"]<br />
<br />
for asdm in basename_south:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+" . Hit <Enter> to proceed.")<br />
<br />
</source><br />
<br />
<br />
For this command notice that we can see the CO(3-2) line in the Antennae even before calibration (see <xr id="plotms_amp_vs_freq_Antennae.png"/>) and that Titan also shows evidence of a strong line (also <xr id="plotms_amp_vs_freq_Titan.png"/>)! This will need to be flagged before we can use Titan to calibrate the flux scale of our data.<br />
<br />
This suite of plots (along with the earlier inspection of the Tsys tables) gives us the tools we need to identify problematic data through the data sets. We use this to generate a set of inspection-driven {{flagdata}} commands for each data set. We apply these before the bandpass and gain calibration.<br />
<br />
==Apply Flagging==<br />
Based on this inspection and the other plots we have made, we now flag problematic portions of the data. We break up the flags by reason for flagging in order to illustrate the process. As you reduce your own data it may be more efficient to group flags by data set and make use of the flagcmd command. Except for the "post-calibration" flagging, the inspection plots that we just looked through have already revealed all of the problems that we flag. We structure the guide so that the flagging is grouped in one place.<br />
<br />
As before, we may wish to reset our flags before beginning (particularly if one iterates this process) via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms',mode='unflag', flagbackup = False)<br />
</source><br />
<br />
Remember that we dropped the flagged data when splitting out after the WVR and Tsys calibration, so this should not undo your "A Priori" flagging of shadowed data, autocorrelations, etc.. In any case this unflagging step is not necessary during the first iteration.<br />
<br />
* '''Edge Channels'''<br />
<br />
ALMA's sensitivity decreases near the edge of the baseband and it is often useful to check for a 'roll-off' in sensitivity near the edge of the band. This will appear as a downturn in amplitude as a function of channel near the edge of the window in the uncalibrated data, as a flaring due to increased noise at the spw edges in the calibrated data. It will also be visible in the amplitude part of the bandpass calibration table. Because our FDM spw does not cover the full baseband, we do not see a strong roll off in our data (see <xr id="amp_vs_channel_example.png"/>), where there is only a mild hint of a roll-off at the high end) but we do flag a (very) few channels at the high and low-frequency edge of the data set to be safe.<br />
<br />
<figure id="amp_vs_channel_example.png"><br />
[[File:amp_vs_channel_example.png|200px|thumb|right|<caption> Amplitude vs. channel for one uncalibrated antenna pair. This kind of plot can be inspected to get an idea of the presence or magnitude of any roll-off in sensitivity near the edges of the spectral window.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:0~7,0:3831~3839', flagbackup = False)<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:3260~3320', flagbackup = False)<br />
</source><br />
<br />
* '''Problematic Tsys measurements'''<br />
<br />
Above we noted issues with the Tsys measurements for both DV04 and DV12. We flag the affected data. Each of these issues should be visible in the Tsys plots you made above (e.g., see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/> and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/>).<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04',flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X1d5"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X392"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
</source><br />
<br />
* '''Unreliable Short-Spacing Measurements on Titan'''<br />
<br />
<figure id="amp_vs_uv_titan_obs.png"><br />
[[File:amp_vs_uv_titan_obs.png|200px|thumb|right|<caption> Observed amplitude vs. uv-distance for observations of Titan in the first data set. Note the scatter for low projected antenna separations. We will flag these short-spacing data, which may reflect contamination by Saturn, and use only the more extended baselines for flux calibration.</caption>]]<br />
</figure><br />
<br />
Saturn may contaminate the short u-v spacings from Titan. In any case these often show significant scatter (<xr id="amp_vs_uv_titan_obs.png"/>), so we flag them. There are still enough baselines to determine a good amplitude calibration for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~40', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
</source><br />
<br />
* '''Delay Issues''' <br />
<br />
<figure id="phase_vs_freq_DV13.png"><br />
[[File:phase_vs_freq_DV13.png|200px|thumb|right|<caption> Phase vs. frequency for DV13 in a data set where this antenna shows evidence of imperfect delay calibration.</caption>]]<br />
</figure><br />
<br />
DV13 and a few other antennas show signatures of an imperfect delay calibration. This is most easily identified via strong "wrapping" of phase as a function of frequency (see <xr id="phase_vs_freq_DV13.png"/>). Such effects can be calibrated out with mild delay issues largely accounted for by the bandpass solution. The phase wrapping in DV13 seems weak enough that we will trust the calibrations to remove it. For a more extreme example see the CASA guide describing the calibration of [[NGC3256Band3]].<br />
<br />
* '''Missing Phase Calibrator Observations'''<br />
<br />
<figure id="amp_vs_time_missing_scans.png"><br />
[[File:amp_vs_time_missing_scans.png|200px|thumb|right|<caption> Amplitude vs. time colored by field for a data set where the final visit to the phase calibrator is missing. We will flag the last set of source data to ensure that each visit to the source is flanked in time by visits to the phase calibrator.</caption>]]<br />
</figure><br />
<br />
As a general rule, we want to be sure that observations of the phase calibrator (3c279) bracket each source observation. Two of the data sets do not include a final phase calibrator observation (see <xr id="amp_vs_time_missing_scans.png"/>) and for those two cases we flag the affected source observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='00:53:47~01:08:00',flagbackup = False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV10',timerange='19:46:20~20:34:40',flagbackup=False)<br />
</source><br />
<br />
* '''Unexpected Scatter or Discontinuity in the Data'''<br />
<br />
For several antennas we find sudden jumps in the phase of the phase calibrator as a function of time. These are visible in the plots of uncalibrated phase vs. time for single baselines above, and we show an example in <xr id="phase_vs_time_DV09.png"/>. It will not be possible to effectively interpolate the phase between measurements when we see these discontinuities. The safest approach is to flag the source data across these jumps. We do so here (though note that the last two flaggings are borderline cases).<br />
<br />
<figure id="phase_vs_time_DV09.png"><br />
[[File:phase_vs_time_DV09.png|200px|thumb|right|<caption> Phase vs. time for DV09 on a problematic day. It may prove problematic to calibrate the data near this discontinuity so we flag data near this time.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09', timerange='21:24:09~21:35:35', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09',timerange='23:30:52~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM01',timerange='23:16:50~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM03',timerange='23:16:50~24:10:00',flagbackup=False)<br />
</source><br />
<br />
* '''Outliers Visible After Calibration'''<br />
<br />
<figure id="amp_vs_uvdist_outliers.png"><br />
[[File:amp_vs_uvdist_outliers.png|200px|thumb|right|<caption> Amplitude vs. u-v distance ''after'' calibration. Note the outlying data. We track these down using the select (box with green "+") and locate (magnifying glass) features inside plotms and identify several problematic baselines across our data. ''Note that you cannot make this plot at this point in the guide, these pathologies become evident after calibration, requiring an iterative approach to reduction.''</caption>]]<br />
</figure><br />
<br />
Often issues with the data may become evident after calibration (i.e., after the next few steps that we apply). These data can appear as outliers in diagnostic plots for the calibrated data or even show up in the imaging stages. Once these are identified, best practice is to apply this new flagging then redo the calibration (if the issue is very minor, then re-calibrating may not be necessary).<br />
<br />
<source lang="python"><br />
# In CASA<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='21:18:00~21:22:15', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV01&DV04', flagbackup=False)<br />
</source><br />
<br />
Now that we've applied our flagging, back up the flags as version "User" using {{flagmanager}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis=asdm+'.wvrtsys.ms',mode='save',versionname ='User')<br />
</source><br />
<br />
Applying this flagging will remove the most egregious pathologies from the data. We are now ready to calibrate the data.<br />
<br />
==Bandpass Calibration==<br />
<br />
We begin by calibrating the phase and amplitude response of each antenna as a function of frequency, called "bandpass calibration." We have already seen that the data contain smooth but systematic variations in both phase and amplitude as a function of frequency. We can see this again in a more compact form by plotting phase as a function of frequency for all baselines associated with each antenna (<xr id="plotms_phase_vs_freq_example.png"/>).<br />
<br />
<figure id="plotms_phase_vs_freq_example.png"><br />
[[File:plotms_phase_vs_freq_example_6.1.png|200px|thumb|right|<caption> Phase vs. frequency for the bandpass calibrator, 3c279 in the first data set. We plot all baselines with DV02, averaged over time, and show only the 'XX' correlation.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='freq', yaxis='phase', <br />
selectdata=True, field='3c279', correlation='XX',<br />
avgtime='1e8', avgscan=True, antenna='*&*',<br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. frequency for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
Each plot shows phase as a function of frequency for all baselines with one antenna for 3c279. We plot only the 'XX' correlation, colorizing by baseline. With '''iteraxis''' set to antenna the green arrows at the bottom of {{plotms}} will cycle through antennas. By using '''avgscan''' and a large '''avgtime''' we average all scans and integrations. <br />
<br />
The phase (and amplitude) also varies as a function of time, as we saw before. Here are the similar plots for phase vs. time (see <xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb-phasecont.png"><br />
[[File:Uid_A002_X1ff7b0_Xb-phasecont_6.1.png|200px|thumb|right|<caption> Phase vs. time for the bandpass calibrator, 3c279. Averaged over channel. Only baselines with antenna DV02, and corr='XX'</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='phase', <br />
selectdata=True, field='3c279', <br />
spw='0:1200~1299', antenna='*&*',correlation='XX',<br />
avgchannel='100', avgscan=True, <br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. time for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
<xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/> shows that the phase varies with time. We need to take this temporal variation into account when we solve for the frequency variations. Therefore we carry out the bandpass calibration in two steps. First, we use {{gaincal}} to solve for the variation of phase as a function of time for 3c279 on very short timescales. We set {{gaincal}} to derive a separate phase solution for each antenna every integration by setting '''solint''' to 'int'. We solve, averaging together only a small fraction of the total bandpass (channels 1100-1300) to avoid the effects of the phase vs. frequency behavior. We will then apply this solution to remove time-dependent behavior when we solve for the frequency response of the antennas with {{bandpass}}.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
An integration is the smallest time quantum of observation in the data, usually a few seconds. <br />
You can check the integration length for each scan in listobs. <br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
for asdm in basename_all:<br />
print ("Running a short solution interval phase calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bpphase.gcal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
selectdata=True,field = '3c279',spw = '0:1100~1300',<br />
caltable = asdm+'.bpphase.gcal',<br />
solint = 'int',refant = 'DV11',calmode='p')<br />
</source><br />
<br />
Now we use {{bandpass}} to solve for the frequency response of each antenna. To do this, we average all data in time by setting '''solint''' to 'inf' (that is, 'infinite'). We allow combination across scans and the different field IDs found for 3c279 by setting '''combine''' to "scan,field". We apply the phase vs. time calibration that we just derived on-the-fly using the parameter "gaintable".<br />
<br />
<source lang="python"><br />
for asdm in basename_all:<br />
print ("Running a bandpass calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bandpass.bcal')<br />
bandpass(vis = asdm+'.wvrtsys.ms',<br />
field = '3c279',<br />
gaintable = asdm+'.bpphase.gcal',<br />
caltable = asdm+'.bandpass.bcal',<br />
bandtype='B',<br />
solint = 'inf',combine = 'scan,field', solnorm=True,refant = 'DV11',<br />
minblperant=3,minsnr=2,fillgaps=62)<br />
</source><br />
<br />
in these calls:<br />
<br />
*'''caltable''' specifies the output calibration table<br />
*'''gaintable''' specifies any calibration tables to be applied "on the fly" to the data before solving.<br />
*'''solint''' sets the time interval for which solutions are derived for each antenna.<br />
*'''refant''' set the reference antenna, here DV11, which is defined to have zero correction by construction.<br />
*'''calmode''' 'p' sets {{gaincal}} to calibrate the phase only, other options are 'a'mplitude or 'ap' - amplitude and phase.<br />
*'''minblperant''' sets the minimum baselines required per antenna for a successful solution.<br />
*'''minsnr''' sets the minimum signal-to-noise ratio required for a successful solution.<br />
*'''bandtype''' here 'B' tells {{bandpass}} to solve for the phase and frequency response of each antenna in each channel, averaging data in time across the solution interval.<br />
*'''fillgaps''' tells {{bandpass}} to interpolate across channel gaps 1 channel wide.<br />
*'''solnorm''' tells {{bandpass}} to normalize the bandpass amplitude and phase corrections to have magnitude unity. The absolute scale of the calibration will come from our later {{gaincal}} solutions.<br />
<br />
Do not worry about the message "Insufficient unflagged antennas" when running the {{bandpass}} task. This indicates that {{bandpass}} is failing on the flagged edge channels, which is expected.<br />
<br />
It is now a good idea to plot both sets of solutions to look for irregularities, especially:<br />
<br />
* discontinuities in the phase vs. time solution<br />
* rapid wrapping of phase in either phase vs. time or bandpass solution<br />
* large roll-off in the amplitude response near the band edge in the bandpass solution<br />
* large scatter in any solution.<br />
<br />
We loop through and using analysis utils, again generating .png files of each calibration. '''For what systems is this true?''' As the bandpass plots take a while you may want to go have a cup of coffee and inspect them using your favorite image viewer. Otherwise, switch the '''interactive''' parameter to True to see them in real time instead.<br />
<br />
<figure id="uid___A002_X1ff7b0_X1c8.bpphase.page1.png"><br />
[[File:uid___A002_X1ff7b0_X1c8.bpphase.page1_6.1.png|200px|thumb|right|<caption> Short interval phase vs. time solution carried out and applied during bandpass calibration, here for the first set of antennas for the first data set. This solution removes any systematic variations in phase vs. time.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1.CASA3.4.png"><br />
[[File:Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1_6.1.png|200px|thumb|right|<caption> Bandpass amplitude solution for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X1ff7b0_Xb.bcal_phase.page1.png"><br />
[[File:uid___A002_X1ff7b0_Xb.bcal_phase.page1.png|200px|thumb|right|<caption> Phase vs. frequency calibration from the bandpass calibration for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<br />
<!--<br />
Again this warning:<br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
--><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
os.system('rm -rf cal_plots/*bandpass*.png')<br />
for asdm in basename_all:<br />
plotbandpass(caltable=asdm+'.bandpass.bcal',<br />
field='',xaxis='freq',yaxis='both',<br />
figfile='cal_plots/'+asdm+'.bandpass.png',<br />
showatm=True,interactive=False,subplot=42)<br />
</source><br />
<br />
==Absolute Flux Calibration==<br />
<br />
The bandpass calibration will account for the phase and amplitude response of our antennas as a function of frequency. We now solve for the absolute flux scale of the data by referencing to Titan and in the next section we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
Before using Titan to set the flux, there is an important systematic to account for. When we looked at the integrated spectra of our targets above, remember that Titan showed a whopping spectral line, in fact the same CO(3-2) line that we wish to observe in the Antennae. We will set the flux of Titan (and thus all of our data) by referencing to a model in casa that does not account for this line. Therefore we need to flag the part of the Titan observations contaminated by the line before we calibrate (you can see the affected channel range in <xr id="Antennae-TitanLine.png"/>). We run the following additional flagging step:<br />
<br />
<figure id="Antennae-TitanLine.png"><br />
[[File:Antennae-TitanLine_6.1.png|200px|thumb|right|<caption> Uncalibrated amplitude vs. channel plot for the flux calibrator, Titan (uid___A002_X1ff7b0_Xb dataset). Averaged over time, corr='XX', and colorized by baseline.</caption>]]<br />
</figure><br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Flagging CO(3-2) in Titan for "+asdm)<br />
flagdata(vis=asdm+'.wvrtsys.ms',flagbackup=False, <br />
field='Titan', spw='0:1100~1700')<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis =asdm+'.wvrtsys.ms',mode = 'save',versionname = 'Calibration')<br />
</source><br />
<br />
Next, we will use the {{setjy}} task to read the predicted complex visibilities for Titan into the MODEL column of each data set.<br />
<br />
<source lang="python"><br />
# in CASA<br />
for asdm in basename_all:<br />
print ("Reading model for Titan into "+asdm)<br />
setjy(vis = asdm+'.wvrtsys.ms',field = 'Titan',<br />
usescratch=True,scalebychan=True,<br />
standard = 'Butler-JPL-Horizons 2012')<br />
</source><br />
<br />
{{setjy}} will output the flux of Titan to the CASA logger and it is worth recording this information. The flux of Titan at these frequencies is about 3.3 Jy. For example, for dataset uid___A002_X1ff7b0_Xb.wvrtsys.ms:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Titan: spw0 Flux:[I=3.2637,Q=0.0,U=0.0,V=0.0] +/- [I=0.0,Q=0.0,U=0.0,V=0.0] Jy @ 344.85GHz<br />
</pre><br />
<br />
Now we are going to take a look at the Titan model for one dataset:<br />
<br />
<source lang="python"><br />
# in CASA<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
</source><br />
<br />
<figure id="2012_titan_model_5.1.png">[[File:2012_titan_model_5.1.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2012'.</caption>]]</figure><br />
<figure id="2010_titan_model_6.1.png">[[File:2010_titan_model.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2010'.</caption>]]</figure><br />
<br />
<br/><br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
The setjy invocation made in this section uses the flux density standard '''standard='Butler-JPL-Horizons 2012' '''. Previous versions of this guide used an older flux density standard '''standard='Butler-JPL-Horizons 2010' '''. <xr id="2012_titan_model_5.1.png"/> and <xr id="2010_titan_model.png"/> show the differences in the Titan models produced using these two standards. <br />
</div><br />
<br />
==Gain (Phase and Amplitude) Calibration==<br />
<br />
With the flux now properly scaled, we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
We begin by running a short-solution interval {{gaincal}} to solve for phase variation on short timescales during observations of our two calibrators, with '''solint''' set to "int". By applying this on-the-fly, we can remove any decorrelation in the data due to phase scatter when we solve for the amplitude calibration. However, there is no benefit to using this short-timescale solution to calibrate the source because we only have information on the gain during calibrator visits (though see the Imaging portion of this guide). Instead we will solve for the gains to apply to the source using a longer '''solint''' in just a moment.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out short timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.intphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.intphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='int',minsnr=2.0, minblperant=4)<br />
</source><br />
<br />
Now we derive the longer timescale phase calibration table using '''solint''' set to "inf", but not allowing scan combination. This calibration has higher signal to noise due to combining more data, and for the purposes of correcting the source, it is just as precise as the short timescale solution.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out longer timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.scanphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.scanphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='inf',minsnr=2.0,minblperant=4)<br />
</source><br />
<br />
Now we apply the short-timescale phase solution and carry out a scan length ('''solint''' set to "inf") calibration of the data using '''calmode''' of 'ap'.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Solving for longer (scan) interval amplitude solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.amp.cal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
gaintable =[asdm+'.bandpass.bcal',asdm+'.intphase.gcal'],<br />
caltable = asdm+'.amp.cal',<br />
calmode='ap',<br />
field = 'Titan,3c279',<br />
spw='0:40~3800',<br />
refant = 'DV11',solint = 'inf', minblperant=4)<br />
</source><br />
<br />
This "amp.cal" solution gives us the amplitude variations as a function of time, but they are not yet pinned to a realistic scale except in the case of Titan, where we have solved using the model input by {{setjy}}. We will set the flux of our secondary calibrator 3c279 with reference to Titan using {{fluxscale}}.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Scaling amplitude calibration to match Titan for "+asdm)<br />
os.system('rm -rf '+asdm+'.flux.cal')<br />
fluxscale(vis = asdm+'.wvrtsys.ms',<br />
caltable = asdm+'.amp.cal',<br />
fluxtable = asdm+'.flux.cal',<br />
reference = 'Titan',<br />
transfer = '3c279')<br />
</source><br />
<br />
This new correctly-scaled flux table ".flux.cal" replaces the previous ".amp.cal" table as the correct amplitude calibration table to apply to the data, i.e., the ".flux.cal" contains both the time variability of the amplitude solved for in ".amp.cal" and the correct flux scaling set with {{fluxscale}}.<br />
<br />
Fluxscale will output the derived flux for 3c279 to the CASA logger. This information is worth noting. We find that the flux of 3c279 is 10.79 Jy, by averaging the fluxes obtained from the ten available datasets. If we check this value against reported flux measurements in the SMA calibrator list [http://sma1.sma.hawaii.edu/callist/callist.html], we find that a flux of 10.79 Jy agrees within a few per cent of a linear interpolation between the two 0.85 mm measurements closest in time to the ALMA observations: (23 May 2011, SMA 11.644 ± 0.583; 01 July 2011, 9.748 ± 0.488).<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used the older, Butler-JPL-Horizons 2010, flux density standard when you ran {{setjy}} earlier in this tutorial, the derived flux values for 3c279 will be slightly lower. The flux of 3c279, when averaged over all 10 measurement sets, will be 10.41 Jy.<br />
</div><br />
<br />
Now we plot the final phase and amplitude calibration tables for each data set. A well-behaved calibration table will show smooth variations as a function of time. Sudden jumps or wild variations among the antenna amplitude gains should prompt further investigation and possibly additional flagging.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting solutions for "+asdm)<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis='antenna',antenna='0~7',plotrange=[0,0,-180,180],<br />
gridrows=4,gridcols=1,showgui=False,<br />
plotfile=asdm+'.scanphase.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis = 'antenna', antenna='8~15', plotrange=[0,0,-180,180],<br />
showgui=False, gridrows=4, gridcols=1, <br />
plotfile=asdm+'.scanphase.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='0~7', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='8~15', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
<br />
</source><br />
<br />
==Apply the Calibrations and Inspect ==<br />
Now we will use {{applycal}} to apply the bandpass, phase, and amplitude calibration tables that we generated in the previous sections to the data. We apply the solutions separately to the bandpass and secondary ("phase") calibrator 3c279, the flux calibrator Titan, and the target source. In most data sets, the bandpass and secondary calibrator will not be the same and this step would include one additional {{applycal}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
for asdm in basename_north: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='NGC*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_south: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Ant*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
</source><br />
<br />
Here:<br />
* '''vis''' and '''field''' specify the measurement set and field to calibrate.<br />
* '''gaintable''' specifies the tables to apply to the data. There may be several tables applied all at once, here we apply the bandpass, phase, and flux calibrations.<br />
* '''interp''' specifies the type of interpolation used to match calibration tables to the data. If there are several gaintables then interp may be either a single value (e.g., "linear" or "nearest") or a list of values with size equal to the list of gaintables. In the case where interp is a list, applycal will match each element to the corresponding gaintable (e.g., first gaintable with first interp parameter).<br />
* '''gainfield''' specifies field from which to draw the calibration. As with interp, this can be a list of size matched to gaintable, so that the first element of gainfield will be the field used for the first table. For example, in the above commands the bandpass calibration (the first table) will always be applied from '3c279' (the first gainfield).<br />
* '''calwt''' indicates that the weights, which were derived from the Tsys measurements, should also be calibrated. Note that '''calwt''' is True by default.<br />
<br />
Once calibrations are applied, it is important to go back and inspect the calibrated data. New problematic antennas or baselines may be visible after calibration. Repeat the steps above, focusing on the CORRECTED data column. Bear in mind that for any point source calibrators we now expect to find phase scattering around zero and to find flat amplitudes as a function of u-v distance. Look for outliers and other signatures of problematic data. As a general rule, you will want to incorporate these data into your overall flagging script then rerun the whole calibration process, so that reduction is iterative. If the data only represent a minor problem, however, it may not be terribly harmful to flag them after the fact so that they do not interfere with imaging but trust that the calibrations are mostly unaffected.<br />
<br />
As an example of this inspection, we cycle through the corrected amplitudes and phases of 3c279 and Titan as a function u-v distance, to check that the phases are close to zero and the amplitudes are constant. <br />
<br />
<figure id="xb-checkcal-pha-cha.png"><br />
[[File:xb-checkcal-pha-cha.png|200px|thumb|right|<caption> Calibrated phase vs. channel plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<figure id="xb-checkcal-amp-time.png"><br />
[[File:xb-checkcal-amp-time.png|200px|thumb|right|<caption> Calibrated amplitude vs. time plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='phase',<br />
ydatacolumn='corrected', field='3c279',<br />
avgchannel='3840', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
In <xr id="xb-checkcal-pha-cha.png"/> and <xr id="xb-checkcal-amp-time.png"/> we plot phase vs. channel and amp vs. time for 3c279 for the uid___A002_X1ff7b0_Xb dataset. <br />
<br />
Finally we can use {{plotms}} to examine the corrected amplitude and phase of Antennae galaxies as a function of time and uv-distance (plots not shown):<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
for asdm in basename_north:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
avgtime='1e8', avgscan=True, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
for asdm in basename_south:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
avgtime='1e8', avgscan=True,avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
</source><br />
<br />
==Split and Concatenate Data for Northern and Southern Mosaics==<br />
The individual data sets are now calibrated. We can safely split out the calibrated data for our science target and drop the calibrators. As we do so, we will smooth the data in frequency, averaging together groups of 23 channels by setting '''width=23''' in {{split}}. The new data will have a channel width corresponding to about ~10 km/s, very similar to the SMA data being verified. The factor of >20 drop in data volume will also make the imaging steps ''much'' more tractable.<br />
<br />
Note that you will see a warning that the last output channel in the new spw 0 will be dropped, as it has less than 23 channels over which to average:<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO MSTransformDataHandler The last output channel of spw 0 has only 22 input channels.<br />
WARN MSTransformManager Not enough input channels to populate output channel n# 166 from SPW 0.<br />
WARN MSTransformManager The channel will be dropped in order to have an uniform grid.<br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_north:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'NGC*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
<br />
for asdm in basename_south:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'Ant*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
</source><br />
<br />
For convenience we concatenate all data for the Northern Mosaic into a single big MS and place all data for the Southern Mosaic into another file. To do this, we construct a list that holds the names of all the Southern Mosaic MS files and another that holds the name of all the Northern Mosaic MS files then feed these into the {{concat}} task. <br />
<br />
Before we do this, we'll take a brief aside to remove Pointing information from the calibrated data. Normally, the pointing information would apply important corrections to be used while imaging the data. However, some aspects of this are still under development and the pointing information in these data interacts poorly with CASA. We will remove the pointing information using the CASA toolkit Table tool (tb). ''This kind of operation is dangerous and should not be a regular feature of your CASA reduction.''<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Manually removing pointing table from "+asdm+".cal.ms ... Please be careful!")<br />
tb.open(asdm+'.cal.ms/POINTING',nomodify=False)<br />
a = tb.rownumbers()<br />
tb.removerows(a)<br />
tb.close()<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
cal_south_vis = [vis+'.cal.ms' for vis in basename_south]<br />
cal_north_vis = [vis+'.cal.ms' for vis in basename_north]<br />
<br />
os.system('rm -rf Antennae_South.cal.ms')<br />
concat(vis=cal_south_vis, concatvis='Antennae_South.cal.ms', timesort=True)<br />
<br />
os.system('rm -rf Antennae_North.cal.ms')<br />
concat(vis=cal_north_vis, concatvis='Antennae_North.cal.ms', timesort=True)<br />
</source><br />
<br />
The syntax used to construct the 'cal_south_vis' variable loops over basename_south and makes a list after adding '.cal.ms' to each member. To see the list 'print (cal_south_vis)'.<br />
<br />
==Continue on to Imaging of the Science Target==<br />
Now you can continue on to the [http://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_6.1 imaging guide].<br />
{{Checked 6.1}}</div>Dkimhttps://casaguides.nrao.edu/index.php?title=File:Antennae-TitanLine_6.1.png&diff=29404File:Antennae-TitanLine 6.1.png2020-10-01T17:00:09Z<p>Dkim: </p>
<hr />
<div></div>Dkimhttps://casaguides.nrao.edu/index.php?title=AntennaeBand7_Calibration_6.1&diff=29403AntennaeBand7 Calibration 6.12020-10-01T15:31:04Z<p>Dkim: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide is written for CASA 6.1 and uses Python 3. The same functionality is implemented in Python 2 using CASA 5.7 at [[AntennaeBand7 Calibration 5.7]]'''<br />
<br />
*'''This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are provided at [[AntennaeBand7]]<br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see: [[AntennaeBand7_Imaging 6.1]]'''.<br />
<br />
==Overview==<br />
<br />
This part of the Antennae Band 7 CASA guide will step through the calibration of the visibility data. We will begin by flagging (marking as bad) data known to be useless before any inspection; for example, data where one telescope blocks the line of sight of another. We will then apply telescope-generated calibration tables to partially correct for atmospheric effects. After inspecting the data, we will flag some additional data that exhibit pathologies. Using observations of the calibrators Titan and 3c279, it will be shown how to derive the phase and amplitude response of individual antennas as a function of time and frequency ("phase", "amplitude", and "bandpass" calibrations). We will apply these solutions to the data and then extract the calibrated source data into a file appropriate for imaging in the [[AntennaeBand7_Imaging | Antennae Band 7 imaging guide]].<br />
<br />
The general procedure in this guide follows the other ALMA CASA guides: [[NGC3256Band3]] and [[TWHydraBand7]].<br />
<br />
==Unpack the Data==<br />
<br />
This guide requires CASA 6.1 and assumes that you have downloaded Antennae_Band7_UnCalibratedMSAndTablesForReduction.tgz from [[AntennaeBand7#Obtaining_the_Data]]. <br />
<br />
Once you have downloaded the data, unpack the file in a terminal outside CASA using<br />
<br />
<source lang="bash"><br />
<br />
tar -xvzf Antennae_Band7_UnCalibratedMSandTablesForReduction.tgz<br />
<br />
</source><br />
<br />
then change directory to the new directory <br />
<br />
<source lang="bash"><br />
<br />
cd Antennae_Band7_UnCalibratedMSandTablesForReduction<br />
<br />
</source><br />
<br />
You may wish to type<br />
<br />
<source lang="bash"><br />
<br />
ls<br />
<br />
</source><br />
<br />
to look at the files present. You should see a set of files with extension ".ms". These are CASA measurement set (MS) files. The data have already been converted to MS format from the native ALMA format using the CASA task {{importasdm}}. In addition to the data, we provide you with calibration tables containing system temperature (Tsys), water vapor radiometer (WVR), and antenna position information. For Early Science, these tables will either be pre-applied or supplied with the data.<br />
<br />
To begin, start CASA by typing<br />
<br />
<source lang="bash"><br />
<br />
casa<br />
<br />
</source><br />
<br />
Be sure that you are using the version indicated at the top of this page.<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 6.1. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
import casalith<br />
version = casalith.version_string()<br />
print("You are using {}".format(version))<br />
if (version < '6.1'):<br />
print ("YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE.")<br />
print ("PLEASE UPDATE IT BEFORE PROCEEDING.")<br />
else:<br />
print ("Your version of CASA is appropriate for this guide.")<br />
</source><br />
<br />
==Initial Inspection==<br />
<br />
First we will take stock of what we have. If you have not already done so, begin by reviewing the description of the observations here: [[AntennaeBand7]]. The 10 data sets each target either the Northern or the Southern Mosaic, as follows:<br />
<br />
Northern Mosaic:<br />
*uid___A002_X1ff7b0_Xb.ms<br />
*uid___A002_X207fe4_X3a.ms<br />
*uid___A002_X207fe4_X3b9.ms<br />
*uid___A002_X2181fb_X49.ms<br />
<br />
Southern Mosaic:<br />
*uid___A002_X1ff7b0_X1c8.ms<br />
*uid___A002_X207fe4_X1f7.ms<br />
*uid___A002_X207fe4_X4d7.ms<br />
*uid___A002_X215db8_X18.ms<br />
*uid___A002_X215db8_X1d5.ms<br />
*uid___A002_X215db8_X392.ms<br />
<br />
The first step is to get basic information about the data: targets observed, time range, spectral setup, and so on. We do this using the task {{listobs}}, which will output a detailed summary of each dataset. Enter the following commands into CASA:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Define a python list holding the names of all of our data sets<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
# Initialize user-input string. (for Python testing)<br />
dummy_string = ''<br />
<br />
# Loop over each element in the list and create summary file using listobs<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.listobs.txt')<br />
listobs(vis=asdm+'.ms', listfile=asdm+'.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note that after cutting and pasting a 'for' loop like this you often have to press return twice to execute. You may also want to take care to paste a line at a time if you are having trouble copy and pasting. Even better, you can use "cpaste" to paste blocks of code. To do so type "cpaste" at the CASA prompt, paste your commands, and then type "--" and hit return on the final (otherwise empty) line. This should look something like this:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
CASA <8>: cpaste<br />
Pasting code; enter '--' alone on the line to stop.<br />
:basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
: "uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
: "uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
: "uid___A002_X215db8_X392"]<br />
:<br />
:for asdm in basename_all:<br />
: print (asdm)<br />
:--<br />
uid___A002_X1ff7b0_Xb<br />
uid___A002_X207fe4_X3a<br />
uid___A002_X207fe4_X3b9<br />
uid___A002_X2181fb_X49<br />
uid___A002_X1ff7b0_X1c8<br />
uid___A002_X207fe4_X1f7<br />
uid___A002_X207fe4_X4d7<br />
uid___A002_X215db8_X18<br />
uid___A002_X215db8_X1d5<br />
uid___A002_X215db8_X392<br />
<br />
CASA <9>: <br />
<br />
</pre><br />
<br />
cpaste should be ''much'' more robust than copying-and-pasting directly into the shell but if you have trouble, just carefully paste one line at a time directly into CASA and hit return until the desired command executes.<br />
<br />
These commands define a python list called "basename_all", which contains the name of all 10 MS files. The "for" loop executes for each element in basename_all, calling listobs and directing the output to a file called, e.g., "uid___A002_X1ff7b0_Xb.listobs.txt" for the first measurement set. You can browse through the listobs output as you would normally look at a text file (use emacs, vi, or another editor). You can also send the output to the terminal from inside of CASA. To do so type:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
or<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('more uid___A002_X1ff7b0_Xb.listobs.txt')<br />
</source><br />
<br />
CASA knows a few basic shell commands like 'cat', 'ls', and 'rm' but for more complex commands you will need to run them inside 'os.system("command")'. For more information see http://casa.nrao.edu/ .<br />
<br />
Here is an example of the (abridged) output from {{listobs}} for the first dataset in the list, uid___A002_X1ff7b0_Xb.ms, which targets the Northern Mosaic. You would see this if you had specified '''verbose''' to be False in the listobs call:<br />
<br />
<pre style="background-color: #fffacd;"><br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_Xb.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA(11 antennas)<br />
Data records: 181357 Total integration time = 4931.71 seconds<br />
Observed from 28-May-2011/01:25:27.6 to 28-May-2011/02:47:39.3 (UTC)<br />
<br />
Fields: 26<br />
ID Code Name RA Decl Epoch SrcId nRows <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 39116 <br />
1 none Titan 12:42:43.94813 -01.43.38.3190 J2000 1 10626 <br />
2 none NGC4038 - Antennae *12:01:53.17008 -18.52.37.9200 J2000 2 4818 <br />
3 none NGC4038 - Antennae *12:01:51.90301 -18.51.49.9437 J2000 2 6435 <br />
4 none NGC4038 - Antennae *12:01:52.43086 -18.51.49.9437 J2000 2 6424 <br />
5 none NGC4038 - Antennae *12:01:52.95871 -18.51.49.9437 J2000 2 5478 <br />
6 none NGC4038 - Antennae *12:01:53.48656 -18.51.49.9436 J2000 2 6435 <br />
7 none NGC4038 - Antennae *12:01:54.01441 -18.51.49.9436 J2000 2 6446 <br />
8 none NGC4038 - Antennae *12:01:52.16693 -18.51.56.4319 J2000 2 6435 <br />
9 none NGC4038 - Antennae *12:01:52.69478 -18.51.56.4318 J2000 2 6424 <br />
10 none NGC4038 - Antennae *12:01:53.22263 -18.51.56.4318 J2000 2 6446 <br />
11 none NGC4038 - Antennae *12:01:53.75049 -18.51.56.4318 J2000 2 6446 <br />
12 none NGC4038 - Antennae *12:01:51.90301 -18.52.02.9201 J2000 2 6435 <br />
13 none NGC4038 - Antennae *12:01:52.43086 -18.52.02.9200 J2000 2 6424 <br />
14 none NGC4038 - Antennae *12:01:52.95871 -18.52.02.9200 J2000 2 4818 <br />
15 none NGC4038 - Antennae *12:01:53.48656 -18.52.02.9200 J2000 2 4829 <br />
16 none NGC4038 - Antennae *12:01:54.01441 -18.52.02.9199 J2000 2 4829 <br />
17 none NGC4038 - Antennae *12:01:52.16694 -18.52.09.4082 J2000 2 4829 <br />
18 none NGC4038 - Antennae *12:01:52.69479 -18.52.09.4082 J2000 2 4829 <br />
19 none NGC4038 - Antennae *12:01:53.22264 -18.52.09.4082 J2000 2 3872 <br />
20 none NGC4038 - Antennae *12:01:53.75049 -18.52.09.4081 J2000 2 4829 <br />
21 none NGC4038 - Antennae *12:01:51.90301 -18.52.15.8964 J2000 2 4829 <br />
22 none NGC4038 - Antennae *12:01:52.43087 -18.52.15.8964 J2000 2 4829 <br />
23 none NGC4038 - Antennae *12:01:52.95872 -18.52.15.8963 J2000 2 4818 <br />
24 none NGC4038 - Antennae *12:01:53.48657 -18.52.15.8963 J2000 2 4818 <br />
25 none NGC4038 - Antennae *12:01:54.01442 -18.52.15.8963 J2000 2 4840 <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 354971.074 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 354916.143 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11 'name'='station' <br />
ID= 0-3: 'DV02'='A015', 'DV04'='J505', 'DV06'='T704', 'DV07'='A004', <br />
ID= 4-7: 'DV08'='A072', 'DV09'='A008', 'DV10'='A009', 'DV11'='A016', <br />
ID= 8-10: 'PM01'='T702', 'PM02'='A017', 'PM03'='J504'<br />
================================================================================<br />
<br />
</pre><br />
<br />
And here is an extract from the full '''verbose''' {{listobs}} for uid___A002_X1ff7b0_X1c8.ms, which targets the Southern Mosaic (note that we have snipped out the record of individual scans):<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
================================================================================<br />
MeasurementSet Name: /lustre/naasc/almauser/AntennaeBand7/uid___A002_X1ff7b0_X1c8.ms MS Version 2<br />
================================================================================<br />
Observer: Unknown Project: T.B.D. <br />
Observation: ALMA<br />
Data records: 175615 Total integration time = 4927.1 seconds<br />
Observed from 28-May-2011/02:50:18.2 to 28-May-2011/04:12:25.3 (UTC)<br />
<br />
<snip><br />
<br />
Fields: 33<br />
ID Code Name RA Decl Epoch SrcId nVis <br />
0 none 3c279 12:56:11.16657 -05.47.21.5247 J2000 0 12232 <br />
1 none Titan 12:42:44.82765 -01.43.41.4224 J2000 1 10615 <br />
2 none 3c279 12:56:11.16600 -05.47.21.5250 J2000 2 27764 <br />
3 none Antennae 12:01:53.17008 -18.52.37.9200 J2000 3 4829 <br />
4 none Antennae 12:01:52.18699 -18.53.30.3952 J2000 3 3883 <br />
5 none Antennae 12:01:52.64413 -18.53.26.6494 J2000 3 3883 <br />
6 none Antennae 12:01:53.10127 -18.53.22.9035 J2000 3 3872 <br />
7 none Antennae 12:01:53.55841 -18.53.19.1577 J2000 3 4818 <br />
8 none Antennae 12:01:54.01554 -18.53.15.4119 J2000 3 4829 <br />
9 none Antennae 12:01:54.47268 -18.53.11.6661 J2000 3 4829 <br />
10 none Antennae 12:01:54.92982 -18.53.07.9203 J2000 3 3872 <br />
11 none Antennae 12:01:55.38696 -18.53.04.1744 J2000 3 3883 <br />
12 none Antennae 12:01:55.84409 -18.53.00.4286 J2000 3 4840 <br />
13 none Antennae 12:01:56.30123 -18.52.56.6828 J2000 3 4818 <br />
14 none Antennae 12:01:52.18700 -18.53.22.9033 J2000 3 4829 <br />
15 none Antennae 12:01:52.64414 -18.53.19.1575 J2000 3 4818 <br />
16 none Antennae 12:01:53.10128 -18.53.15.4116 J2000 3 4818 <br />
17 none Antennae 12:01:53.55842 -18.53.11.6658 J2000 3 4840 <br />
18 none Antennae 12:01:54.01555 -18.53.07.9200 J2000 3 3872 <br />
19 none Antennae 12:01:54.47269 -18.53.04.1742 J2000 3 4829 <br />
20 none Antennae 12:01:54.92983 -18.53.00.4284 J2000 3 4829 <br />
21 none Antennae 12:01:55.38697 -18.52.56.6825 J2000 3 4829 <br />
22 none Antennae 12:01:55.84410 -18.52.52.9367 J2000 3 4829 <br />
23 none Antennae 12:01:51.72988 -18.53.19.1572 J2000 3 4818 <br />
24 none Antennae 12:01:52.18702 -18.53.15.4114 J2000 3 4829 <br />
25 none Antennae 12:01:52.64415 -18.53.11.6656 J2000 3 4829 <br />
26 none Antennae 12:01:53.10129 -18.53.07.9197 J2000 3 2266 <br />
27 none Antennae 12:01:53.55843 -18.53.04.1739 J2000 3 2266 <br />
28 none Antennae 12:01:54.01557 -18.53.00.4281 J2000 3 3212 <br />
29 none Antennae 12:01:54.47270 -18.52.56.6823 J2000 3 3234 <br />
30 none Antennae 12:01:54.92984 -18.52.52.9365 J2000 3 3212 <br />
31 none Antennae 12:01:55.38698 -18.52.49.1906 J2000 3 2266 <br />
32 none Antennae 12:01:55.84411 -18.52.45.4448 J2000 3 3223 <br />
(nVis = Total number of time/baseline visibilities per field) <br />
Spectral Windows: (9 unique spectral windows and 2 unique polarization setups)<br />
SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs <br />
0 4 TOPO 184550 1500000 7500000 I <br />
1 3840 TOPO 344845.586 488.28125 1875000 XX YY <br />
2 1 TOPO 343908.086 1875000 1875000 XX YY <br />
3 3840 TOPO 356845.586 488.28125 1875000 XX YY <br />
4 1 TOPO 343908.086 1875000 1875000 XX YY <br />
5 128 TOPO 344900.518 15625 2000000 XX YY <br />
6 1 TOPO 343892.705 1796875 1796875 XX YY <br />
7 128 TOPO 356900.518 15625 2000000 XX YY <br />
8 1 TOPO 343892.705 1796875 1796875 XX YY <br />
Antennas: 11:<br />
ID Name Station Diam. Long. Lat. <br />
0 DV02 A015 12.0 m -067.45.15.3 -22.53.26.0 <br />
1 DV04 J505 12.0 m -067.45.18.0 -22.53.22.8 <br />
2 DV06 T704 12.0 m -067.45.16.2 -22.53.22.1 <br />
3 DV07 A004 12.0 m -067.45.15.9 -22.53.28.0 <br />
4 DV08 A072 12.0 m -067.45.12.6 -22.53.24.0 <br />
5 DV09 A008 12.0 m -067.45.15.4 -22.53.26.8 <br />
6 DV10 A009 12.0 m -067.45.16.1 -22.53.26.1 <br />
7 DV11 A016 12.0 m -067.45.16.4 -22.53.25.1 <br />
8 PM01 T702 12.0 m -067.45.18.6 -22.53.24.1 <br />
9 PM02 A017 12.0 m -067.45.15.9 -22.53.26.8 <br />
10 PM03 J504 12.0 m -067.45.17.0 -22.53.23.0 <br />
</pre><br />
<br />
This output shows that three sources were observed in each data set: 3c279, Titan, and the Antennae.<br />
<br />
* The '''Antennae''' are our science target. Note that the source name changes between the Northern Mosaic, where it is "NGC4038 - Antennae", and the Southern Mosaic, where it is just "Antennae". Also note that the source corresponds to a number of individual fields (see the Field ID column). These are the individual mosaic pointings. There are 23 for the Northern Mosaic and 29 for the Southern Mosaic.<br />
* '''Titan''' is observed once and will be used to set the absolute flux scale of the data.<br />
* '''3c279''' plays two roles: it will serve as our bandpass calibrator, to characterize the frequency response of the antennas, and because it is fairly close on the sky to the Antennae (18.6 degrees away) it will serve as our secondary calibrator (also referred to as the "phase calibrator" or "gain calibrator"), to track changes in the phase and amplitude response of the telescopes over time. Observations of 3c279 are interleaved with observations of the Antennae.<br />
<br />
The output also shows that the data contain many spectral windows. Using the labeling scheme in the listobs above these are:<br />
<br />
* '''spw 0''' targets ~185 GHz and holds water vapor radiometer data<br />
* '''spw 1''' and '''spw 3''' hold our science data. These are "Frequency Domain Mode" (FDM) data with small (0.49 MHz) channel width and wide (1.875 GHz) total bandwidth. As a result these have a lot of channels (3840). spw 1 holds the lower sideband (LSB) data and includes the CO(3-2) line. We will focus on these data. For the CO(3-2) line the channel width corresponds to 0.426 km/s and the bandwidth of spw 1 to 1634 km/s.<br />
* '''spw 2''' and '''spw 4''' hold frequency-averaged versions of spw 1 and 3 ("Channel 0" for those familiar with AIPS). These are used for some quick automated inspection. We will not use them here but we will carry out an equivalent inspection using spw 1.<br />
* '''spw 5''' and '''spw 7''' hold lower a resolution processing ("Time Domain Mode", TDM) of the data from the same part of the spectrum (baseband) as spws 1 and 3. These data have only 128 channels across 2 GHz bandwidth and so have a much coarser channel spacing than the FDM data. These were used to generate the calibration tables that we include in the tarball but will not otherwise appear in this guide.<br />
<br />
The final column of the listobs output in the logger (not shown above) gives the scan intent. Later we will use this information to flag the pointing scans and the hot and ambient load calibration scans.<br />
<br />
We'll now have a look at the configuration of the antennas used to take the data using the task {{plotants}} (<xr id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb.ANT_5.4.png"><br />
[[File:Uid_A002_X1ff7b0_Xb.ANT_6.1.png|200px|thumb|right|<caption> Position of antennas in dataset uid_A002_X1ff7b0_Xb obtained using task plotants. </caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Antenna configuration for : "+asdm)<br />
plotants(vis=asdm+'.ms', figfile=asdm+'.plotants.png')<br />
clearstat()<br />
dummy_string = input("Hit <Enter> to see the antenna configuration for the next data set.")<br />
</source> <br />
<br />
This will loop through all 10 data sets, show you the antenna position for each, and save that as a file named, e.g., "uid___A002_X1ff7b0_Xb.plotants.png" for the first data set. The "input" command asks CASA to wait for your input before proceeding. If you would prefer to just browse the .png files after the fact you can remove this. Notice that the antenna setup changes, but only slightly, over the course of the 10 data sets.<br />
<br />
==How to Deal With 10 Measurement Sets==<br />
<br />
It should already be clear from the initial inspection that dealing with 10 data sets at the same time can be a bit problematic. This is especially tricky in our case because the Antennae data contain two distinct sets of observations: the Northern and Southern Mosaics. The source name changes between these two scripts and there are different numbers of fields in the mosaic.<br />
<br />
''As a general rule one would reduce each individual observation separately or at the very least only group data observed in a uniform way and very close in time.'' <br />
<br />
Unfortunately, a CASA Guide stepping through the reduction for each of 10 data sets would quickly become unwieldy. Therefore we will use a few tricks to reduce the Antennae data in a kind of batch mode. You have already seen the first trick: we can define a python list holding the names of each data set and then loop over this list to execute the same command on each data set. For example:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print (asdm)<br />
</source><br />
<br />
You only need to define your list of MS files once per CASA session. Then "basename_all" will be a variable in the casapy shell. You can check if it exists by typing "print (basename_all)". In the interests of allowing you to easily exit and restart CASA and pick this guide up at any point we will redefine "basename_all" in each section of the guide. Feel free to skip this step if you've already defined it in your session.<br />
<br />
This page will step you through the reduction of the whole Antennae Band 7 SV data set using these 'for' loops. We will not be able to show every diagnostic plot but we give an example of each and the syntax to generate the rest. Also please be aware that even on a very fast machine this whole process can take a while, we are simply dealing with a lot of data.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
One potential "gotcha" is that the source name changes between the two data sets. Therefore at several points we will break apart our loop to iterate separately over the Northern and Southern Mosaics, where the source can be referred unambiguously. Another subtle point is that 3c279 appears with two distinct field IDs in the Southern Mosaic, but only one in the Northern Mosaic. We will largely avoid this by referring to the source by its name but if you tried to use field ID numbers and mingled the two data sets this could cause confusion.<br />
</pre><br />
<br />
==''A Priori'' Flagging==<br />
<br />
Even before we look in detail, we know that there are some data that we wish to exclude. We will start by flagging "shadowed" data where one antenna blocks the line of sight of another. We will also flag scans that were used to carry out pointing and atmospheric calibration, identified by their scan intent. Finally, we'll flag the autocorrelation data (the correlation of the signal from an antenna with itself) as we are only interested in cross-correlation data to make an interferometric image.<br />
<br />
Start by defining our list of MS files:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
You may want to reset the flagging if you have tried this step before and are starting over though this is not necessary on your first time through. Do so using {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Resetting flags for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='unflag', flagbackup=False)<br />
</source><br />
<br />
Then flag shadowed data using the command {{flagdata}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging shadowed data for "+asdm)<br />
flagdata(vis=asdm+'.ms',mode = 'shadow', flagbackup = False)<br />
</source><br />
<br />
In the {{flagdata}} task we choose:<br />
<br />
* '''vis''' = asdm+'.ms' : each measurement set<br />
* '''mode''' = 'shadow': flag shadowed data<br />
* '''flagbackup''' = False: Do not automatically back up the flag files. We will save all of the ''a priori'' flags together using {{flagmanager}} at the end of this subsection and save some space and time.<br />
<br />
The relevant calibration information has already been extracted from the pointing and atmospheric scans and we will not need them below. Now flag the pointing scans using {{flagdata}} in 'manualflag' mode and selecting on 'intent':<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging calibration scans for "+asdm)<br />
flagdata(vis=asdm+'.ms', mode='manual', intent='*POINTING*', flagbackup = False)<br />
</source><br />
<br />
Note that because the atmospheric calibration scans contain only TDM spectral windows, they will be removed automatically when we separate out the FDM data below.<br />
<br />
Now flag the autocorrelation data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Flagging autocorrelation data for "+asdm)<br />
flagdata(vis=asdm+'.ms',autocorr=True,flagbackup=False)<br />
</source><br />
<br />
Finally store the current flags information using {{flagmanager}}: <br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Backing up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'save', versionname = 'Apriori')<br />
</source><br />
<br />
Where '''versionname''' is just the name we assign to the current flagging state in the data. We can now roll back the flags to match the current version, called 'Apriori', whenever we want. There is no reason to do this now, but the syntax would be:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
print ("Restoring up 'a priori' flags for "+asdm)<br />
flagmanager(vis = asdm+'.ms', mode = 'restore', versionname = 'Apriori')<br />
</source><br />
<br />
<br />
It would have been possible to set {{flagdata}} to '''flagbackup'''=True so that it stores the flags at each of the flagging step automatically, but this way it is a bit more efficient with regard to time and disk space. More important, lumping all the ''a priori'' flagging together gives us a natural point to roll back to if we get in trouble.<br />
<br />
<br />
The flagmanager task will also allow you to view the saved flagging versions,<br />
including those created by running flagdata with flagbackup=True.<br />
<br />
For example try <br />
<br />
<source lang="python"><br />
# In CASA<br />
flagmanager(vis='uid___A002_X2181fb_X49.ms', mode='list')<br />
</source><br />
<br />
The output in the logger should list the Apriori flagging that we have applied.<br />
It will also indicate versions associated with any flagdata command where you<br />
did not set flagbackup=False. Other tasks, for example applycal, will also create<br />
flag version tables.<br />
<br />
==Create and Apply Tsys, WVR, and Antenna Position Calibration Tables==<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
</source><br />
<br />
===Tsys===<br />
<br />
The Tsys calibration gives a first-order correction for the atmospheric opacity as a function of time and frequency and associates weights with each visibility that persists through imaging.<br />
<br />
Use gencal to create the Tsys calibration tables from the spectral windows with CALIBRATE_ATMOSPHERE intents in listobs (i.e. the TDM spectral windows with 128 channels), these are spectral windows 5 and 7.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#Removing existing Tsys information<br />
os.system('rm -rf *tdm.tsys')<br />
for asdm in basename_all:<br />
print ("Creating TDM Tsys Table for "+asdm)<br />
gencal(vis=asdm+'.ms',caltable=asdm+'.tdm.tsys',spw='5,7',caltype='tsys')<br />
</source><br />
<br />
Later in the applycal stage this TDM Tsys table will be interpolated to the FDM (3840 channels per spw) science spectral windows 1 and 3.<br />
<br />
Next we inspect the Tsys tables for the spectral window '''spw''' = 5 with the task {{plotms}}. In previous CASA versions, we used {{plotcal}} for this task, but most of '''plotcal''''s functionality is now included in {{plotms}}, and '''plotcal''' will be deprecated in a future CASA release. We want to check that Tsys data have reasonable values and identify any unexpected features as a function of either time or frequency. To get an idea of sensible Tsys under average atmospheric observations consult the ALMA sensitivity calculator, accessible from http://www.almascience.org (via the "Documents & Tools" link).<br />
<br />
We start by plotting the Tsys for all the antennas and polarizations (XX and YY) as a function of time for each. <!--Here and throughout we focus on spw 1, which contains CO(3-2): --><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
Note that right now, plotms can't select individual channels when plotting caltables (as was possible with plotcal). In addition, when iteraxis is set, plotms appends the axes being iterated over to the output filename specified in plotfile; this can make for rather unwieldy filenames (particularly when iteraxis='antenna'!) but is useful for the ALMA pipeline. <br />
</pre><br />
<br />
<figure id="Xb.Tsys_vs_time.page1.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page1.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 8 antennas. Note the high y-axis values for DV04. The two different colors indicate the two polarizations (XX and YY).</caption>]]<br />
</figure><br />
<figure id="Xb.Tsys_vs_time.page2.6.1.png"><br />
[[File:Xb.Tsys_vs_time.page2.6.1.png|200px|thumb|right|<caption> Tsys vs. time plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting Tsys vs. time for "+asdm)<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='0~7',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page1.png',overwrite=True)<br />
#dummy_string = input("First eight antennas for "+asdm+" . Hit <Enter> to continue.")<br />
plotms(vis=asdm+'.tdm.tsys',<br />
xaxis='time',yaxis='tsys',coloraxis='corr',<br />
spw='5:50~50',<br />
gridrows=4,gridcols=2,<br />
antenna='8~15',iteraxis='antenna',<br />
plotfile=asdm+'.tsys_vs_time.page2.png',overwrite=True)<br />
#dummy_string = input("Remaining antennas for "+asdm+" . Hit <Enter> to continue.")<br />
</source><br />
<br />
This sequence loops over all of our files and plots Tsys as a function of time for channel 50 in spectral window 5. In the call to {{plotms}}:<br />
<br />
* '''gridrows'''=4 and '''gridcols'''=2 sets up a 4 x 2 panel grid. <br />
* '''iteraxis'''='antenna' tells {{plotms}} to make a separate plot for each antenna.<br />
* '''spw'''='5:50~50' selects spw '5' channel 50-50. This allows us to cleanly separate time variations from frequency variations. '''Note that this is a functionality in plotcal but not yet in {{plotms}}, and plotms is actually showing all channels from spw 5 at this time.'''<br />
<br />
Because 8 panels (2 panels for each antenna - LSB and USB) is not enough to show all antennas on one page, there are two {{plotms}} calls: one for the first 8 antennas ('''antenna'''='0~7'), and then for the remaining antennas ('''antenna'''='8~15').<br />
<br />
The 'input' commands will wait for you to hit Enter before issuing the next plot command. In the example above these are commented out (the leading "#" means that CASA will ignore them). If you would like to interactively cycle through the plots, uncomment them by removing the "#". Otherwise, the '''plotfile''' parameter directs the output to .png files for later inspection. The easiest way to look at the 20 plots produced here is to simply inspect the .png files using your favorite viewer. As noted above, here plotms is adding the antenna information to the filenames because we set '''iteraxis''' = 'antenna', so check your directory for the impressively long filenames to view them. <br />
<br />
The Tsys values in <xr id="Xb.Tsys_vs_time.page1.6.1.png"/> and <xr id="Xb.Tsys_vs_time.page2.6.1.png"/> look reliable, with typical values ~150 K except for some large values of Tsys at ~400 and 500 K for DV04. We will flag the data for that antenna later. <br />
<br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV02.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). First 4 antennas. Note the high y-axis values for DV04 and the mesospheric line near 343.2 GHz.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.DV08.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Next 4 antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"><br />
[[File:uid___A002_X1ff7b0_Xb.tdm.tsys.*Antennae*.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid_A002_X1ff7b0_Xb (northern mosaic). Remaining antennas.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"><br />
[[File:uid___A002_X215db8_X392.tdm.tsys.3c279.PM01.spw05_6.1.png|200px|thumb|right|<caption> Tsys vs. frequency plot for uid___A002_X215db8_X392. Note the pathological behavior for DV12.</caption>]]<br />
</figure><br />
<br />
We will also want to look at Tsys as a function of frequency. <br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
os.system('rm -rf cal_plots/Tsys_plots/'+asdm+'.tdm.tsys*')<br />
tsysfields=['3c279','Titan','*Antennae*']<br />
caltable=asdm+'.tdm.tsys'<br />
for field in tsysfields:<br />
plotbandpass(caltable=caltable,yaxis='amp',field=field,xaxis='freq',<br />
showatm=True,overlay='time',<br />
figfile='cal_plots/Tsys_plots/'+caltable+'.'+field,<br />
buildpdf=False,interactive=False,chanrange='8~120',subplot=42)<br />
</source><br />
<br />
You will see the following statement in the logger, but this is fine: <br />
<br />
<pre style="background-color: #fffacd;"><br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
</pre><br />
<br />
Now have a look at the Tsys vs. frequency plots or see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/>, <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV08.spw5.CASA3_4.png"/>, and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/> for examples on the first data set. You can see the effect of a close pair of atmospheric ozone absorption lines at about 343.2 GHz that makes Tsys larger near that frequency in all antennas. Applying the Tsys calibration tables will minimize the contribution of these atmospheric lines. Again DV04 stands out with its very high Tsys. Although not present in the first data sets, Antenna DV12 exhibits periodic spikes in Tsys vs. frequency for one polarization (see <xr id="Uid___A002_X215db8_X392.tdm.tsys.3c279.DV11.spw5.CASA3_4.png"/> for an example from a later data set). It may or may not be possible to calibrate that behavior out. We will make a note to look carefully at DV12 further on in the calibration process.<br />
<br />
===WVR===<br />
The WVR calibration uses observations of the wings of the 183 GHz atmospheric water line to correct for phase variations as a function of time. As noted in the tsys section, this run of gencal will append to existing WVR produced tables. To avoid this, preexisting wvrgcal data is removed. <br />
<source lang="python"><br />
#In CASA<br />
#Removing existing WVR information<br />
os.system('rm -rf *.wvrgcal')<br />
for asdm in basename_all:<br />
wvrgcal(vis=asdm+'.ms',caltable=asdm+'.wvrgcal',toffset=-1)<br />
</source><br />
<br />
===Antenna Positions===<br />
<br />
In general, the most appropriate antenna positions for the dataset will be determined and updated if needed during QA2. If the antenna positions need to be updated after QA2, we inform the PIs of the affected datasets and provide instructions on how to update the antenna positions. For the data in this guide, we do need to update the antenna positions. <br />
<br />
The antenna position table reflects refinements in the measured positions of the antennas from those stored in the data. {{gencal}} will now be used put antenna position data into each observation. Again, {{gencal}} will merely append to existing antenna position data, ruining any subsequent results. We start by removing any existing antenna position refinements, followed by defining the antenna names, then their refinements (both as arrays), finally running {{gencal}} to create the information CASA can refer to for antenna positions.<br />
<br />
<source lang="python"><br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_Xb.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:21]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3a.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X3b9.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X2181fb_X49.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV01,DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
-0.00004, 0.00026, 0.00019, #DV01-A137<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X1ff7b0_X1c8.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV06,DV07,DV08,DV09,DV10,DV11,PM01,PM02,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00034, 0.00092, 0.00027, #PM02-A017 Before July 1<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X1f7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X207fe4_X4d7.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV11,DV12,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X18.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:22]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X1d5.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
<br />
#In CASA<br />
#The measurement set we are refining the antenna positions for<br />
data='uid___A002_X215db8_X392.ms'<br />
#Removing existing antenna refinements<br />
os.system('rm -rf '+data[0:23]+'.antpos')<br />
antenna='DV02,DV04,DV05,DV06,DV07,DV08,DV09,DV10,DV11,DV12,DV13,PM01,PM03'<br />
parameter = [<br />
0.00000, 0.00000, 0.00000, #DV02-A015<br />
-0.00004, 0.00059, 0.00024, #DV04-J505<br />
-0.00019,-0.00003, 0.00035, #DV05-A067<br />
-0.00027, 0.00033, 0.00022, #DV06-T704<br />
0.00006, 0.00057, 0.00032, #DV07-A004<br />
-0.00027, 0.00025,-0.00003, #DV08-A072<br />
-0.00037, 0.00025, 0.00003, #DV09-A008<br />
-0.00056, 0.00028, 0.00026, #DV10-A009<br />
-0.00028, 0.00024, 0.00011, #DV11-A016<br />
-0.00018, 0.00010,-0.00014, #DV12-A011<br />
0.00009, 0.00033, 0.00023, #DV13-A075<br />
-0.00017, 0.00013, 0.00030, #PM01-T702<br />
-0.00007, 0.00034, -0.00004] #PM03-J504 <br />
gencal(vis=data,caltable='%s.antpos'%(data.split('.')[0]),caltype='antpos',<br />
antenna=antenna,parameter=parameter)<br />
</source><br />
<br />
===Applycal===<br />
<br />
We are now ready to apply the Tsys and the WVR calibration tables to the data with {{applycal}}, which reads the specified gain calibration tables, applies them to the (raw) data column, and writes the calibrated results into the corrected column. Again, we loop through all the datasets. It is important to only apply Tsys and WVR corrections obtained close in time to the data being corrected, so in addition to looping over data sets we define the list of unique source names and loop over these. Then by setting '''gainfield''' and '''field''' to the same value we ensure that Tsys and WVR calibrations are only applied to the source for which they are measured. Because the source has a different name in the Northern Mosaic and the Southern Mosaic, we will carry out two loops. We will only correct '''spw''' 1 and 3, our science windows, because we will drop the other data in a moment.<br />
<br />
The applycal task now has much more flexibility for interpolating and applying calibrations derived in one spectral window to another, even if they do not share the same spectral shape (number of channels and channel width). This new functionality is used below to interpolate the TDM (128 channel) Tsys measurements to the FDM (3840 channel) spectral windows. This is controlled through the spectral window mapping parameter *spwmap*. Because this can be a bit confusing, we've written a "helper" function that will tell you what you should put for the Tsys calibration table part of spwmap. We only need to run it on one of the datasets because they are all the same in this regard<br />
<br />
<source lang="python"><br />
# In CASA<br />
from casarecipes.almahelpers import tsysspwmap<br />
tsysspwmap(vis='uid___A002_X207fe4_X3a.ms',tsystable='uid___A002_X207fe4_X3a.tdm.tsys')<br />
</source><br />
<br />
This will print to your screen: [0, 5, 5, 7, 5, 5, 5, 7]. Recall that the TDM spectral windows are spw=5 and 7 and the FDM spectral windows are 1 and 3. This spwmap tells applycal to use the Tsys information in spectral window 5 for spectral window 1; and to use the information in spectral window 7 for spectral window 3. Beyond that, it is only important that there are placeholders for the other spectral windows, its also useful to note that you need not give placeholders for spectral window ids larger than the largest spectral window you need to use, in this case 7.<br />
<br />
You will also need to put in placeholders for other tables that you give the gaintables. So if the Tsys table is 2nd in the list, spwmap=[[],[0,5,5,7,5,5,5,7],[]]<br />
<br />
Now run the applycal commands.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# A new list of file names that contain only data from the Northern Mosaic<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names_north = ['Titan','3c279','NGC*']<br />
<br />
for asdm in basename_north:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_north:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=['',field,field],<br />
interp=['','linear,spline','nearest'], <br />
gaintable=[asdm+'.antpos',asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]],<br />
flagbackup=False, calwt=True)<br />
<br />
# A new list of file names that contain only data from the Southern Mosaic<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names_south = ['Titan','3c279','Ant*']<br />
<br />
for asdm in basename_south:<br />
print ("Apply Tsys, WVR, and Antenna Position calibrations to "+asdm)<br />
for field in field_names_south:<br />
applycal(vis=asdm+".ms", spw='1,3', <br />
field=field, gainfield=["",field,field],<br />
interp=['','linear,spline','nearest'],<br />
gaintable=[asdm+".antpos",asdm+'.tdm.tsys',asdm+'.wvrgcal'],<br />
spwmap=[[],[0, 5, 5, 7, 5, 5, 5, 7],[]], <br />
flagbackup=False, calwt=True)<br />
</source><br />
<br />
where:<br />
<br />
*'''field''': the field ''to'' which we will apply the calibration, <br />
*'''gainfield''': the field ''from'' which we wish to take the calibration table<br />
*'''interp''' = 'nearest' : apply the nearest solution from the calibration table rather than interpolating.<br />
<br />
As you browse through the whole data set, you will probably note some problems along the same lines as the DV04 issue we saw above. We'll apply these as additional data flagging in just a moment.<br />
<br />
==Inspect Data==<br />
We are not quite done with the original ".ms" data sets yet. Before going further it will be useful to use {{plotms}} to show the effects of applying the calibration. In the process we'll take a quick look at each antenna and search for pathologies in the data.<br />
<br />
For this basic inspection, we want to compare the phase and amplitude as a function of frequency and time in the DATA and CORRECTED columns of each measurement set. The CORRECTED column has had the Tsys and WVR calibrations applied and so we expect lower phase scatter and flatter amplitude response as a function of time and frequency. We are looking for antenna-based issues, so cycling through a set of baselines that includes each antenna once will be a good start. We'll focus these plots on the phase+bandpass calibrator, 3c279, and on baselines that include antenna DV11, which we will make our reference antenna in just a bit.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
Each CASA Measurement Set has up to three "columns" of data: DATA, CORRECTED, and MODEL (though it is possible<br />
for a MS to hold only a DATA column if it has not been processed at all). <br />
<br />
A column entry exists for each data point (baseline, frequency, time). <br />
<br />
The DATA column holds the current raw data, though using split as we just did we can change the definition of<br />
"raw" data. <br />
<br />
The CORRECTED column holds the result of applying one or more calibration tables (e.g., via applycal) to the<br />
DATA column and so represents a corrected version of the DATA column. <br />
<br />
The MODEL column is now deprecated (though it is still possible to use it by explicitly setting usescratch=True).<br />
Instead, the model is stored in the header of the ms. This is a great step forward in terms of saving space and time <br />
to create scratch columns <br />
<br />
To get an intuitive feel for the columns you may wish to explore using plotms (which can plot different data <br />
columns, as seen below) or the browsetable task.<br />
<br />
</pre><br />
<br />
<figure id="plotms_amp_vs_freq_example-data.png"><br />
[[File:plotms_amp_vs_freq_example-data_6.1.png|200px|thumb|right|<caption> Example of Amplitude vs. Frequency before correction for the 3c 279.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_example-corr.png"><br />
[[File:plotms_amp_vs_freq_example-corr_6.1.png|200px|thumb|right|<caption> Same baseline as Figure 8 but now after correction using WVR and Tsys calibrations.</caption>]]<br />
</figure><br />
<br />
First, we plot amplitude as a function of frequency for 3c279. We start by plotting the DATA column, set color to indicate the two correlations (i.e., the XX and YY polarizations), and ask plotms to iterate over baseline. By setting '''antenna''' to 'DV11&*' we select only baselines that include DV11. We ask plotms to average all data over a very long timescale, '''avgtime''' = 1e8 seconds ~ 3 years or much longer than the time spanned by the whole data set. By setting '''avgscan''' = True we allow {{plotms}} to average across scan boundaries. The result is a plot of average amplitude per channel vs. frequency.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
asdm=basename_all[0]<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='amp',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Notice the green arrows along the bottom of the {{plotms}} window. We asked {{plotms}} to iterate over baseline. As you click the arrows, the plot will rotate from baseline to baseline, always with DV11 so that each antenna shows up once. To see the effect of the calibration, go to the "Axes" tab along the left of the {{plotms}} window and pull down the Data Column menu under the Y Axis. Set this from DATA to CORRECTED and you should see the effects of the calibration. You may need to ensure that the "Force Reload" box is checked before clicking "Plot" (both buttons lie at the bottom of the panel). For the most part things get better (flatter), but as we noted before DV04 is problematic.<br />
<br />
<figure id="plotms_amp_vs_time_north.png"><br />
[[File:plotms_amp_vs_time_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_time_south.png"><br />
[[File:plotms_amp_vs_time_south_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. time for a southern mosaic data set.</caption>]]<br />
</figure><br />
<br />
You can now make analogous calls to examine the phase vs. frequency, amplitude vs. time, and phase vs. time.<br />
<br />
<source lang="python"><br />
# In CASA<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='frequency', yaxis='phase',<br />
selectdata=True, spw='1', <br />
avgtime='1e8',avgscan=True,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='amp',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
<br />
plotms(vis=asdm+'.ms', <br />
field='3c279',<br />
xaxis='time', yaxis='phase',<br />
selectdata=True, spw='1:1200~1299', <br />
avgchannel='100',avgscan=False,<br />
coloraxis='corr',<br />
iteraxis='baseline',<br />
antenna='DV11&*',<br />
ydatacolumn='data', <br />
showgui = True)<br />
</source><br />
<br />
Where:<br />
<br />
* '''spw''' is set to cover only channels 1200~1300 for the time plots in order to isolate time dependent variations from frequency-dependent behavior. Those 101 channels represent only a small part of the total spw 1 bandpass.<br />
* '''avgchannel''' set to a large number causes the plots of phase and amplitude vs. time to average data at all frequencies into a single point for each measurement.<br />
* '''coloraxis''' corr sets the colors to correspond to the two polarizations of the data.<br />
<br />
In each case, you will want to examine each baseline, alternating between the DATA and CORRECTED columns.<br />
<br />
This is a lot of data inspection and that's only for one of 10 data sets! You can iterate across the data by hand, updating "asdm" to refer to each data set in order and cycling between baselines and DATA/CORRECTED. It is also possible to script CASA to show you the key plots in succession (see the next block down). However you approach the infrastructure, you are looking for:<br />
<br />
* Improved scatter and lower variability in phase and amplitude vs. frequency and time. This indicates that the WVR and Tsys calibrations helped. <br />
* Sudden jumps in phase or amplitude as a function of either time or frequency. These may indicate problems with the antenna during that observation.<br />
* Large gradients, especially full wraps, in phase as a function of frequency. This may indicate a problem in the delays, the signal path length to the telescopes.<br />
* Unusual magnitude, scatter, or patterns in any plot - though this may be better explored using plots that show all data together, which we'll make in a moment.<br />
* Missing data. For example, if the phase calibrator drops out for a period of time we will not be able to calibrate and will need to flag the data.<br />
<br />
As you look through, note individual potentially problematic antennas. If ''all'' antennas in a data set appear problematic it may be that your "reference" antenna, DV11 in the example above, is the source of the problem. In this case swap this reference antenna for another and see whether the problem is isolated to your original reference antenna.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
<br />
A brief aside on structure:<br />
<br />
This section (Data Inspection) and the next (Apply Flags) are closely linked. We will present them as two<br />
separate steps. The idea here is that you look through your data, note problems, and then write commands to<br />
flag problematic data. This mimics one approach to writing data reduction scripts for CASA, where you will<br />
group all flagging together into one convenient place. Other CASA guides take a different approach, interleaving <br />
flagging and plotting. There is no "right" answer here. Find an approach to data inspection that works for you.<br />
<br />
</pre><br />
<br />
If you do wish to semi-automate the plot generation, the following sequence will cycle between data and corrected plots for each data set in turn. Type "stop" at any input call to break out.<br />
<br />
<!--<br />
'''Note:''' In loops like this involving {{plotms}}, hitting enter before the last dataset completes loading may cause {{plotms}} to stop refreshing the plot window at each step, or cause the window to disappear altogether. This will be fixed in an upcoming CASA release. Right now, you may need to exit CASA and restart to bring up the {{plotms}} window again, but you should be able to continue in the script where you left off.<br />
--><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
user_input = ""<br />
for asdm in basename_all:<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
# Extract antenna list for this data set.<br />
tb.open(asdm+'.ms/ANTENNA', nomodify=True)<br />
ants = tb.getcol('NAME')<br />
tb.close<br />
# Define the reference antenna to make baselines with<br />
ref_ant = 'DV11'<br />
# Loop over antennas<br />
for ant in ants:<br />
# Check if the user wants to stop<br />
if user_input == "stop":<br />
break<br />
# Skip correlation of reference antenna with itself (autocorrelations are flagged anyhow) <br />
if ant == ref_ant:<br />
continue<br />
# Define the baseline with the reference antenna for current antenna<br />
ant_str = ref_ant+'&'+ant<br />
print ("Showing baseline "+ant_str+" for data set "+asdm)<br />
print ("Use this to inspect effect of applying wvrcal and Tsys calibrations.")<br />
# Loop over phase and amplitude as axes<br />
for y_axis in ["amp", "phase"]:<br />
# Make 'before' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for frequency x-axis<br />
print ("... "+y_axis+" vs. frequency for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1', field='3c279',<br />
antenna=ant_str, xaxis="frequency", yaxis=y_axis,<br />
avgtime="1e8", avgscan=True, coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'before' plot for time x-axis<br />
print ("... "+y_axis+" vs. time for DATA:") <br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="data", showgui = True)<br />
user_input = input("Hit <ENTER> to see CORRECTED data [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
# Make 'after' plot for time y-axis<br />
print ("... "+y_axis+" vs. time for CORRECTED:")<br />
plotms(vis=asdm+'.ms', spw='1:1200~1299', field='3c279',<br />
antenna=ant_str, xaxis="time", yaxis=y_axis,<br />
avgchannel="100", coloraxis="corr",<br />
ydatacolumn="corrected", showgui = True)<br />
user_input = input("Hit <ENTER> to proceed to next plot [type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<figure id="plotms_amp_vs_uvdist_north.png"><br />
[[File:plotms_amp_vs_uvdist_north_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. uv-distance for 3c279 in the first northern mosaic data set.</caption>]]<br />
</figure><br />
<br />
<figure id="plotms_amp_vs_freq_3c279.png"><br />
[[File:plotms_amp_vs_freq_3c279_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for 3c279 in the second northern mosaic data set.</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Titan.png"><br />
[[File:plotms_amp_vs_freq_Titan_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for Titan in the second northern mosaic data set. Note the strong line (this is CO 3-2)!</caption>]]<br />
</figure><br />
<figure id="plotms_amp_vs_freq_Antennae.png"><br />
[[File:plotms_amp_vs_freq_Antennae_6.1.png|200px|thumb|right|<caption> Example of amplitude vs. frequency for the Antennae in the second northern mosaic data set. The CO(3-2) line is visible.</caption>]]<br />
</figure><br />
<br />
A detailed explanation of the procedure is a bit outside the scope of this guide (for more on python see http://www.python.org/ and for more on the CASA toolkit see http://casa.nrao.edu/), but the basic process is to loop over each data set, baseline with the reference antenna (here DV11), and y-axis of interest (phase or amplitude) then plot the effect of the calibration vs. frequency and time for each combination. Running this to step through the data will give you about 200 "before and after" plots from which you could note a subset of problematic cases to be followed up by hand. Many other strategies to inspect the data are also viable.<br />
<br />
With the Tsys and WVR calibrations applied successfully and the ''a priori'' flagging taken care of we will now {{split}} out the corrected data. We will keep only the corrected data, specified via '''datacolumn''', and only spectral window 1, which contains the FDM (high spectral resolution) observations of the CO(3-2) line. Setting '''keepflags'''=False tells {{split}} not to carry over any fully flagged rows from the original data set to the new MS. We give the new MS files the extension ".wvrtsys.ms" to indicate that they have been corrected for WVR and Tsys effects. Because split will not overwrite existing files, we remove any previous versions of the new MS before beginning.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm -rf '+asdm+'.wvrtsys.ms')<br />
print ("Splitting out corrected data for "+asdm)<br />
split(vis=asdm+'.ms', outputvis=asdm+'.wvrtsys.ms', <br />
datacolumn='corrected', spw='1', keepflags=False)<br />
</source><br />
<br />
Be patient, {{split}} may take awhile. The WVR and Tsys-corrected data now sit in the DATA column of the new measurement sets, which have only one spectral window (now labeled spectral window 0 though it was spectral window 1 in the original data). You may wish to run {{listobs}} to illustrate the changes:<br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
os.system('rm '+asdm+'.wvrtsys.listobs.txt')<br />
listobs(vis=asdm+'.wvrtsys.ms', listfile=asdm+'.wvrtsys.listobs.txt', verbose=True)<br />
</source><br />
<br />
Note the new spectral window information:<br />
<br />
<pre style="background-color: #fffacd;"><br />
<br />
2011-08-05 01:07:08 INFO listobs Spectral Windows: (1 unique spectral windows and 1 unique polarization setups)<br />
2011-08-05 01:07:08 INFO listobs SpwID #Chans Frame Ch1(MHz) ChanWid(kHz)TotBW(kHz) Ref(MHz) Corrs <br />
2011-08-05 01:07:08 INFO listobs 0 3840 TOPO 344845.586 488.28125 1875000 344908.33 XX YY <br />
<br />
</pre><br />
<br />
<br />
Next we will do a bit more inspection using {{plotms}} to look at whole data sets. This will help us identify missing data or look for egregious outliers.<br />
<br />
First we plot amplitude versus time (see <xr id="plotms_amp_vs_time_north.png"/> and <xr id="plotms_amp_vs_time_south.png"/>), averaging over all channels (by setting '''avgchannel''' to the very large value 10,000). We colorize by field so that scans on Titan are red, the bandpass and phase calibrator 3c279 is black (and orange in the Southern Mosaic where it has two field IDs), and the Antennae mosaic appears as a range of colors (one per pointing).<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='amp', <br />
avgchannel='3840',coloraxis='field', showgui = True)<br />
user_input = input("Examining amplitude vs. time for "+asdm+" . Hit <Enter> to proceed.[type 'stop'+<Enter> to break out].")<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
Here look for:<br />
<br />
* Missing data. The source needs to be flanked by phase calibrator scans, if those are missing for any reason we need to flag the appropriate time range.<br />
* Dramatic outliers. Does the source suddenly get very bright or the otherwise bright calibrator appear anomalously faint for a brief time? This likely indicates problematic data that should be identified and flagged. You can use the "select" (box with green plus along the bottom row in plotms) and "locate" (magnifying glass) buttons in {{plotms}} to isolate and identify problem data (it will print to the log).<br />
* Smooth variation with time. A sudden jump may indicate a problem and often the safest approach is to flag data near a discontinuity.<br />
<br />
Look through the amplitudes vs. time for each data set (remember that we've already examined the phases vs. time and amplitude vs. time for individual baselines above).<br />
<br />
There are two other very useful "averaging" plots worth making. First, we plot amplitude as a function of u-v distance (projected antenna separation). Discontinuities and spikes in this plot are often from non-astrophysical sources. In the phase analog to the plot, the effects of atmospheric decorrelation can be assessed from increased scatter at longer u-v distances. While using the moon Titan as our flux calibrator, we may want to watch for flaring amplitudes at short u-v distances. These may indicate that Saturn is contaminating our beam. For a perfect, bright point source, we expect flat amplitudes as a function of u-v distance at the source amplitudes. <xr id="plotms_amp_vs_uvdist_north.png"/> shows an example of this plot, generated via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='3c279',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. UV Distance for 3c279 for "+asdm+" . Hit <Enter> to proceed.")<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field='Titan',<br />
xaxis='uvdist', yaxis='amp', <br />
avgchannel='3840',coloraxis='corr', showgui = True)<br />
user_input = input("Examining amplitude vs. UV Distance for Titan for "+asdm+" . Hit <Enter> to proceed [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if user_input == "stop":<br />
break<br />
</source><br />
<br />
<br />
<br />
It can also be useful to examine the average amplitude as a function of frequency for each target. This allows one to check for lingering atmospheric effects, unexpected line emission or absorption in the calibrators, or decreased sensitivity due to "roll-off" of the telescope sensitivity at the band edges. These plots are created by the sequence of commands below, where we have broken up the script to loop separately over the Northern and Southern Mosaics to reflect the different source names.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
field_names = ["3c279","Titan","NGC*"]<br />
<br />
for asdm in basename_north:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+". Hit <Enter> to proceed.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
field_names = ["3c279","Titan","Ant*"]<br />
<br />
for asdm in basename_south:<br />
for field in field_names:<br />
plotms(vis=asdm+'.wvrtsys.ms', <br />
field=field,<br />
xaxis='frequency', yaxis='amp', <br />
avgtime='1e8',avgscan=True, coloraxis='corr', showgui = True)<br />
dummy_string = input("Examining amplitude vs. frequency for "+field+" in "+asdm+" . Hit <Enter> to proceed.")<br />
<br />
</source><br />
<br />
<br />
For this command notice that we can see the CO(3-2) line in the Antennae even before calibration (see <xr id="plotms_amp_vs_freq_Antennae.png"/>) and that Titan also shows evidence of a strong line (also <xr id="plotms_amp_vs_freq_Titan.png"/>)! This will need to be flagged before we can use Titan to calibrate the flux scale of our data.<br />
<br />
This suite of plots (along with the earlier inspection of the Tsys tables) gives us the tools we need to identify problematic data through the data sets. We use this to generate a set of inspection-driven {{flagdata}} commands for each data set. We apply these before the bandpass and gain calibration.<br />
<br />
==Apply Flagging==<br />
Based on this inspection and the other plots we have made, we now flag problematic portions of the data. We break up the flags by reason for flagging in order to illustrate the process. As you reduce your own data it may be more efficient to group flags by data set and make use of the flagcmd command. Except for the "post-calibration" flagging, the inspection plots that we just looked through have already revealed all of the problems that we flag. We structure the guide so that the flagging is grouped in one place.<br />
<br />
As before, we may wish to reset our flags before beginning (particularly if one iterates this process) via:<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms',mode='unflag', flagbackup = False)<br />
</source><br />
<br />
Remember that we dropped the flagged data when splitting out after the WVR and Tsys calibration, so this should not undo your "A Priori" flagging of shadowed data, autocorrelations, etc.. In any case this unflagging step is not necessary during the first iteration.<br />
<br />
* '''Edge Channels'''<br />
<br />
ALMA's sensitivity decreases near the edge of the baseband and it is often useful to check for a 'roll-off' in sensitivity near the edge of the band. This will appear as a downturn in amplitude as a function of channel near the edge of the window in the uncalibrated data, as a flaring due to increased noise at the spw edges in the calibrated data. It will also be visible in the amplitude part of the bandpass calibration table. Because our FDM spw does not cover the full baseband, we do not see a strong roll off in our data (see <xr id="amp_vs_channel_example.png"/>), where there is only a mild hint of a roll-off at the high end) but we do flag a (very) few channels at the high and low-frequency edge of the data set to be safe.<br />
<br />
<figure id="amp_vs_channel_example.png"><br />
[[File:amp_vs_channel_example.png|200px|thumb|right|<caption> Amplitude vs. channel for one uncalibrated antenna pair. This kind of plot can be inspected to get an idea of the presence or magnitude of any roll-off in sensitivity near the edges of the spectral window.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:0~7,0:3831~3839', flagbackup = False)<br />
<br />
for asdm in basename_all:<br />
flagdata(vis = asdm+'.wvrtsys.ms', mode='manual', spw = '0:3260~3320', flagbackup = False)<br />
</source><br />
<br />
* '''Problematic Tsys measurements'''<br />
<br />
Above we noted issues with the Tsys measurements for both DV04 and DV12. We flag the affected data. Each of these issues should be visible in the Tsys plots you made above (e.g., see <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.DV02.spw5.CASA3_4.png"/> and <xr id="Uid___A002_X1ff7b0_Xb.tdm.tsys.3c279.PM01.spw5.CASA3_4.png"/>).<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV04',flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X1d5"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
<br />
asdm="uid___A002_X215db8_X392"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV12',correlation='YY', flagbackup=False)<br />
</source><br />
<br />
* '''Unreliable Short-Spacing Measurements on Titan'''<br />
<br />
<figure id="amp_vs_uv_titan_obs.png"><br />
[[File:amp_vs_uv_titan_obs.png|200px|thumb|right|<caption> Observed amplitude vs. uv-distance for observations of Titan in the first data set. Note the scatter for low projected antenna separations. We will flag these short-spacing data, which may reflect contamination by Saturn, and use only the more extended baselines for flux calibration.</caption>]]<br />
</figure><br />
<br />
Saturn may contaminate the short u-v spacings from Titan. In any case these often show significant scatter (<xr id="amp_vs_uv_titan_obs.png"/>), so we flag them. There are still enough baselines to determine a good amplitude calibration for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X1ff7b0_Xb"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~40', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X1ff7b0_X1c8"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~50', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X4d7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', field='Titan', uvrange='0~30', flagbackup = False)<br />
</source><br />
<br />
* '''Delay Issues''' <br />
<br />
<figure id="phase_vs_freq_DV13.png"><br />
[[File:phase_vs_freq_DV13.png|200px|thumb|right|<caption> Phase vs. frequency for DV13 in a data set where this antenna shows evidence of imperfect delay calibration.</caption>]]<br />
</figure><br />
<br />
DV13 and a few other antennas show signatures of an imperfect delay calibration. This is most easily identified via strong "wrapping" of phase as a function of frequency (see <xr id="phase_vs_freq_DV13.png"/>). Such effects can be calibrated out with mild delay issues largely accounted for by the bandpass solution. The phase wrapping in DV13 seems weak enough that we will trust the calibrations to remove it. For a more extreme example see the CASA guide describing the calibration of [[NGC3256Band3]].<br />
<br />
* '''Missing Phase Calibrator Observations'''<br />
<br />
<figure id="amp_vs_time_missing_scans.png"><br />
[[File:amp_vs_time_missing_scans.png|200px|thumb|right|<caption> Amplitude vs. time colored by field for a data set where the final visit to the phase calibrator is missing. We will flag the last set of source data to ensure that each visit to the source is flanked in time by visits to the phase calibrator.</caption>]]<br />
</figure><br />
<br />
As a general rule, we want to be sure that observations of the phase calibrator (3c279) bracket each source observation. Two of the data sets do not include a final phase calibrator observation (see <xr id="amp_vs_time_missing_scans.png"/>) and for those two cases we flag the affected source observations.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3b9"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='00:53:47~01:08:00',flagbackup = False)<br />
<br />
asdm="uid___A002_X215db8_X18"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV10',timerange='19:46:20~20:34:40',flagbackup=False)<br />
</source><br />
<br />
* '''Unexpected Scatter or Discontinuity in the Data'''<br />
<br />
For several antennas we find sudden jumps in the phase of the phase calibrator as a function of time. These are visible in the plots of uncalibrated phase vs. time for single baselines above, and we show an example in <xr id="phase_vs_time_DV09.png"/>. It will not be possible to effectively interpolate the phase between measurements when we see these discontinuities. The safest approach is to flag the source data across these jumps. We do so here (though note that the last two flaggings are borderline cases).<br />
<br />
<figure id="phase_vs_time_DV09.png"><br />
[[File:phase_vs_time_DV09.png|200px|thumb|right|<caption> Phase vs. time for DV09 on a problematic day. It may prove problematic to calibrate the data near this discontinuity so we flag data near this time.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09', timerange='21:24:09~21:35:35', flagbackup = False)<br />
<br />
asdm="uid___A002_X207fe4_X1f7" <br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV09',timerange='23:30:52~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM01',timerange='23:16:50~24:10:00',flagbackup=False)<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='PM03',timerange='23:16:50~24:10:00',flagbackup=False)<br />
</source><br />
<br />
* '''Outliers Visible After Calibration'''<br />
<br />
<figure id="amp_vs_uvdist_outliers.png"><br />
[[File:amp_vs_uvdist_outliers.png|200px|thumb|right|<caption> Amplitude vs. u-v distance ''after'' calibration. Note the outlying data. We track these down using the select (box with green "+") and locate (magnifying glass) features inside plotms and identify several problematic baselines across our data. ''Note that you cannot make this plot at this point in the guide, these pathologies become evident after calibration, requiring an iterative approach to reduction.''</caption>]]<br />
</figure><br />
<br />
Often issues with the data may become evident after calibration (i.e., after the next few steps that we apply). These data can appear as outliers in diagnostic plots for the calibrated data or even show up in the imaging stages. Once these are identified, best practice is to apply this new flagging then redo the calibration (if the issue is very minor, then re-calibrating may not be necessary).<br />
<br />
<source lang="python"><br />
# In CASA<br />
asdm="uid___A002_X207fe4_X3a"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', timerange='21:18:00~21:22:15', flagbackup=False)<br />
<br />
asdm="uid___A002_X2181fb_X49"<br />
flagdata(vis=asdm+'.wvrtsys.ms', mode='manual', antenna='DV01&DV04', flagbackup=False)<br />
</source><br />
<br />
Now that we've applied our flagging, back up the flags as version "User" using {{flagmanager}}:<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis=asdm+'.wvrtsys.ms',mode='save',versionname ='User')<br />
</source><br />
<br />
Applying this flagging will remove the most egregious pathologies from the data. We are now ready to calibrate the data.<br />
<br />
==Bandpass Calibration==<br />
<br />
We begin by calibrating the phase and amplitude response of each antenna as a function of frequency, called "bandpass calibration." We have already seen that the data contain smooth but systematic variations in both phase and amplitude as a function of frequency. We can see this again in a more compact form by plotting phase as a function of frequency for all baselines associated with each antenna (<xr id="plotms_phase_vs_freq_example.png"/>).<br />
<br />
<figure id="plotms_phase_vs_freq_example.png"><br />
[[File:plotms_phase_vs_freq_example_6.1.png|200px|thumb|right|<caption> Phase vs. frequency for the bandpass calibrator, 3c279 in the first data set. We plot all baselines with DV02, averaged over time, and show only the 'XX' correlation.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='freq', yaxis='phase', <br />
selectdata=True, field='3c279', correlation='XX',<br />
avgtime='1e8', avgscan=True, antenna='*&*',<br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. frequency for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
Each plot shows phase as a function of frequency for all baselines with one antenna for 3c279. We plot only the 'XX' correlation, colorizing by baseline. With '''iteraxis''' set to antenna the green arrows at the bottom of {{plotms}} will cycle through antennas. By using '''avgscan''' and a large '''avgtime''' we average all scans and integrations. <br />
<br />
The phase (and amplitude) also varies as a function of time, as we saw before. Here are the similar plots for phase vs. time (see <xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/>).<br />
<br />
<figure id="Uid_A002_X1ff7b0_Xb-phasecont.png"><br />
[[File:Uid_A002_X1ff7b0_Xb-phasecont_6.1.png|200px|thumb|right|<caption> Phase vs. time for the bandpass calibrator, 3c279. Averaged over channel. Only baselines with antenna DV02, and corr='XX'</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for asdm in basename_all:<br />
plotms(vis= asdm+'.wvrtsys.ms', <br />
xaxis='time', yaxis='phase', <br />
selectdata=True, field='3c279', <br />
spw='0:1200~1299', antenna='*&*',correlation='XX',<br />
avgchannel='100', avgscan=True, <br />
coloraxis='baseline', iteraxis='antenna', showgui = True)<br />
dummy_string = input("Plotting phase vs. time for "+asdm+". Hit <Enter> for next data set or cycle through antennas [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
<xr id="Uid_A002_X1ff7b0_Xb-phasecont.png"/> shows that the phase varies with time. We need to take this temporal variation into account when we solve for the frequency variations. Therefore we carry out the bandpass calibration in two steps. First, we use {{gaincal}} to solve for the variation of phase as a function of time for 3c279 on very short timescales. We set {{gaincal}} to derive a separate phase solution for each antenna every integration by setting '''solint''' to 'int'. We solve, averaging together only a small fraction of the total bandpass (channels 1100-1300) to avoid the effects of the phase vs. frequency behavior. We will then apply this solution to remove time-dependent behavior when we solve for the frequency response of the antennas with {{bandpass}}.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
An integration is the smallest time quantum of observation in the data, usually a few seconds. <br />
You can check the integration length for each scan in listobs. <br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
for asdm in basename_all:<br />
print ("Running a short solution interval phase calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bpphase.gcal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
selectdata=True,field = '3c279',spw = '0:1100~1300',<br />
caltable = asdm+'.bpphase.gcal',<br />
solint = 'int',refant = 'DV11',calmode='p')<br />
</source><br />
<br />
Now we use {{bandpass}} to solve for the frequency response of each antenna. To do this, we average all data in time by setting '''solint''' to 'inf' (that is, 'infinite'). We allow combination across scans and the different field IDs found for 3c279 by setting '''combine''' to "scan,field". We apply the phase vs. time calibration that we just derived on-the-fly using the parameter "gaintable".<br />
<br />
<source lang="python"><br />
for asdm in basename_all:<br />
print ("Running a bandpass calibration for "+asdm)<br />
os.system('rm -rf '+asdm+'.bandpass.bcal')<br />
bandpass(vis = asdm+'.wvrtsys.ms',<br />
field = '3c279',<br />
gaintable = asdm+'.bpphase.gcal',<br />
caltable = asdm+'.bandpass.bcal',<br />
bandtype='B',<br />
solint = 'inf',combine = 'scan,field', solnorm=True,refant = 'DV11',<br />
minblperant=3,minsnr=2,fillgaps=62)<br />
</source><br />
<br />
in these calls:<br />
<br />
*'''caltable''' specifies the output calibration table<br />
*'''gaintable''' specifies any calibration tables to be applied "on the fly" to the data before solving.<br />
*'''solint''' sets the time interval for which solutions are derived for each antenna.<br />
*'''refant''' set the reference antenna, here DV11, which is defined to have zero correction by construction.<br />
*'''calmode''' 'p' sets {{gaincal}} to calibrate the phase only, other options are 'a'mplitude or 'ap' - amplitude and phase.<br />
*'''minblperant''' sets the minimum baselines required per antenna for a successful solution.<br />
*'''minsnr''' sets the minimum signal-to-noise ratio required for a successful solution.<br />
*'''bandtype''' here 'B' tells {{bandpass}} to solve for the phase and frequency response of each antenna in each channel, averaging data in time across the solution interval.<br />
*'''fillgaps''' tells {{bandpass}} to interpolate across channel gaps 1 channel wide.<br />
*'''solnorm''' tells {{bandpass}} to normalize the bandpass amplitude and phase corrections to have magnitude unity. The absolute scale of the calibration will come from our later {{gaincal}} solutions.<br />
<br />
Do not worry about the message "Insufficient unflagged antennas" when running the {{bandpass}} task. This indicates that {{bandpass}} is failing on the flagged edge channels, which is expected.<br />
<br />
It is now a good idea to plot both sets of solutions to look for irregularities, especially:<br />
<br />
* discontinuities in the phase vs. time solution<br />
* rapid wrapping of phase in either phase vs. time or bandpass solution<br />
* large roll-off in the amplitude response near the band edge in the bandpass solution<br />
* large scatter in any solution.<br />
<br />
We loop through and using analysis utils, again generating .png files of each calibration. '''For what systems is this true?''' As the bandpass plots take a while you may want to go have a cup of coffee and inspect them using your favorite image viewer. Otherwise, switch the '''interactive''' parameter to True to see them in real time instead.<br />
<br />
<figure id="uid___A002_X1ff7b0_X1c8.bpphase.page1.png"><br />
[[File:uid___A002_X1ff7b0_X1c8.bpphase.page1_6.1.png|200px|thumb|right|<caption> Short interval phase vs. time solution carried out and applied during bandpass calibration, here for the first set of antennas for the first data set. This solution removes any systematic variations in phase vs. time.</caption>]]<br />
</figure><br />
<figure id="Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1.CASA3.4.png"><br />
[[File:Uid___A002_X1ff7b0_X1c8.bandpass.DV02.spw0.t1_6.1.png|200px|thumb|right|<caption> Bandpass amplitude solution for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<figure id="uid___A002_X1ff7b0_Xb.bcal_phase.page1.png"><br />
[[File:uid___A002_X1ff7b0_Xb.bcal_phase.page1.png|200px|thumb|right|<caption> Phase vs. frequency calibration from the bandpass calibration for the first set of antennas and the first data set.</caption>]]<br />
</figure><br />
<br />
<!--<br />
Again this warning:<br />
No ASDM_CALWVR, ASDM_CALATMOSPHERE, or CalWVR.xml table found. Using PWV 1.0mm.<br />
--><br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
os.system('rm -rf cal_plots/*bandpass*.png')<br />
for asdm in basename_all:<br />
plotbandpass(caltable=asdm+'.bandpass.bcal',<br />
field='',xaxis='freq',yaxis='both',<br />
figfile='cal_plots/'+asdm+'.bandpass.png',<br />
showatm=True,interactive=False,subplot=42)<br />
</source><br />
<br />
==Absolute Flux Calibration==<br />
<br />
The bandpass calibration will account for the phase and amplitude response of our antennas as a function of frequency. We now solve for the absolute flux scale of the data by referencing to Titan and in the next section we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
Before using Titan to set the flux, there is an important systematic to account for. When we looked at the integrated spectra of our targets above, remember that Titan showed a whopping spectral line, in fact the same CO(3-2) line that we wish to observe in the Antennae. We will set the flux of Titan (and thus all of our data) by referencing to a model in casa that does not account for this line. Therefore we need to flag the part of the Titan observations contaminated by the line before we calibrate (you can see the affected channel range in <xr id="Antennae-TitanLine.png"/>). We run the following additional flagging step:<br />
<br />
<figure id="Antennae-TitanLine.png"><br />
[[File:Antennae-TitanLine_6.1.png|200px|thumb|right|<caption> Uncalibrated amplitude vs. channel plot for the flux calibrator, Titan (uid___A002_X1ff7b0_Xb dataset). Averaged over time, corr='XX', and colorized by baseline.</caption>]]<br />
</figure><br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Flagging CO(3-2) in Titan for "+asdm)<br />
flagdata(vis=asdm+'.wvrtsys.ms',flagbackup=False, <br />
field='Titan', spw='0:1100~1700')<br />
<br />
for asdm in basename_all:<br />
flagmanager(vis =asdm+'.wvrtsys.ms',mode = 'save',versionname = 'Calibration')<br />
</source><br />
<br />
Next, we will use the {{setjy}} task to read the predicted complex visibilities for Titan into the MODEL column of each data set.<br />
<br />
<source lang="python"><br />
# in CASA<br />
for asdm in basename_all:<br />
print ("Reading model for Titan into "+asdm)<br />
setjy(vis = asdm+'.wvrtsys.ms',field = 'Titan',<br />
usescratch=True,scalebychan=True,<br />
standard = 'Butler-JPL-Horizons 2012')<br />
</source><br />
<br />
{{setjy}} will output the flux of Titan to the CASA logger and it is worth recording this information. The flux of Titan at these frequencies is about 3.3 Jy. For example, for dataset uid___A002_X1ff7b0_Xb.wvrtsys.ms:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Titan: spw0 Flux:[I=3.2637,Q=0.0,U=0.0,V=0.0] +/- [I=0.0,Q=0.0,U=0.0,V=0.0] Jy @ 344.85GHz<br />
</pre><br />
<br />
Now we are going to take a look at the Titan model for one dataset:<br />
<br />
<source lang="python"><br />
# in CASA<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
<br />
plotms(vis ='uid___A002_X1ff7b0_X1c8.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='model', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
</source><br />
<br />
<figure id="2012_titan_model_5.1.png">[[File:2012_titan_model_5.1.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2012'.</caption>]]</figure><br />
<figure id="2010_titan_model.png">[[File:2010_titan_model.png|thumb|right|200px|<caption>Titan model produced by 'Butler-JPL-Horizons 2010'.</caption>]]</figure><br />
<br />
<br/><br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
The setjy invocation made in this section uses the flux density standard '''standard='Butler-JPL-Horizons 2012' '''. Previous versions of this guide used an older flux density standard '''standard='Butler-JPL-Horizons 2010' '''. <xr id="2012_titan_model_5.1.png"/> and <xr id="2010_titan_model.png"/> show the differences in the Titan models produced using these two standards. <br />
</div><br />
<br />
==Gain (Phase and Amplitude) Calibration==<br />
<br />
With the flux now properly scaled, we will calibrate the phase and amplitude behavior of the antennas as a function of time.<br />
<br />
We begin by running a short-solution interval {{gaincal}} to solve for phase variation on short timescales during observations of our two calibrators, with '''solint''' set to "int". By applying this on-the-fly, we can remove any decorrelation in the data due to phase scatter when we solve for the amplitude calibration. However, there is no benefit to using this short-timescale solution to calibrate the source because we only have information on the gain during calibrator visits (though see the Imaging portion of this guide). Instead we will solve for the gains to apply to the source using a longer '''solint''' in just a moment.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out short timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.intphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.intphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='int',minsnr=2.0, minblperant=4)<br />
</source><br />
<br />
Now we derive the longer timescale phase calibration table using '''solint''' set to "inf", but not allowing scan combination. This calibration has higher signal to noise due to combining more data, and for the purposes of correcting the source, it is just as precise as the short timescale solution.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Carrying out longer timescale phase solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.scanphase.gcal')<br />
gaincal(vis=asdm+'.wvrtsys.ms',<br />
gaintable=asdm+'.bandpass.bcal', <br />
caltable=asdm+'.scanphase.gcal',<br />
calmode='p',<br />
field='Titan,3c279',<br />
spw='0:40~3800',<br />
refant='DV11', solint='inf',minsnr=2.0,minblperant=4)<br />
</source><br />
<br />
Now we apply the short-timescale phase solution and carry out a scan length ('''solint''' set to "inf") calibration of the data using '''calmode''' of 'ap'.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Solving for longer (scan) interval amplitude solution for "+asdm)<br />
os.system('rm -rf '+asdm+'.amp.cal')<br />
gaincal(vis = asdm+'.wvrtsys.ms',<br />
gaintable =[asdm+'.bandpass.bcal',asdm+'.intphase.gcal'],<br />
caltable = asdm+'.amp.cal',<br />
calmode='ap',<br />
field = 'Titan,3c279',<br />
spw='0:40~3800',<br />
refant = 'DV11',solint = 'inf', minblperant=4)<br />
</source><br />
<br />
This "amp.cal" solution gives us the amplitude variations as a function of time, but they are not yet pinned to a realistic scale except in the case of Titan, where we have solved using the model input by {{setjy}}. We will set the flux of our secondary calibrator 3c279 with reference to Titan using {{fluxscale}}.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Scaling amplitude calibration to match Titan for "+asdm)<br />
os.system('rm -rf '+asdm+'.flux.cal')<br />
fluxscale(vis = asdm+'.wvrtsys.ms',<br />
caltable = asdm+'.amp.cal',<br />
fluxtable = asdm+'.flux.cal',<br />
reference = 'Titan',<br />
transfer = '3c279')<br />
</source><br />
<br />
This new correctly-scaled flux table ".flux.cal" replaces the previous ".amp.cal" table as the correct amplitude calibration table to apply to the data, i.e., the ".flux.cal" contains both the time variability of the amplitude solved for in ".amp.cal" and the correct flux scaling set with {{fluxscale}}.<br />
<br />
Fluxscale will output the derived flux for 3c279 to the CASA logger. This information is worth noting. We find that the flux of 3c279 is 10.79 Jy, by averaging the fluxes obtained from the ten available datasets. If we check this value against reported flux measurements in the SMA calibrator list [http://sma1.sma.hawaii.edu/callist/callist.html], we find that a flux of 10.79 Jy agrees within a few per cent of a linear interpolation between the two 0.85 mm measurements closest in time to the ALMA observations: (23 May 2011, SMA 11.644 ± 0.583; 01 July 2011, 9.748 ± 0.488).<br />
<br />
<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;"><br />
If you used the older, Butler-JPL-Horizons 2010, flux density standard when you ran {{setjy}} earlier in this tutorial, the derived flux values for 3c279 will be slightly lower. The flux of 3c279, when averaged over all 10 measurement sets, will be 10.41 Jy.<br />
</div><br />
<br />
Now we plot the final phase and amplitude calibration tables for each data set. A well-behaved calibration table will show smooth variations as a function of time. Sudden jumps or wild variations among the antenna amplitude gains should prompt further investigation and possibly additional flagging.<br />
<br />
<source lang="python"><br />
# in CASA<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Plotting solutions for "+asdm)<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis='antenna',antenna='0~7',plotrange=[0,0,-180,180],<br />
gridrows=4,gridcols=1,showgui=False,<br />
plotfile=asdm+'.scanphase.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis=asdm+'.scanphase.gcal',<br />
xaxis = 'time', yaxis = 'phase', coloraxis='corr',<br />
iteraxis = 'antenna', antenna='8~15', plotrange=[0,0,-180,180],<br />
showgui=False, gridrows=4, gridcols=1, <br />
plotfile=asdm+'.scanphase.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='0~7', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page1.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
plotms(vis = asdm+'.flux.cal', <br />
xaxis = 'time',yaxis = 'amp', coloraxis='corr',<br />
iteraxis='antenna', antenna='8~15', plotrange = [0,0,0,0],<br />
showgui=False, gridrows=4,gridcols=1, <br />
plotfile=asdm+'.flux.page2.png')<br />
# dummy_string = input("Hit <Enter> to see next plot.")<br />
<br />
</source><br />
<br />
==Apply the Calibrations and Inspect ==<br />
Now we will use {{applycal}} to apply the bandpass, phase, and amplitude calibration tables that we generated in the previous sections to the data. We apply the solutions separately to the bandpass and secondary ("phase") calibrator 3c279, the flux calibrator Titan, and the target source. In most data sets, the bandpass and secondary calibrator will not be the same and this step would include one additional {{applycal}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
for asdm in basename_north: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='NGC*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_south: <br />
print ("Applying calibrations for "+asdm)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='3c279',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Titan',<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],<br />
interp=['nearest','nearest','nearest'],<br />
gainfield=['3c279','Titan','Titan'],flagbackup=False,calwt=False)<br />
applycal(vis=asdm+'.wvrtsys.ms',field='Ant*',<br />
interp=['nearest','linear','linear'],<br />
gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],<br />
gainfield=['3c279','3c279','3c279'],flagbackup=False,calwt=False)<br />
</source><br />
<br />
Here:<br />
* '''vis''' and '''field''' specify the measurement set and field to calibrate.<br />
* '''gaintable''' specifies the tables to apply to the data. There may be several tables applied all at once, here we apply the bandpass, phase, and flux calibrations.<br />
* '''interp''' specifies the type of interpolation used to match calibration tables to the data. If there are several gaintables then interp may be either a single value (e.g., "linear" or "nearest") or a list of values with size equal to the list of gaintables. In the case where interp is a list, applycal will match each element to the corresponding gaintable (e.g., first gaintable with first interp parameter).<br />
* '''gainfield''' specifies field from which to draw the calibration. As with interp, this can be a list of size matched to gaintable, so that the first element of gainfield will be the field used for the first table. For example, in the above commands the bandpass calibration (the first table) will always be applied from '3c279' (the first gainfield).<br />
* '''calwt''' indicates that the weights, which were derived from the Tsys measurements, should also be calibrated. Note that '''calwt''' is True by default.<br />
<br />
Once calibrations are applied, it is important to go back and inspect the calibrated data. New problematic antennas or baselines may be visible after calibration. Repeat the steps above, focusing on the CORRECTED data column. Bear in mind that for any point source calibrators we now expect to find phase scattering around zero and to find flat amplitudes as a function of u-v distance. Look for outliers and other signatures of problematic data. As a general rule, you will want to incorporate these data into your overall flagging script then rerun the whole calibration process, so that reduction is iterative. If the data only represent a minor problem, however, it may not be terribly harmful to flag them after the fact so that they do not interfere with imaging but trust that the calibrations are mostly unaffected.<br />
<br />
As an example of this inspection, we cycle through the corrected amplitudes and phases of 3c279 and Titan as a function u-v distance, to check that the phases are close to zero and the amplitudes are constant. <br />
<br />
<figure id="xb-checkcal-pha-cha.png"><br />
[[File:xb-checkcal-pha-cha.png|200px|thumb|right|<caption> Calibrated phase vs. channel plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<figure id="xb-checkcal-amp-time.png"><br />
[[File:xb-checkcal-amp-time.png|200px|thumb|right|<caption> Calibrated amplitude vs. time plot for 3c279 (uid___A002_X1ff7b0_Xb dataset). </caption>]]<br />
</figure><br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='3c279',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='time', yaxis='phase',<br />
ydatacolumn='corrected', field='3c279',<br />
avgchannel='3840', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
<br />
<br />
for asdm in basename_all:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='phase',<br />
ydatacolumn='corrected', field='Titan',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Titan',avgtime='1e8',<br />
avgchannel='', avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot [type 'stop'+<Enter> to break out].")<br />
# check if a stop has been requested<br />
if dummy_string == "stop":<br />
break<br />
</source><br />
<br />
In <xr id="xb-checkcal-pha-cha.png"/> and <xr id="xb-checkcal-amp-time.png"/> we plot phase vs. channel and amp vs. time for 3c279 for the uid___A002_X1ff7b0_Xb dataset. <br />
<br />
Finally we can use {{plotms}} to examine the corrected amplitude and phase of Antennae galaxies as a function of time and uv-distance (plots not shown):<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
for asdm in basename_north:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='NGC*',<br />
avgtime='1e8', avgscan=True, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
for asdm in basename_south:<br />
print ("Examining calibrated data for "+asdm)<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='uvdist', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
averagedata=True, avgchannel='3840', avgtime='',<br />
avgscan=False, avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
plotms(vis = asdm+'.wvrtsys.ms', xaxis='freq', yaxis='amp',<br />
ydatacolumn='corrected', field='Ant*',<br />
avgtime='1e8', avgscan=True,avgbaseline=False, coloraxis='corr', showgui = True)<br />
dummy_string = input("Hit <Enter> for next plot.")<br />
</source><br />
<br />
==Split and Concatenate Data for Northern and Southern Mosaics==<br />
The individual data sets are now calibrated. We can safely split out the calibrated data for our science target and drop the calibrators. As we do so, we will smooth the data in frequency, averaging together groups of 23 channels by setting '''width=23''' in {{split}}. The new data will have a channel width corresponding to about ~10 km/s, very similar to the SMA data being verified. The factor of >20 drop in data volume will also make the imaging steps ''much'' more tractable.<br />
<br />
Note that you will see a warning that the last output channel in the new spw 0 will be dropped, as it has less than 23 channels over which to average:<br />
<br />
<pre style="background-color: #fffacd;"><br />
INFO MSTransformDataHandler The last output channel of spw 0 has only 22 input channels.<br />
WARN MSTransformManager Not enough input channels to populate output channel n# 166 from SPW 0.<br />
WARN MSTransformManager The channel will be dropped in order to have an uniform grid.<br />
</pre><br />
<br />
<source lang="python"><br />
#In CASA<br />
<br />
basename_north=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9","uid___A002_X2181fb_X49"]<br />
<br />
basename_south=["uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7","uid___A002_X207fe4_X4d7",<br />
"uid___A002_X215db8_X18","uid___A002_X215db8_X1d5","uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_north:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'NGC*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
<br />
for asdm in basename_south:<br />
os.system('rm -rf '+asdm+'.cal.ms')<br />
split(vis = asdm+'.wvrtsys.ms',outputvis = asdm+'.cal.ms',<br />
field = 'Ant*',spw='0',width=23, keepflags=False)<br />
os.system('rm -rf '+asdm+'.cal.listobs.txt')<br />
listobs(asdm+'.cal.ms',listfile=asdm+'.cal.listobs.txt')<br />
</source><br />
<br />
For convenience we concatenate all data for the Northern Mosaic into a single big MS and place all data for the Southern Mosaic into another file. To do this, we construct a list that holds the names of all the Southern Mosaic MS files and another that holds the name of all the Northern Mosaic MS files then feed these into the {{concat}} task. <br />
<br />
Before we do this, we'll take a brief aside to remove Pointing information from the calibrated data. Normally, the pointing information would apply important corrections to be used while imaging the data. However, some aspects of this are still under development and the pointing information in these data interacts poorly with CASA. We will remove the pointing information using the CASA toolkit Table tool (tb). ''This kind of operation is dangerous and should not be a regular feature of your CASA reduction.''<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
basename_all=["uid___A002_X1ff7b0_Xb","uid___A002_X207fe4_X3a","uid___A002_X207fe4_X3b9",<br />
"uid___A002_X2181fb_X49","uid___A002_X1ff7b0_X1c8","uid___A002_X207fe4_X1f7",<br />
"uid___A002_X207fe4_X4d7","uid___A002_X215db8_X18","uid___A002_X215db8_X1d5",<br />
"uid___A002_X215db8_X392"]<br />
<br />
for asdm in basename_all:<br />
print ("Manually removing pointing table from "+asdm+".cal.ms ... Please be careful!")<br />
tb.open(asdm+'.cal.ms/POINTING',nomodify=False)<br />
a = tb.rownumbers()<br />
tb.removerows(a)<br />
tb.close()<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
cal_south_vis = [vis+'.cal.ms' for vis in basename_south]<br />
cal_north_vis = [vis+'.cal.ms' for vis in basename_north]<br />
<br />
os.system('rm -rf Antennae_South.cal.ms')<br />
concat(vis=cal_south_vis, concatvis='Antennae_South.cal.ms', timesort=True)<br />
<br />
os.system('rm -rf Antennae_North.cal.ms')<br />
concat(vis=cal_north_vis, concatvis='Antennae_North.cal.ms', timesort=True)<br />
</source><br />
<br />
The syntax used to construct the 'cal_south_vis' variable loops over basename_south and makes a list after adding '.cal.ms' to each member. To see the list 'print (cal_south_vis)'.<br />
<br />
==Continue on to Imaging of the Science Target==<br />
Now you can continue on to the [http://casaguides.nrao.edu/index.php?title=AntennaeBand7_Imaging_6.1 imaging guide].<br />
{{Checked 6.1}}</div>Dkim