TWHydraBand7 Calibration 3.4: Difference between revisions

From CASA Guides
Jump to navigationJump to search
Thunter (talk | contribs)
Jcrossle (talk | contribs)
made calwt value explicit in all calls to applycal
 
(162 intermediate revisions by 5 users not shown)
Line 2: Line 2:
*'''This script assumes that you have downloaded TWHYA_BAND7_UnCalibratedMSAndTablesForReduction.tgz from [[TWHydraBand7#Getting_the_Data]]'''
*'''This script assumes that you have downloaded TWHYA_BAND7_UnCalibratedMSAndTablesForReduction.tgz from [[TWHydraBand7#Getting_the_Data]]'''


*'''Details of the ALMA data are provided at [[TWHydraBand7]]
*'''An introduction to this data set is available at [[TWHydraBand7]].


*'''Older version of the calibration part of the tutorial can be found at: [[TWHydraBand7_Old_for_CASA_3.3]]
*'''This guide is designed for CASA 3.4 (≥r19988).  If you are using an older version of CASA please see [[TWHydraBand7_Calibration_for_CASA_3.3]].


*'''For the streamlined Synthesis Imaging School version, see [[TWHydraBand7_SS12]].


==Unpack the Data==
==Preparation==


Once you have downloaded TWHYA_BAND7_UnCalibratedMSAndTablesForReduction.tgz, in a terminal unpack it with
Once you have downloaded TWHYA_BAND7_UnCalibratedMSAndTablesForReduction.tgz, in a terminal unpack it with


<tt>>tar -zxvf TWHYA_BAND7_UnCalibratedMSAndTablesForReduction.tgz</tt>
<source lang="bash">
tar -zxvf TWHYA_BAND7_UnCalibratedMSAndTablesForReduction.tgz
</source>


Please be aware that you will need about 100 GB of free space to do the data reduction.  It is a good idea to check that now before you begin.  Some of the plots described here require 9 GB of RAM; as little as 4 GB may be sufficient if additional data averaging is used when the plots are generated.  When you are satisfied with the available drive space and memory on your machine:
Please be aware that you will need about 100 GB of free space to do the data reduction.  It is a good idea to check that now before you begin.  Some of the plots described here require 9 GB of RAM; as little as 4 GB may be sufficient if additional data averaging is used when the plots are generated.  When you are satisfied with the available drive space and memory on your machine:


<tt>>cd TWHYA_BAND7_UnCalibratedMSAndTablesForReduction</tt>
<source lang="bash">
cd TWHYA_BAND7_UnCalibratedMSAndTablesForReduction
</source>
 
'''NOTE: the calibration tables included TWHYA_BAND7_UnCalibratedMSAndTablesForReduction CANNOT be used with CASA 3.4, they should be discarded, or moved out of the working directory.'''


Then start CASA.  
Then start CASA.  


<tt>>casapy</tt>
<source lang="bash">
casapy
</source>
 
== Confirm your version of CASA==
 
This guide has been written for CASA release 3.4.0.  Please confirm your version before proceeding.
<source lang="python">
# In CASA
version = casalog.version()
print "You are using " + version
if (int(version.split()[4][1:-1]) < 19988):
    print "\033[91m YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."
    print "\033[91m PLEASE UPDATE IT BEFORE PROCEEDING."
else:
    print "Your version of CASA is appropriate for this guide."
</source>
 
==Install Analysis Utilities==
 
Analysis Utilities (or analysisUtils for short) is a small set of Python scripts that provide a number of analysis and plotting utilities for ALMA data reduction. This guide uses a few of these utilities. They are very easy to install (just download and untar). See
 
http://casaguides.nrao.edu/index.php?title=Analysis_Utilities
 
for a full description and download instructions. If you do not wish to do this, see the CASA 3.3 version of the guide linked at the top of this page for alternative (but slow) plotting options. Analysis Utilities are updated frequently so if its been a while since you installed it, its probably worth doing it again. If you are at an ALMA site or ARC, the analysis utilities are probably already installed and up to date.
 
==Fix Titan's coordinates==
 
'''Note that in the near future this step will be unnecessary.'''
 
It is temporarily necessary to correct the positions of ephemeris objects observed during ALMA Cycle 0, because the control software revisions earlier than 9.0 erroneously write the data with coordinates of 00:00:00.0000 +00.00.00.0000 (J2000).  For this dataset, we need to correct the position of the absolute flux calibrator Titan, as we can
see from the first {{listobs}}:
 
<source lang="python">
# In CASA
os.system('rm -f X3c1.ms.listobs')
listobs('X3c1.ms', verbose=T, listfile='X3c1.ms.listobs')
</source>
 
You can view the listobs output files using command "less" from the CASA prompt.
 
<pre style="background-color: #fffacd;">
  ID  Code Name          RA              Decl          Epoch  SrcId nRows
  0    none 3c279          12:56:11.16657 -05.47.21.5247 J2000  0    23625
  1    none Titan          00:00:00.00000 +00.00.00.0000 J2000  1    4842
  2    none TW Hya        11:01:51.84498 -34.42.17.1609 J2000  2    175176
  3    none J1147-382=QSO  11:47:01.38151 -38.12.11.1179 J2000  3    14832
  4    none J1037-295=QSO  10:37:16.08989 -29.34.02.9888 J2000  4    59877
</pre>
 
To correct Titan's position, we will use the task [http://casa.nrao.edu/stable/docs/TaskRef/fixplanets-task.html fixplanets], which writes the actual coordinates at the instant of the first observation.  This step takes a while because we are recalculating the uvw's accordingly.
<source lang="python">
# In CASA
fixplanets(vis='X3c1.ms', field='Titan', fixuvw=True)
</source>
 
Check the header information again with {{listobs}} to confirm that the information for Titan has changed:
 
<source lang="python">
# In CASA
os.system('rm -f X3c1.ms.listobs')
listobs('X3c1.ms', verbose=T, listfile='X3c1.ms.listobs')
</source>
 
<pre style="background-color: #fffacd;">
  ID  Code Name          RA              Decl          Epoch  SrcId nRows
  0    none 3c279          12:56:11.16657 -05.47.21.5247 J2000  0    23625
  1    none Titan          12:49:25.97588 -02.22.41.3024 J2000  1    4842
  2    none TW Hya        11:01:51.84498 -34.42.17.1609 J2000  2    175176
  3    none J1147-382=QSO  11:47:01.38151 -38.12.11.1179 J2000  3    14832
  4    none J1037-295=QSO  10:37:16.08989 -29.34.02.9888 J2000  4    59877
</pre>
 
Now fix the other two measurement sets similarly:
<source lang="python">
# In CASA
fixplanets(vis='X5d8.ms', field='Titan', fixuvw=True)
fixplanets(vis='X7ef.ms', field='Titan', fixuvw=True)
</source>


==Observing Log and Priors==
==Observing Log and Priors==
Line 32: Line 117:
</pre>
</pre>


First let's examine the basic properties of the data using {{listobs}}.  Among other information we will be able to deduce what the source ids are and what each source was used for:
First let's examine the basic properties of the data using {{listobs}}.  Among other information we  
will be able to deduce what the source ids are and what each source was used for:


<pre style="background-color: #E0FFFF;">
<pre style="background-color: #E0FFFF;">
Line 49: Line 135:
</source>
</source>


You can view the {{listobs}} output files using command '''less''' from the CASA prompt. 
Below we copy select parts of the {{listobs}} output files for reference.  
Below we copy select parts of the {{listobs}} output files for reference.  


Line 67: Line 154:
   ID  Code Name                RA              Decl          Epoch  SrcId nRows
   ID  Code Name                RA              Decl          Epoch  SrcId nRows
   0    none 3c279              12:56:11.16657 -05.47.21.5247 J2000  0    23625
   0    none 3c279              12:56:11.16657 -05.47.21.5247 J2000  0    23625
   1    none Titan              00:00:00.00000 +00.00.00.0000 J2000  1    4842
   1    none Titan              12:49:25.97588 -02.22.41.3024 J2000  1    4842
   2    none TW Hya              11:01:51.84498 -34.42.17.1609 J2000  2    175176
   2    none TW Hya              11:01:51.84498 -34.42.17.1609 J2000  2    175176
   3    none J1147-382=QSO      11:47:01.38151 -38.12.11.1179 J2000  3    14832
   3    none J1147-382=QSO      11:47:01.38151 -38.12.11.1179 J2000  3    14832
Line 114: Line 201:
Things to Notice from above:  
Things to Notice from above:  
*There are three different data sets acquired close together in time. We will calibrate each dataset independently and then combine the calibrated data prior to imaging.  
*There are three different data sets acquired close together in time. We will calibrate each dataset independently and then combine the calibrated data prior to imaging.  
*Titan appears to have a position of 0,0. We will fix this later in the tutorial (it is a temporary data capture issue in the ALMA system, Titan was properly tracked during the observation).  
*Titan appears to have slightly different positions in each dataset because it is a moving body.  In fact, at the time of observation, due to temporary data capture issue in the ALMA system, the position was written has (0,0).  We have pre-corrected this error using fixplanets.  Later in the tutorial, we will run fixplanets again to force all three datasets to have the same fixed position for Titan.
*There are a lot of spectral windows! Don't be alarmed. In ALMA data,  
*There are a lot of spectral windows! Don't be alarmed. In ALMA data,  
**spw=0 is always reserved for the water vapor radiometry data.
**spw=0 is always reserved for the water vapor radiometry data.
**spw=9, 11, 13, 15 are the wideband (TDM) correlator mode with 128 channels per spw default settings for doing pointing and this is all they are used for in these data
**spw=9, 11, 13, 15 are the wideband (TDM) correlator mode with 128 channels per spw default settings for doing pointing and this is all they are used for in these data.
**currently Tsys data can only be taken in the wide (TDM) correlator mode with 128 channels per spw, these correspond to spws=1, 3, 5, 7 above. The frequencies of these TDM spw were carefully chosen so the the narrowband FDM spws fall within them.
**Currently Tsys data can only be taken in the wide (TDM) correlator mode with 128 channels per spw, these correspond to spws=1, 3, 5, 7 above. The frequencies of these TDM spws were carefully chosen so the the narrowband FDM spws fall within them.
** The 0.5 GHz, high spectral resolution spws that contain all the real source data (science target and calibrators) are 17, 19, 21, and 23
** The 0.5 GHz, high spectral resolution spws that contain all the real source data (science target and calibrators) are 17, 19, 21, and 23
**For quicklook purposes, the ALMA online system produces a channel averaged spw for each channelized spw, these correspond to spw=2,4,6,8,10,12,14,16,18,20,22,24 and shouldn't be used for anything in post-processing as bandpass calibration etc has not been applied.
**For quicklook purposes, the ALMA online system produces a channel averaged spw for each channelized spw, these correspond to spw=2,4,6,8,10,12,14,16,18,20,22,24 and shouldn't be used for anything in post-processing as bandpass calibration etc has not been applied.


Next scroll up in the logger itself after making your logger window as wide as possible (and optionally reducing the font size). In the portion of the listobs that shows the timerange, the final column gives the scan intent. It is important to have a look at this because you can flag and do other operations in CASA using the scan intent as a selection option. Also these intents will be used in the future for pipeline processing. You will usually want to use them to flag the CALIBRATE_POINTING* and CALIBRATE_ATMOS* (the latter correspond to the hot and cold load measurements used to calculate Tsys) data. This is essential for science or calibration data taken only in TDM (wide bandwidth) mode, i.e. the same mode that the pointing and Tsys data are taken in. For the current data however, that calibration data is recorded in different spws from the useful FDM (narrow bandwidth) data, so we'll be able to separate them by splitting them off at the final step prior to imaging.
In the portion of the {{listobs}} output that shows the timerange, the final column gives the scan intent. It is important to have a look at this because you can flag and do other operations in CASA using the scan intent as a selection option. Also, these intents will be used in the future for pipeline processing. You will usually want to use them to flag the CALIBRATE_POINTING* and CALIBRATE_ATMOS* (the latter correspond to the hot and cold load measurements used to calculate Tsys) data. This is essential for science or calibration data taken only in TDM (wide bandwidth) mode, i.e. the same mode that the pointing and Tsys data are taken in. For the current data however, that calibration data is recorded in different spws from the useful FDM (narrow bandwidth) data, so we'll be able to separate them by splitting them off at the final step prior to imaging.


[[Image:Ant_pos.png|thumb|Antenna locations for the first dataset.]]
<figure id="Ant_pos.png">
[[Image:Ant_pos.png|thumb|<caption>Antenna locations for the first dataset.</caption>]]
</figure>


Before we move on, its also nice to get an idea where the antennas are with respect to each other. We can use {{plotants}} to plot their positions. It is a good idea to check each file since an antenna may have entered or exited the array between observations.
Before we move on, its also nice to get an idea where the antennas are with respect to each other. We can use {{plotants}} to plot their positions. It is a good idea to check each file since an antenna may have entered or exited the array between observations.
Line 133: Line 222:
</source>
</source>


==Create the Tsys and WVR Tables, Apply, and Split==
You can view the output images using any standard image viewer.
 
==Create the Tsys and WVR Tables, and Examine ==


Each ms include tables that contain the Tsys and WVR measurements associated with the visibility data.
Each ms include tables that contain the Tsys and WVR measurements associated with the visibility data.
Line 146: Line 237:
for asdm in basename_all:
for asdm in basename_all:
   os.system('rm -rf '+asdm+'.wvr')
   os.system('rm -rf '+asdm+'.wvr')
   wvrgcal(vis=asdm+'.ms', caltable=asdm+'.wvr', segsource=True)
   wvrgcal(vis=asdm+'.ms', caltable=asdm+'.wvr', segsource=True, toffset=-1)
</source>
</source>


Line 153: Line 244:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
for asdm in basename_all:
   os.system('rm -rf '+asdm+'.tsys')
   os.system('rm -rf '+asdm+'.tsys')
Line 162: Line 254:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
for asdm in basename_all:
     listobs(vis=asdm+'.ms', verbose=F, selectdata=True, intent='CALIBRATE_ATMOS*')
     listobs(vis=asdm+'.ms', verbose=F, selectdata=True, intent='CALIBRATE_ATMOS*')
</source>
</source>
<figure id="X3c1.tsys_vs_time_3.4.png">
[[File:X3c1.tsys_vs_time_3.4.png|thumb|<caption>Tsys vs. time for spw 1 of the X3c1.ms data.</caption>]]
</figure>
<figure id="X5d8.tsys_vs_time_3.4.png">
[[File:X5d8.tsys_vs_time_3.4.png|thumb|<caption>Tsys vs. time for spw 1 of the X5d8.ms data.</caption>]]
</figure>
<figure id="X7ef.tsys_vs_time_3.4.png">
[[File:X7ef.tsys_vs_time_3.4.png|thumb|<caption>Tsys vs. time for spw 1 of the X7ef.ms data.</caption>]]
</figure>


<pre style="background-color: #fffacd;">
<pre style="background-color: #fffacd;">
Line 170: Line 273:
   ID  Code Name                RA              Decl          Epoch  SrcId nRows   
   ID  Code Name                RA              Decl          Epoch  SrcId nRows   
   0    none 3c279              12:56:11.16657 -05.47.21.5247 J2000  0    1116   
   0    none 3c279              12:56:11.16657 -05.47.21.5247 J2000  0    1116   
   1    none Titan              00:00:00.00000 +00.00.00.0000 J2000  1    1125   
   1    none Titan              12:49:25.97588 -02.22.41.3024 J2000  1    1125   
   2    none TW Hya              11:01:51.84498 -34.42.17.1609 J2000  2    6795   
   2    none TW Hya              11:01:51.84498 -34.42.17.1609 J2000  2    6795   
   4    none J1037-295=QSO      10:37:16.08989 -29.34.02.9888 J2000  4    6777   
   4    none J1037-295=QSO      10:37:16.08989 -29.34.02.9888 J2000  4    6777   
Line 191: Line 294:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
tsysfields=['0','1','2','4']  
basename_all = ['X3c1','X5d8','X7ef']
tsysfields=['0','1','2','4']
os.system('mkdir cal_plots; mkdir cal_plots/Tsys_plots')
for asdm in basename_all:
for asdm in basename_all:
   print "Plotting Tsys vs. time for "+asdm
   print "Plotting Tsys vs. time for "+asdm
   plotcal(caltable=asdm+'.tsys', xaxis='time',yaxis='tsys',
   plotcal(caltable=asdm+'.tsys', xaxis='time',yaxis='tsys',
           antenna='1~8',plotrange=[0,0,100,800],
           antenna='1~8',plotrange=[0,0,100,500],
           iteration='antenna',subplot=421,poln='',spw='1:50~50',
           iteration='antenna',subplot=421,poln='',spw='1:50~50',
           figfile='cal_plots/Tsys_plots/'+asdm+'.tsys_vs_time.png')
           figfile='cal_plots/Tsys_plots/'+asdm+'.tsys_vs_time.png')
Line 201: Line 306:
     user_check=raw_input('press enter to continue script\n')
     user_check=raw_input('press enter to continue script\n')
</source>
</source>
File:X3c1.tsys.time.spw1.png|Tsys vs Time for the X3c1.ms data.


To inspect Tsys vs. frequency, we use [[plotbandpass]] from [[analysisUtils]], which allows us to overlay an atmospheric transmission curve:
To inspect Tsys vs. frequency, we use [[plotbandpass]] from [[analysis_Utilities]]. (Note: You need to have installed [[analysis_Utilities]] before starting casapy.)  There are many different options for plotbandpass, and we demonstrate some of the most useful ones. The option '''showtsky=T''' will overlay the effective temperature curve from the atmospheric model.  This shows us the location of any atmospheric lines which will appear as emission lines in the autocorrelation data (from which the Tsys spectra are derived) from all antennas.  In the
example below, we set '''interactive=False''', which will produce many pages of plots as
individual pngs but will only show the final page in the graphics window.  To view all the pages we use the image viewer '''eog''' (Eye of GNOME) available on Linux.  The alternative is to set '''interactive=True''' and examine the plots in the casa graphics window as they are produced.
 
<figure id="X3c1.tsys.field0.DV04.spw1.t1.png">
[[File:X3c1.tsys.field0.DV04.spw1.t1.png|thumb|<caption>Tsys vs. frequency on 3C279 for the X3c1.ms data, spw=1.</caption>]]
</figure>
<figure id="X3c1.tsys.field0.DV04.spw3.t1.png">
[[File:X3c1.tsys.field0.DV04.spw3.t1.png|thumb|<caption>Tsys vs. frequency on 3C279 for the X3c1.ms data, spw=3.</caption>]]
</figure>
 
<source lang="python">
basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
    print "Plotting Tsys vs. frequency for "+asdm
    for spw in [1,3,5,7]:
        for field in ['0','1']:
            au.plotbandpass(caltable=asdm+'.tsys', xaxis='freq',yaxis='amp',
                    showtsky=T,subplot=421,field=field,
                    spw=spw, interactive=False, plotrange=[0,0,0,0],
                    figfile='cal_plots/Tsys_plots/'+asdm+'.tsys.field%s.png'%field,
                    buildpdf=False)
</source>
 
In <xr id="X3c1.tsys.field0.DV04.spw1.t1.png"/> and <xr id="X3c1.tsys.field0.DV04.spw3.t1.png"/> we see the effect of atmospheric ozone lines on the Tsys measurements associated with 3C279 in spw 1 and 3.
 
For sources that have multiple Tsys measurements (typically the primary phase calibrator and/or the science target) one can use '''overlay="time"''' to overlay all the measurements for that source.  This can help to identify any anomalous Tsys scans. As a fraction of the plots produced by this loop, here we show the Tsys recorded on spw=1 for TW Hya from the first dataset.
 
<figure id="X3c1.tsys.field2.DV04.spw1.png">
[[File:X3c1.tsys.field2.DV04.spw1.png|thumb|<caption>Tsys vs. freq for field 2, spw 1 of the X3c1.ms data (antennas 0..3).</caption>]]
</figure>
<figure id="X3c1.tsys.field2.DV04.spw1.png">
[[File:X3c1.tsys.field2.DV09.spw1.png|thumb|<caption>Tsys vs. freq for field 2, spw 1 of the X3c1.ms data (antennas 4..7).</caption>]]
</figure>
<figure id="X3c1.tsys.field2.PM03.spw1.png">
[[File:X3c1.tsys.field2.PM03.spw1.png|thumb|<caption>Tsys vs. freq for field 2, spw 1 of the X3c1.ms data (antenna 8).</caption>]]
</figure>


<source lang="python">
<source lang="python">
basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
for asdm in basename_all:
  print "Plotting Tsys vs. frequency for "+asdm
    print "Plotting Tsys vs. frequency for "+asdm
  for field in tsysfields:
    for spw in [1,3,5,7]:
    au.plotbandpass2(caltable=asdm+'.tsys', xaxis='freq',yaxis='amp',showtsky=T,subplot=42,field=field,
        for field in ['2','4']:
                     overlay='time',spw='1,3,5,7', interactive=False, plotrange=[0,0,100,800],
            au.plotbandpass(caltable=asdm+'.tsys', xaxis='freq',yaxis='amp',
                     figfile='cal_plots/Tsys_plots/'+asdm+'.tsys.field%s.png'%field,debug=False,
                    showtsky=T,subplot=221,field=field,
                     overlay='time',spw=spw, interactive=False, plotrange=[0,0,0,0],
                     figfile='cal_plots/Tsys_plots/'+asdm+'.tsys.field%s.png'%field,
                     buildpdf = False)
                     buildpdf = False)
</source>
</source>


File:X3c1.tsys.freq.spw1.png|Tsys vs Freq for the X3c1.ms data.
Alternatively, the '''overlay="antenna"''' option will quickly reveal any Antennas with discrepant Tsys values, as they
will be obvious outliers.  For FDM projects like this one, using the '''showfdm=True''' option can be helpful, as it
will show where in the TDM bandpass each FDM spw was located. 
<figure id="X3c1.tsys.field0.spw1.t1.png">
[[Image:X3c1.tsys.field0.spw1.t1.png|thumb|<caption>Tsys vs Freq for field 0, spw 1 of the X3c1.ms data with all antennas overlaid.</caption>]]
</figure>


<source lang="python">
tsysfields=['0','1','2','4']
basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
    print "Plotting Tsys vs. frequency for "+asdm
    for spw in [1,3,5,7]:
        for field in tsysfields:
            au.plotbandpass(caltable=asdm+'.tsys', xaxis='freq',yaxis='amp',
                  showtsky=T,subplot=111,field=field,
                  overlay='antenna',spw=spw, interactive=False,
                  figfile='cal_plots/Tsys_plots/'+asdm+'.tsys.field%s.png'%field,
                  buildpdf=False,showfdm=True)
</source>
Note that DV04 consistently has a significantly higher Tsys than the rest of the antennas.  We already know from the Observation log that
we need to flag that antenna, but had we not had that information, examining this plot would have demonstrated the situation.


==Apply the Tsys and WVR Tables, and Split ==


Next we apply the calibrations.  For the (4) sources with Tsys measurements, we use the '''field''' and '''gainfield''' parameters of {{applycal}} to apply solutions only to themselves.  We also tell casa to interpolate the TDM Tsys values in spws 1,3,5,7 onto the FDM spws 17,19,21,23 using
Next we apply the calibrations.  For the (4) sources with Tsys measurements, we use the '''field''' and '''gainfield''' parameters of {{applycal}} to apply solutions only to themselves.  A new feature in casa 3.4 is the ability of {{applycal}} to interpolate gain tables from one spw onto another spw.  In this case, we want to interpolate the TDM Tsys values in spws 1,3,5,7 onto the FDM spws 17,19,21,23.  We use the '''interp''' parameter to request linear interpolation in the time dimension and spline interpolation in the channel/frequency dimension. To map the solutions for each spw, we use the '''spwmap''' parameter, which requires a list of all spws for each gain table to be applied, or a blank list ([]) which is a shorthand notation to apply the solution for each spw to itself.  While applying Tsys, we will also apply the wvr calibration tables; wvr data is usually always present for all sources.  Below we first set some definitions so we can loop over the correct parameters:
the '''spwmap''' parameter.  While applying Tsys, we will also apply the wvr calibration tables; wvr data is usually always present for all sources.  Below we first set some definitions so we can loop over the correct parameters:


<source lang="python">
<source lang="python">
Line 233: Line 398:
tsysmap[23] = 7
tsysmap[23] = 7
for asdm in basename_all:
for asdm in basename_all:
   for field in sources:
   for field in tsysfields:
     applycal(vis=asdm+'.ms', spw=fdm, field=field, gainfield=field,
     applycal(vis=asdm+'.ms', spw=fdm, field=field, gainfield=field,
             gaintable=[asdm+'.tsys', asdm+'.wvr'], spwmap=[tsysmap,[]],
             gaintable=[asdm+'.tsys', asdm+'.wvr'], spwmap=[tsysmap,[]],
             interp=['linear,spline','nearest'], flagbackup=F)
             interp=['linear,spline','nearest'], flagbackup=F, calwt=T)
</source>
</source>


Line 245: Line 410:
for asdm in basename_all:
for asdm in basename_all:
   applycal(vis=asdm+'.ms', spw=fdm, field=nocal,
   applycal(vis=asdm+'.ms', spw=fdm, field=nocal,
           gaintable=[asdm+'.tsys', asdm+'wvr'], spwmap=[tsysmap,[]],
           gaintable=[asdm+'.tsys', asdm+'.wvr'], spwmap=[tsysmap,[]],
           gainfield=['4',nocal], interp=['linear,spline','nearest'],flagbackup=F)
           gainfield=['4',nocal], interp=['linear,spline','nearest'],flagbackup=F,
          calwt=T)
</source>
</source>


Line 252: Line 418:
simplicity we'll just look at the two strongest sources 3C279 and Titan.
simplicity we'll just look at the two strongest sources 3C279 and Titan.


[[Image:X5d8_wvrtsys_corrected_spw19.png|thumb|Spectral plots of 3C279 (black) and Titan (magenta) for spw=19 after Tsys and wvr correction.]]
<figure id="X5d8_wvrtsys_corrected_spw19.png">
[[Image:X5d8_wvrtsys_corrected_spw19.png|thumb|<caption>Spectral plots of 3C279 (black) and Titan (magenta) for spw=19 after Tsys and wvr correction.</caption>]]
</figure>


<source lang="python">
<source lang="python">
Line 261: Line 429:
</source>
</source>


[[Image:X5d8_wvrtsys_corrected_spw21.png|thumb|Spectral plots of 3C279 (black) and Titan (magenta) for spw=21 after Tsys and wvr correction.]]
<figure id="X5d8_wvrtsys_corrected_spw21.png">
[[Image:X5d8_wvrtsys_corrected_spw21.png|thumb|<caption>Spectral plots of 3C279 (black) and Titan (magenta) for spw=21 after Tsys and wvr correction.</caption>]]
</figure>


'''Note''': the antenna='*&*' is specifying that we only want to see the cross-correlation data (i.e. not the autocorrelations).
'''Note''': the antenna='*&*' is specifying that we only want to see the cross-correlation data (i.e. not the autocorrelations).
Line 267: Line 437:
Use the '''green arrows''' on the {{plotms}} display to cycle through the 4 FDM spws.  
Use the '''green arrows''' on the {{plotms}} display to cycle through the 4 FDM spws.  


Now change '''Data Column''' to '''corrected''' on the "Axes" tab (this is the same as ydatacolumn in the task) and hit plot button on the gui. Flip through again.
Now change '''Data Column''' to '''corrected''' on the "Axes" tab (this is the same as ydatacolumn in the task) and hit '''Plot''' button on the GUI. Flip through again.


'''Things to notice:'''
'''Things to notice:'''
Line 280: Line 450:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
for vis in data:
for asdm in basename_all:
   newvis = '%s_wvrtsys.ms' % (vis.split('.')[0])
   newvis = asdm + '_wvrtsys.ms'
   os.system('rm -rf ' + newvis)
   os.system('rm -rf ' + newvis)
   split(vis=vis,outputvis=newvis,datacolumn='corrected',spw=fdm)
   split(vis=asdm+'.ms',outputvis=newvis,datacolumn='corrected',spw=fdm)
</source>
</source>


Line 300: Line 470:
From here we begin to operate on the *wvrtsys.ms files.   
From here we begin to operate on the *wvrtsys.ms files.   


Before we begin flagging data, we unflag all data in the measurement sets.  If this is your first pass through this section of the guide, no data in the measurement sets will be flagged, and you can skip this step.  If you are rerunning the flagging commands below, this will reset your flag columns to their original state.
Before we begin flagging data, we unflag all data in the measurement sets.  If this is your first pass through this section of the guide, no data in the measurement sets will be flagged, and you can skip this step.  If you are rerunning the flagging commands below, this will reset your flag columns to their original state. (Warning messages about using task '''tflagdata''' can be ignored for now.)


<source lang="python">
<source lang="python">
Line 322: Line 492:
Next we inspect the data with {{plotms}} for additional issues that need flagging, first looking at amplitude vs. time for each of the three datasets. Use the '''green''' arrows on the plotms gui to cycle through spws.  
Next we inspect the data with {{plotms}} for additional issues that need flagging, first looking at amplitude vs. time for each of the three datasets. Use the '''green''' arrows on the plotms gui to cycle through spws.  


[[Image:Tsyswvr_time_spw0_X3x1.png|thumb|Amplitude as a function of time for X3c1_wvrtsys.ms, spw=0]]
<figure id="Tsyswvr_time_spw0_X3x1.png">
[[Image:Tsyswvr_time_spw0_X3x1.png|thumb|<caption>Amplitude as a function of time for X3c1_wvrtsys.ms, spw=0</caption>]]
</figure>


'''Note''': when iteraxis is invoked in {{plotms}}, unzoom does not always work properly. If you have trouble with this, flip to next page and then back to current one. this usually fixes the problem.
'''Note''': when '''iteraxis''' is invoked in {{plotms}}, unzoom does not always work properly. If you have trouble with this, flip to next page and then back to current one. This usually fixes the problem.


<source lang="python">
<source lang="python">
Line 344: Line 516:
</source>
</source>


[[Image:Tsyswvr_time_spw2corr_X3x1.png|thumb|Amplitude as a function of time for X3x1_wvrtsys.ms, spw=2 with colorize='corr'.]]
<figure id="Tsyswvr_time_spw2corr_X3x1.png">
[[Image:Tsyswvr_time_spw2corr_X3x1.png|thumb|<caption>Amplitude as a function of time for X3x1_wvrtsys.ms, spw=2 with colorize='corr'.</caption>]]
</figure>


'''Things to Notice:'''
'''Things to Notice:'''
Line 380: Line 554:


First we look at phase as a function of frequency for a well behaved antenna like DV06.  
First we look at phase as a function of frequency for a well behaved antenna like DV06.  
'''coloraxis='baselines'''' (note this parameter is called colorize in the gui, Display Tab) will show each baseline as a different color. Significant delay errors or baseline errors will show up as phase slopes in these plots. Again you will want to page through the spectral windows.
'''coloraxis='baselines'''' (note this parameter is called '''Colorize''' in the GUI "Display" tab) will show each baseline as a different color. Significant delay errors or baseline errors will show up as phase slopes in these plots. Again you will want to page through the spectral windows.


<source lang="python">
<source lang="python">
Line 402: Line 576:
Overall these plots look good with no large delays or baseline errors apparent.
Overall these plots look good with no large delays or baseline errors apparent.


[[Image:Birdies_spw2_X3x1.png|thumb|Phase calibrators (brown and green) and TW Hya (orange) showing both real CO(3-2) emission in TW Hya and weak ''birdie'' spectral features in all three sources for spw=2.]]
<figure id="Birdies_spw2_X3x1.png">
[[Image:Birdies_spw2_X3x1.png|thumb|<caption>Phase calibrators (brown and green) and TW Hya (orange) showing both real CO(3-2) emission in TW Hya and weak ''birdie'' spectral features in all three sources for spw=2.</caption>]]
</figure>


With such high spectral resolution data, one often sees occasional "birdies" in the data. These are typically very narrow weak spectral features that are internally generated in the system. Over time as we track down issues the number of birdies should decrease, but you should always check. This is easiest to do by looking at amplitude vs. frequency for sources observed over a long time range (for sensitivity). It is helpful to look at more than one source to verify the nature of the emission. Below we look at both calibrators (brown and green) and TW Hya (orange). If you have enough sensitivity birdies should be seen on all sources, however, be careful not to mistake real line emission for a birdie even on a calibrator - they can be present as we've seen for Titan.
With such high spectral resolution data, one often sees occasional "birdies" in the data. These are typically very narrow weak spectral features that are internally generated in the system. Over time as we track down issues the number of birdies should decrease, but you should always check. This is easiest to do by looking at amplitude vs. frequency for sources observed over a long time range (for sensitivity). It is helpful to look at more than one source to verify the nature of the emission. Below we look at both calibrators (brown and green) and TW Hya (orange). If you have enough sensitivity birdies should be seen on all sources, however, be careful not to mistake real line emission for a birdie even on a calibrator - they can be present as we've seen for Titan.


[[Image:Birdies_spw3_X3x1.png|thumb|Phase calibrators (brown and green) and TW Hya (orange) showing only weak birdie spectral features in spw=3.]]
<figure id="Birdies_spw3_X3x1.png">
[[Image:Birdies_spw3_X3x1.png|thumb|<caption>Phase calibrators (brown and green) and TW Hya (orange) showing only weak birdie spectral features in spw=3.</caption>]]
</figure>


<source lang="python">
<source lang="python">
Line 447: Line 625:
In this section, we will flag spectral features in the calibrators so they do not skew the calibration solutions. First make plots of 3C279 and Titan in channel space to get channels for flagging.   
In this section, we will flag spectral features in the calibrators so they do not skew the calibration solutions. First make plots of 3C279 and Titan in channel space to get channels for flagging.   


[[Image:3C279_Titan_spw1.png|thumb|Spectral plots of 3C279 (black) and Titan (magenta) for spw=1 after Tsys and wvr correction.]]
<figure id="3C279_Titan_spw1.png">
[[Image:3c279_meso_freq.png|thumb|Zoomed spectral plot of 3C279 showing mesospheric absorption of CO(3-2) in frequency space.]]
[[Image:3C279_Titan_spw1.png|thumb|<caption>Spectral plots of 3C279 (black) and Titan (magenta) for spw=1 after Tsys and wvr correction.</caption>]]
[[Image:3c279_meso_chann.png|thumb|Zoomed spectral plot of 3C279 showing mesospheric absorption of CO(3-2) in channel space.]]
</figure>
<figure id="3c279_meso_freq.png">
[[Image:3c279_meso_freq.png|thumb|<caption>Zoomed spectral plot of 3C279 showing mesospheric absorption of CO(3-2) in frequency space.</caption>]]
</figure>
<figure id="3c279_meso_chann.png">
[[Image:3c279_meso_chann.png|thumb|<caption>Zoomed spectral plot of 3C279 showing mesospheric absorption of CO(3-2) in channel space.</caption>]]
</figure>


<source lang="python">
<source lang="python">
Line 508: Line 692:
</source>
</source>


[[Image:Titan_spw2.png|thumb|Spectral plot of Titan (magenta) for spw=2.]]
<figure id="Titan_spw2.png">
[[Image:Titan_spw2.png|thumb|<caption>Spectral plot of Titan (magenta) for spw=2.</caption>]]
</figure>


Flag absorption features for all sources.
Flag absorption features for all sources.
Line 519: Line 705:
</source>
</source>


[[Image:Titan_spw3.png|thumb|Spectral plot of Titan (magenta) for spw=3.]]
<figure id="Titan_spw3.png">
[[Image:Titan_spw3.png|thumb|<caption>Spectral plot of Titan (magenta) for spw=3.</caption>]]
</figure>


Now we need to flag emission. The very broad CO(3-2) in spw=2 of Titan will prevent us from using it as a calibrator for this spectral window since there are no line-free channels (we will transfer, phase, amplitude, and absolute flux from another Titan spw below). We do want to flag the narrower Titan line in spw=3.
Now we need to flag emission. The very broad CO(3-2) in spw=2 of Titan will prevent us from using it as a calibrator for this spectral window since there are no line-free channels (we will transfer, phase, amplitude, and absolute flux from another Titan spw below). We do want to flag the narrower Titan line in spw=3.
Line 557: Line 745:
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
for asdm in basename:
   setjy(vis=asdm+'.ms',field='1',
   setjy(vis=asdm+'.ms',field='1',usescratch=F,
         standard='Butler-JPL-Horizons 2010',scalebychan=F)
         standard='Butler-JPL-Horizons 2010',scalebychan=F)
</source>
</source>


==Bandpass Calibration==
<figure id="Titan amp vs uvdist.png">
[[Image:ThreeScansAmp.png|thumb|Amplitude variation for three 3C279 scans (for one representative baseline).]]
[[Image:Titan amp vs uvdist.png|thumb|<caption>Plot of Titan model for each of the 4 spws.</caption>]]
[[Image:ThreeScansPhase.png|thumb|Phase variation for three 3C279 scans (for one representative baseline).]]
</figure>


First we need to check how the amplitude and phase of 3C279 behave as a function of time.
After running setjy, it is a good idea to plot the model in order to confirm that it makes sense.  In this case, Titan is partially resolved, so we expect the flux density to drop with uv distance, but not so much as to pass through a null.  We also expect it to be brighter at higher frequencies since it has a thermal blackbody spectrum.


<source lang="python">
<source lang="python">
# In CASA
# In CASA
for asdm in basename:
for asdm in basename:
   plotms(vis=asdm+'.ms',spw='',xaxis='time',yaxis='amp',
   plotms(vis=asdm+'.ms',field='1',xaxis='uvdist',yaxis='amp',coloraxis='spw',
        field='0',avgchannel='3840',iteraxis='spw')
        ydatacolumn='model')
   print('When you are done with the graphics window,')
   print('When you are done with the graphics window,')
   print('quit that window, and')
   print('quit that window, and')
Line 577: Line 765:
</source>
</source>


Page through the spws. This shows significant variations in the amplitude across the three scans.
==Bandpass Calibration==
 
First we need to check how the amplitude and phase of 3C279 behave as a function of time. In order to set
a fixed scale on the y-axis, we first make a plot of all the data, excluding antenna DV04.  (We must specify '''ydatacolumn='data' ''' explicitly here because the default value of '''ydatacolumn''' equals the value used in the previous execution of {{plotms}}.  In the previous execution '''ydatacolumn''' was set to '''model'''.  See the online help, <tt>help plotms</tt>, for details.)


<source lang="python">
<source lang="python">
# In CASA
# In CASA
for asdm in basename:
plotms(vis='X3c1_wvrtsys.ms',xaxis='time',yaxis='amp',coloraxis='corr',
  plotms(vis=asdm+'.ms',spw='0',xaxis='time',yaxis='phase',
      field='0',avgchannel='3840',ydatacolumn='data')
        antenna='DV06;!DV04',coloraxis='corr',
</source>
        field='0',avgchannel='3840',iteraxis='baseline')
 
  print('When you are done with the graphics window,')
<figure id="ThreeScansAmp.png">
   print('quit that window, and')
[[Image:ThreeScansAmp.png|thumb|<caption>Amplitude variation for three 3C279 scans, spw 0 (for one representative baseline).</caption>]]
  user_check=raw_input('press enter to continue script\n')
</figure>
 
We see that the uncalibrated amplitudes range between 0.2-0.4, so let's set this as our
scale and examine a representative baseline (DV06-DV07) to see how the amplitude changes with time.
 
<source lang="python">
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for spw in ['0','1','2','3']:
  for asdm in basename:
    print "Now showing spw %s from %s" % (spw, asdm+'.ms')
    plotms(vis=asdm+'.ms',spw=spw,xaxis='time',yaxis='amp',coloraxis='corr',iteraxis='spw',
          field='0',avgchannel='3840',antenna='DV06&DV07',plotrange=[0,0,0.2,0.4])
    user_check=raw_input('press enter to go to the next plot\n')
</source>
 
<figure id="ThreeScansPhase.png">
[[Image:ThreeScansPhase.png|thumb|<caption>Phase variation for three 3C279 scans, spw 0 (for one representative baseline).</caption>]]
</figure>
 
Page through the measurement sets for each spw. This shows significant variations in the amplitude across the three measurement sets.
Now do the same with phase.
 
<source lang="python">
# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for spw in ['0','1','2','3']:
   for asdm in basename:
    print "Now showing spw %s from %s" % (spw, asdm+'.ms')
    plotms(vis=asdm+'.ms',spw=spw,xaxis='time',yaxis='phase',coloraxis='corr',iteraxis='spw',
          field='0',avgchannel='3840',antenna='DV06&DV07',plotrange=[0,0,-180,180])
    user_check=raw_input('press enter to go to the next plot\n')
</source>
</source>


Page through the baselines to DV06. This examination reveals two findings: (1) significant variation in the phase across the three scans, as well as (2) smaller but significant variations within a scan. The first finding suggests that we do not want to combine the scans for bandpass calibration, but instead derive an independent bandpass for each scan. Actually what is more important than a DC offset is if the '''shape''' of the amplitude or phase changes from scan to scan. There isn't enough S/N to tell for sure so we will keep them separate. The second finding suggests that we need to correct the phase vs. time behavior of the bandpass calibrator (3C279; field=0) within each scan, before doing the bandpass. We want to chose a relatively narrow range of channels near the center of the spws so that the bandpass phase slopes (to be corrected with the bandpass calibration itself) do not decorrelate the signal. You need to avoid spectral regions that were completely flagged above.
This examination reveals two findings: (1) significant variation in the phase across the three scans, as well as (2) smaller but significant variations within a scan. The first finding suggests that we do not want to combine the scans for bandpass calibration, but instead derive an independent bandpass for each scan. Actually what is more important than a DC offset is if the '''shape''' of the amplitude or phase changes from scan to scan. There isn't enough S/N to tell for sure so we will keep them separate. This situation is often the case, which is why we did not concatenate the three datasets prior to calibration. The second finding suggests that we need to correct the phase vs. time behavior of the bandpass calibrator (3C279; field=0) within each scan, before doing the bandpass. We want to chose a relatively narrow range of channels near the center of the spws so that the bandpass phase slopes (to be corrected with the bandpass calibration itself) do not decorrelate the signal. You need to avoid spectral regions that were completely flagged above.


<source lang="python">
<source lang="python">
# In CASA
# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
for asdm in basename:
  os.system('rm -rf ' + asdm + '.bpphase.gcal')
   gaincal(vis=asdm+'.ms',caltable=asdm+'.bpphase.gcal',
   gaincal(vis=asdm+'.ms',caltable=asdm+'.bpphase.gcal',
           field='0',spw='0~3:900~1100',refant='DV06',
           field='0',spw='0~3:900~1100',refant='DV06',
Line 600: Line 823:
</source>
</source>


[[Image:X7ef_wvrtsys.bpphase.X.png|thumb|Phase only solutions for correlation X on the third scan of the bandpass calibrator 3C279.]]
<figure id="X7ef_wvrtsys.bpphase.X.png">
[[Image:X7ef_wvrtsys.bpphase.X.png|thumb|<caption>Phase only solutions for correlation X on the third scan of the bandpass calibrator 3C279.</caption>]]
</figure>


Inspect the phase-only calibration solutions for the bandpass calibrator. Look for any noisy solutions. We do XX and YY separately to reduce confusion in the plot. It will help if you make your plotcal window wide.
Inspect the phase-only calibration solutions for the bandpass calibrator. Look for any noisy solutions. We do XX and YY separately to reduce confusion in the plot. It will help if you make your plotcal window wide.
Line 606: Line 831:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
for asdm in basename:
   plotcal(caltable=asdm+'.bpphase.gcal',xaxis='time',yaxis='phase',spw='',antenna='1~8',  
   plotcal(caltable=asdm+'.bpphase.gcal',xaxis='time',yaxis='phase',spw='',antenna='1~8',  
Line 619: Line 845:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
for asdm in basename:
   plotcal(caltable=asdm+'.bpphase.gcal',xaxis='time',yaxis='phase',spw='',antenna='1~8',  
   plotcal(caltable=asdm+'.bpphase.gcal',xaxis='time',yaxis='phase',spw='',antenna='1~8',  
Line 632: Line 859:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
for asdm in basename:
  os.system('rm -rf ' + asdm + '.bandpass.bcal')
   bandpass(vis=asdm+'.ms',caltable=asdm+'.bandpass.bcal',
   bandpass(vis=asdm+'.ms',caltable=asdm+'.bandpass.bcal',
           field='0',spw='',combine='',refant='DV06',
           field='0',spw='',combine='',refant='DV06',
Line 639: Line 868:
</source>
</source>


You will see some error messages, these are just related to the flagged channels. We set fillgaps=17 to interpolate across the smaller regions of flagged channels (mesospheric features and birdies).
You will see some error messages in the terminal, these are just related to the flagged channels. We set fillgaps=17 to interpolate across the smaller regions of flagged channels (mesospheric features and birdies).


[[Image:Bandpass.ampspw0.png|thumb|Bandpass amplitude plots.]]
<figure id="Bandpass.ampspw0.png">
[[Image:Bandpass.phasespw0.png|thumb|Bandpass phase plots.]]
[[Image:Bandpass.ampspw0.png|thumb|<caption>Bandpass amplitude solution plots.</caption>]]
</figure>
<figure id="Bandpass.phasespw0.png">
[[Image:Bandpass.phasespw0.png|thumb|<caption>Bandpass phase solution plots.</caption>]]
</figure>


'''A few words about solint and combine:'''
'''A few words about solint and combine:'''
Line 649: Line 882:
solution for each 3C279 scan, '''unless''' '''combine='scan'''' (which is the default). Here we set combine=' ' explicitly so that it does not combine the scans into one bandpass. Likewise, field boundaries are only crossed if combine='field', and spw boundaries are only crossed if combine='spw'.  In some cases it can be helpful to combine fields if you suffer from lack of S/N, but it is never a good idea to combine spws.  
solution for each 3C279 scan, '''unless''' '''combine='scan'''' (which is the default). Here we set combine=' ' explicitly so that it does not combine the scans into one bandpass. Likewise, field boundaries are only crossed if combine='field', and spw boundaries are only crossed if combine='spw'.  In some cases it can be helpful to combine fields if you suffer from lack of S/N, but it is never a good idea to combine spws.  


Now inspect the phase and amplitude solutions. You are looking for excursions from smooth fits, or particularly noisy solutions compared to the others. These plots take a while because there are so many channels per spw (3840!).
Now inspect the phase and amplitude solutions. You are looking for excursions from smooth fits, or particularly noisy solutions compared to the others.  


<source lang="python">
<source lang="python">
# In CASA
# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
for asdm in basename:
  plotcal(caltable=asdm+'.bandpass.bcal',xaxis='freq',yaxis='amp',antenna='1~8',
    for spw in [0,1,2,3]:
          iteration='antenna',subplot=421,spw='0',figfile=asdm+'.bandpass.ampspw0.png')
        au.plotbandpass(asdm+'.bandpass.bcal',xaxis='freq',yaxis='amp', spw=spw,
  print('When you are done with the graphics window,')
            antenna='1~8', subplot=421, figfile=asdm+'.bandpass.amp', showatm=T,
  print('quit that window, and')
            interactive=True)
  user_check=raw_input('press enter to continue script\n')
</source>
</source>


<source lang="python">
<source lang="python">
# In CASA
# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
for asdm in basename:
  plotcal(caltable=asdm+'.bandpass.bcal',xaxis='freq',yaxis='phase',antenna='1~8',
    for spw in [0,1,2,3]:
          iteration='antenna',subplot=421,spw='0',figfile=asdm+'.bandpass.phasespw0.png')
        au.plotbandpass(asdm+'.bandpass.bcal',xaxis='freq',yaxis='phase',spw=spw,
  print('When you are done with the graphics window,')
            antenna='1~8',subplot=421,figfile=asdm+'.bandpass.phs', showatm=T,
  print('quit that window, and')
            interactive=True)
  user_check=raw_input('press enter to continue script\n')
</source>
</source>


The values of phase on DV06 are very small because it was used as the reference antenna.
The values of phase on DV06 are very close to zero because it was used as the reference antenna.
 
These plots should be repeated for each spw. Be sure to rename the plot's file each time before running.


==Gain Calibration==
==Gain Calibration==
Line 683: Line 914:
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
for asdm in basename:
  os.system('rm -rf ' + asdm + '.intphase.gcal')
   gaincal(vis=asdm+'.ms',caltable=asdm+'.intphase.gcal',
   gaincal(vis=asdm+'.ms',caltable=asdm+'.intphase.gcal',
           field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
           field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
Line 689: Line 921:
</source>
</source>


Here solint='int' coupled with calmode='p' will derive a single phase solution for each 10 second integration. Note that the bandpass table is applied on-the-fly before solving for the phase solutions, however the bandpass is NOT applied to the data permanently until applycal is run later on.  
Here '''solint='int' ''' coupled with '''calmode='p' ''' will derive a single phase solution for each 10 second integration. Note that the bandpass table is applied on-the-fly before solving for the phase solutions, however the bandpass is NOT applied to the data permanently until applycal is run later on.  


Although solint='int' (i.e. the integration time of 10 seconds) is the best choice to apply before for solving for the amplitude solutions, it is not a good idea to use this to apply to the target. This is because the phase-scatter within a scan can dominate the interpolation between calibrator scans. Instead, we also solve for the phase on the scan time, solint='inf' (but combine=' ', since we want one solution per scan) for application to the target later on. Unlike the bandpass task, for {{gaincal}}, the default of the combine parameter is combine=' '.  
Although '''solint='int' ''' (i.e. the integration time of 10 seconds) is the best choice to apply before solving for the amplitude solutions, it is not a good idea to use this to apply to the target. This is because the phase-scatter within a scan can dominate the interpolation between calibrator scans. Instead, we also solve for the phase on the scan time, '''solint='inf' ''' (but '''combine=' ' ''', since we want one solution per scan) for application to the target later on. Unlike the bandpass task, for {{gaincal}}, the default of the combine parameter is '''combine=' ' '''.  


<source lang="python">
<source lang="python">
# In CASA
# In CASA
for asdm in basename:
for asdm in basename:
  os.system('rm -rf ' + asdm + '.scanphase.gcal')
   gaincal(vis=asdm+'.ms',caltable=asdm+'.scanphase.gcal',
   gaincal(vis=asdm+'.ms',caltable=asdm+'.scanphase.gcal',
           field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
           field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
Line 704: Line 937:
Alternatively, instead of making a separate phase solution for application to the target, one can also run {{smoothcal}} to smooth the solutions derived on the integration time.  
Alternatively, instead of making a separate phase solution for application to the target, one can also run {{smoothcal}} to smooth the solutions derived on the integration time.  


Next we apply the bandpass and solint='int' phase-only calibration solutions on-the-fly to derive amplitude solutions. Here the use of solint='inf', but combine=' ' will result in one solution per scan interval.  
Next we apply the bandpass and '''solint='int' ''' phase-only calibration solutions on-the-fly to derive amplitude solutions. Here the use of '''solint='inf' ''', but '''combine=' ' ''' will result in one solution per scan interval.  


<source lang="python">
<source lang="python">
# In CASA
# In CASA
for asdm in basename:
for asdm in basename:
  os.system('rm -rf ' + asdm + '.amp.gcal')
   gaincal(vis=asdm+'.ms',caltable=asdm+'.amp.gcal',
   gaincal(vis=asdm+'.ms',caltable=asdm+'.amp.gcal',
           field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
           field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
Line 718: Line 952:


We make plots in X and Y separately for clarity. The colors are showing the spectral windows.
We make plots in X and Y separately for clarity. The colors are showing the spectral windows.
[[Image:X3c1_wvrtsys.intphase_X.png|thumb|Phase solutions for the X polarization for every integration time of the first dataset.]]
<figure id="X3c1_wvrtsys.intphase_X.png">
[[Image:X3c1_wvrtsys.scanphase_X.png|thumb|Phase solutions for the X polarization for each scan of the first dataset.]]
[[Image:X3c1_wvrtsys.intphase_X.png|thumb|<caption>Phase solutions for the X polarization for every integration time of the first dataset.</caption>]]
</figure>


<source lang="python">
<source lang="python">
Line 742: Line 977:
   user_check=raw_input('press enter to continue script\n')
   user_check=raw_input('press enter to continue script\n')
</source>
</source>
<figure id="X3c1_wvrtsys.scanphase_X.png">
[[Image:X3c1_wvrtsys.scanphase_X.png|thumb|<caption>Phase solutions for the X polarization for each scan of the first dataset.</caption>]]
</figure>


<source lang="python">
<source lang="python">
Line 765: Line 1,004:
</source>
</source>


[[Image:X3c1_wvrtsys.amp_phase.png|thumb|Residual phase after applying intphase.gcal for both correlations in the first dataset.]]
Since we have taken out the phase as best we can by applying the '''solint='int' ''' phase-only solution, this plot will give a good idea of the residual phase error. If you see scatter of more than a few degrees here, you should consider going back and looking for more data to flag, particularly bad timeranges etc.  
[[Image:X3c1_wvrtsys.amp_X.png|thumb|Amplitude solutions on a scan interval for correlation X in the first dataset.]]


Since we have taken out the phase as best we can by applying the solint='int' phase-only solution, this plot will give a good idea of the residual phase error. If you see scatter of more than a few degrees here, you should consider going back and looking for more data to flag, particularly bad timeranges etc.  
<figure id="X3c1_wvrtsys.amp_phase.png">
[[Image:X3c1_wvrtsys.amp_phase.png|thumb|<caption>Residual phase after applying intphase.gcal for both correlations in the first dataset.</caption>]]
</figure>
<figure id="X3c1_wvrtsys.amp_X.png">
[[Image:X3c1_wvrtsys.amp_X.png|thumb|<caption>Amplitude solutions on a scan interval for correlation X in the first dataset.</caption>]]
</figure>


<source lang="python">
<source lang="python">
Line 812: Line 1,055:
# In CASA
# In CASA
for asdm in basename:
for asdm in basename:
  os.system('rm -rf ' + asdm + '.flux.cal')
   fluxscale(vis=asdm+'.ms',caltable=asdm+'.amp.gcal',
   fluxscale(vis=asdm+'.ms',caltable=asdm+'.amp.gcal',
             fluxtable=asdm+'.flux.cal',reference='1',refspwmap=[0,1,3,3]
             fluxtable=asdm+'.flux.cal',reference='1',refspwmap=[0,1,3,3],
             listfile=asdm+'.fluxscale.txt')
             listfile=asdm+'.fluxscale.txt')
</source>
</source>
Line 837: Line 1,081:
</pre>
</pre>


[[Image:x3c1_wvrtsys.flux_X.png|thumb|Absolute flux calibration solutions for correlation X for the first dataset.]]
<figure id="x3c1_wvrtsys.flux_X.png">
[[Image:x3c1_wvrtsys.flux_X.png|thumb|<caption>Absolute flux calibration solutions for correlation X for the first dataset.</caption>]]
</figure>


Now look at the flux solutions.
Now look at the flux solutions.
Line 865: Line 1,111:
==Apply Calibration and Inspect==
==Apply Calibration and Inspect==


Now we can use the {{flagmanager}} to restore the spectral flagging we did on the calibrators.
Now we can use the {{flagmanager}} if we want to restore any of the spectral flagging we did prior to bandpass calibration. 
In this case, we choose to restore the flags of the emission lines on Titan, because we are interested in seeing how
strong they are compared to the continuum.  However, we leave the strong ozone line and mesospheric CO line flagged on all
sources, because we want to get the most accurate continuum flux density for the science target.


<source lang="python">
<source lang="python">
Line 871: Line 1,120:
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
for asdm in basename:
   flagmanager(vis=asdm+'.ms',mode='restore',versionname=asdm+'.before_calspectralflags')
   flagmanager(vis=asdm+'.ms',mode='restore',versionname=asdm+'.before_emissionflags')
</source>
</source>


Next we apply the calibration solutions to each source individually, using the '''gainfield''' parameter to specify which calibrators solutions should be applied from each of the '''gaintable''' calibration tables.  
Next we apply the calibration solutions to each source individually, using the '''gainfield''' parameter to specify which calibrator's solutions should be applied from each of the '''gaintable''' calibration tables.  


First, we do 3C279 (the bandpass calibrator), applying all 3 of its solutions to itself (that's why gainfield contains three zeros):
First, we do 3C279 (the bandpass calibrator), applying all 3 of its solutions to itself (that's why gainfield contains three zeros):
Line 933: Line 1,182:
Now we can check the results of applying the calibration solutions.
Now we can check the results of applying the calibration solutions.


[[Image:Corrected_vs_time_1.png|thumb|The calibrated data for the first dataset as a function of time.]]
<figure id="Corrected_vs_time_1.png">
[[Image:Corrected_vs_time_1.png|thumb|<caption>The calibrated data for the first dataset (amplitude vs. time).</caption>]]
</figure>


<source lang="python">
<source lang="python">
Line 945: Line 1,196:
</source>
</source>


Looks good but there are some noisy points toward the end of the first scheduling block, but it mostly only affects the secondary phase calibrator (green). Let's check whether it improves when we apply this calibrator's solutions to itself rather than transferring from the primary phase calibrator.
In amplitude, it looks good but there are some noisy points toward the end of the first scheduling block, but it mostly only affects the secondary phase calibrator (green). In phase, we expect all the points to cluster about zero. The large scatter in phase on the secondary phase calibrator is readily apparent:
 
<figure id="Corrected_phase_vs_time_1.png">
[[Image:Corrected_phase_vs_time_1.png|thumb|<caption>The calibrated data on the calibrators for the first dataset (phase vs. time).</caption>]]
</figure>
 
<source lang="python">
# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='time',yaxis='phase',field='0,1,3,4',avgchannel='3840',
        coloraxis='field',iteraxis='spw',ydatacolumn='corrected')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')
</source>
 
Let's check whether the situation improves when we apply this calibrator's solutions to itself rather than transferring the solutions from the primary phase calibrator (which is 17 degrees away, and observed at a different time).  


<source lang="python">
<source lang="python">
Line 953: Line 1,220:
           gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],
           gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],
           interp=['nearest','nearest','nearest'],
           interp=['nearest','nearest','nearest'],
           gainfield=['0','3','3'],flagbackup=T)
           gainfield=['0','3','3'],flagbackup=T, calwt=T)
</source>
 
<figure id="Corrected_vs_time_1_field3.png">
[[Image:Corrected_vs_time_1_field3.png|thumb|<caption>The calibrated data for the first dataset (amplitude vs. time), but now with field 3, the secondary phase calibrator, calibrated with itself.</caption>]]
</figure>


<source lang="python">
# In CASA
# In CASA
for asdm in basename:
for asdm in basename:
Line 964: Line 1,237:
</source>
</source>


[[Image:Corrected_vs_time_1_field3.png|thumb|The calibrated data from the first dataset as a function of time, but now with field 3, the secondary phase calibrator, calibrated with itself.]]
<figure id="Corrected_phase_vs_time_1_field3.png">
 
[[Image:Corrected_phase_vs_time_1_field3.png|thumb|<caption>The calibrated data from the first dataset (phase vs. time), but now with field 3, the secondary phase calibrator, calibrated with itself.</caption>]]
Indeed it looks better now. This is an indication that the amplitude calibration is not working well in this timerange. Since the effect is pretty small and we know we can self-cal later, we let this go for now. Or if you want you can delve deeper into the data and try to solve the mystery...  In any case, so that we can check the effect of correcting the secondary phase calibrator with the primary phase calibrator, we will re-issue the original {{applycal}} so that it is this calibration that our subsequent {{split}} will use.
</figure>


<source lang="python">
<source lang="python">
# In CASA
# In CASA
for asdm in basename:
for asdm in basename:
   applycal(vis=asdm+'.ms',field='3',
   plotms(vis=asdm+'.ms',spw='',xaxis='time',yaxis='phase',field='0,1,3,4',
          gaintable=[asdm+'.bandpass.bcal', asdm+'.scanphase.gcal', asdm+'.flux.cal'],
        avgchannel='3840', coloraxis='field',iteraxis='spw',
          interp=['nearest','linear','linear'],
        ydatacolumn='corrected')
          gainfield=['0','4','4'], flagbackup=T, calwt=F)
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')
</source>
</source>


Indeed, the secondary calibrator looks better now in amplitude and phase. This is an indication that the calibration transfer is not working well in this timerange. Because the effect is not catastrophic and we know we can self-calibrate on TW Hya later, we will let this go for now. Or, if you want you can delve deeper into the data and try to solve the mystery...


Now, let's have a look at the corrected phase of the calibrators. If all has worked well, then they should be near zero.
In any case, we will re-issue the original {{applycal}} so that it is this calibration that our subsequent {{split}} will use.  This will allow us to check the effect of correcting the secondary phase calibrator with the primary phase calibrator later.  
 
[[Image:Corrected_phase..png|thumb|The corrected phase as a function of time for all calibrators.]]


<source lang="python">
<source lang="python">
# In CASA
# In CASA
for asdm in basename:
for asdm in basename:
   plotms(vis=asdm+'.ms',spw='',xaxis='time',yaxis='phase',field='0,1,3,4',
   applycal(vis=asdm+'.ms',field='3',
        avgchannel='3840',coloraxis='field',iteraxis='spw',ydatacolumn='corrected')
          gaintable=[asdm+'.bandpass.bcal', asdm+'.scanphase.gcal', asdm+'.flux.cal'],
  print('When you are done with the graphics window,')
          interp=['nearest','linear','linear'],
  print('quit that window, and')
          gainfield=['0','4','4'], flagbackup=T, calwt=F)
  user_check=raw_input('press enter to continue script\n')
</source>
</source>


Indeed, these look very reasonable.


Let's check the spectral calibration now. First 3C279 and Titan:
Let's check the spectral calibration now. First 3C279 and Titan:


[[Image:X3c1_spw2_corrected_3.4.png|thumb|Spectral UV-plots of 3C279 and Titan of spw=2 for the first dataset.]]
<figure id="X3c1_spw2_corrected_3.4.png">
[[Image:X3c1_spw2_corrected_3.4.png|thumb|<caption>Spectral UV-plots of 3C279 and Titan of spw=2 for the first dataset.</caption>]]
</figure>


<source lang="python">
<source lang="python">
Line 1,036: Line 1,310:
   user_check=raw_input('press enter to continue script\n')
   user_check=raw_input('press enter to continue script\n')
</source>
</source>
[[Image:X3c1_CO3_2_uvplot_3.4.png|thumb|UV-Plot of the TW Hya CO(3-2) emission.]]
[[Image:X3c1_HCOp4_3_uvplot_3.4.png|thumb|UV-Plot of the TW Hya HCO+(4-3) emission.]]


We see HCO+(4-3) in spw=0 and CO(3-2) in spw=2 as expected. Because the shape of the  
We see HCO+(4-3) in spw=0 and CO(3-2) in spw=2 as expected. Because the shape of the  
line profiles varies with baseline, you can already tell that the line emission is resolved.
line profiles varies with baseline, you can already tell that the line emission is resolved.
<figure id="X3c1_CO3_2_uvplot_3.4.png">
[[Image:X3c1_CO3_2_uvplot_3.4.png|thumb|<caption>UV-Plot of the TW Hya CO(3-2) emission from the first dataset.</caption>]]
</figure>
<figure id="X3c1_HCOp4_3_uvplot_3.4.png">
[[Image:X3c1_HCOp4_3_uvplot_3.4.png|thumb|<caption>UV-Plot of the TW Hya HCO+(4-3) emission from the first dataset.</caption>]]
</figure>


Now check that the velocity of TWHydra is correct in the LSRK frame, it should be around 2.88 km/s.
Now check that the velocity of TWHydra is correct in the LSRK frame, it should be around 2.88 km/s.
Line 1,051: Line 1,329:
for asdm in basename:
for asdm in basename:
   plotms(vis=asdm+'.ms',spw='2',xaxis='velocity',yaxis='amp',field='2',
   plotms(vis=asdm+'.ms',spw='2',xaxis='velocity',yaxis='amp',field='2',
         avgtime='1e8',avgscan=T,transform=T,freqframe='LSRK',restfreq='345.79599GHz',
         avgtime='1e8',avgscan=T,transform=T,freqframe='LSRK',
        plotrange=[-10,15,0,0],coloraxis='spw')
        restfreq='345.79599GHz', plotrange=[-10,15,0,0],coloraxis='spw')
   print('When you are done with the graphics window,')
   print('When you are done with the graphics window,')
   print('quit that window, and')
   print('quit that window, and')
Line 1,062: Line 1,340:
for asdm in basename:
for asdm in basename:
   plotms(vis=asdm+'.ms',spw='0',xaxis='velocity',yaxis='amp',field='2',
   plotms(vis=asdm+'.ms',spw='0',xaxis='velocity',yaxis='amp',field='2',
         avgtime='1e8',avgscan=T,transform=T,freqframe='LSRK',restfreq='356.7342GHz',
         avgtime='1e8',avgscan=T,transform=T,freqframe='LSRK',
        plotrange=[-10,15,0,0],coloraxis='spw')
        restfreq='356.7342GHz',plotrange=[-10,15,0,0],coloraxis='spw')
   print('When you are done with the graphics window,')
   print('When you are done with the graphics window,')
   print('quit that window, and')
   print('quit that window, and')
Line 1,070: Line 1,348:


Both lines show up at the expected velocity.
Both lines show up at the expected velocity.


==Concatenate the Data==
==Concatenate the Data==


Here we will concatenate the three datasets for convenience. '''WARNING''': if the different data sets are not taken close together in time it is dangerous to combine them in this way before calibration, it can be particularly difficult if the antennas have moved in the mean time. In that case it is best to calibrate each dataset independently and then only combine the calibrated data for imaging.  
Here we will concatenate the three datasets prior to imaging.


<source lang="python">
<source lang="python">
Line 1,086: Line 1,365:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
listobs(vis='Band7multi_april22.ms',verbose=F)
listfile = 'Band7multi_april22.listobs.txt'
os.system('rm ' + listfile)
listobs(vis='Band7multi_april22.ms',verbose=F, listfile=listfile)
</source>
</source>


==Fix Titan's Coordinates==
<figure id="All_spw2_corrected_3.4.png">
 
[[Image:All_spw2_corrected_3.4.png|thumb|<caption>Spectral UV-plots of 3C279 and Titan of spw=2 for the combined datasets.</caption>]]
'''Note that in the near future this step will be unnecessary.'''
</figure>
 
It is temporarily necessary to correct the positions of ephemeris objects observed by ALMA, as they are currently erroneously written to the data with coordinates of 00:00:00.0000 +00.00.00.0000 J2000 (see {{listobs}} output in [[TWHydraBand7_Calibration#Observing_Log_and_Priors]]).  For this data we need to correct Titan which we observed as the absolute flux calibrator. It is important to apply the fix after concatenation of the data, or Titan will be at slightly different positions in all three datasets.
 
If you are running casa revision r15777 or newer, fixplanets() is already defined as a task.  However, if you are using an older revision, then you must first initialize this script with this command:


execfile(casadef.python_library_directory+'/recipes/fixplanets.py')
You can also examine the spectral uv plots for the combined dataset to see the improvement in S/N:
 
Now fix the position of Titan. This step takes a while because the model and corrected scratch columns must be created for the new dataset first (see logger message).


<source lang="python">
<source lang="python">
# In CASA
# In CASA
fixplanets(vis='Band7multi_april22.ms', field='Titan', fixuvw=True)
plotms(vis='Band7multi_april22.ms',spw='',xaxis='frequency',yaxis='amp',field='0,1',
      avgtime='1e8',avgscan=T,coloraxis='field',ydatacolumn='corrected',
      iteraxis='spw',xselfscale=T)
</source>
</source>


Check the header information again to see that the information for Titan has changed.
<figure id="All_CO3_2_uvplot_3.4.png">
[[Image:All_CO3_2_uvplot_3.4.png|thumb|<caption>UV-Plot of the TW Hya CO(3-2) emission from the combined datasets.</caption>]]
</figure>
 
...and the CO line profile for the combined dataset:


<source lang="python">
<source lang="python">
# In CASA
# In CASA
listobs(vis='Band7multi_april22.ms',verbose=F)
plotms(vis='Band7multi_april22.ms',spw='2',xaxis='velocity',yaxis='amp',field='2',
        avgtime='1e8',avgscan=T,transform=T,freqframe='LSRK',restfreq='345.79599GHz',
        plotrange=[-10,15,0,0],coloraxis='spw')
</source>
</source>
<pre style="background-color: #fffacd;">
  ID  Code Name        RA            Decl          Epoch  SrcId
  0    none 3c279        12:56:11.1666 -05.47.21.5247 J2000  0   
  1    none Titan        12:49:26.5120 -02.22.10.8190 J2000  1   
  2    none TW Hya      11:01:51.9063 -34.42.17.0212 J2000  2   
  3    none J1147-382=Q* 11:47:01.3815 -38.12.11.1179 J2000  3   
  4    none J1037-295=Q* 10:37:16.0899 -29.34.02.9888 J2000  4   
</pre>


==Split Calibrated Data==
==Split Calibrated Data==
Line 1,137: Line 1,411:
os.system('rm -rf J1037_corrected.ms')
os.system('rm -rf J1037_corrected.ms')
split(vis='Band7multi_april22.ms',outputvis='J1037_corrected.ms',
split(vis='Band7multi_april22.ms',outputvis='J1037_corrected.ms',
      datacolumn='corrected',spw='',field='4')
    datacolumn='corrected',spw='',field='4')
</source>
</source>


Line 1,149: Line 1,423:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
os.system('rm -rf J1147_corrected_with4.ms')
os.system('rm -rf 3C279_CO3_2.ms')
split(vis='Band7multi_april22.ms',outputvis='J1147_corrected_with4.ms',
split(vis='Band7multi_april22.ms',outputvis='3C279_CO3_2.ms',
       datacolumn='corrected',spw='',field='3')
       datacolumn='corrected',spw='2:1900~2000',field='0')
</source>
 
==Optional: Reconcile Titan's Coordinates==
 
If you do not care to image Titan, then you can skip this step and simply continue on to the [http://casaguides.nrao.edu/index.php?title=TWHydraBand7_Imaging_3.4 imaging guide].
 
Our earlier treatment of Titan's coordinates using [http://casa.nrao.edu/stable/docs/TaskRef/fixplanets-task.html fixplanets] replaced the zeros written by the ALMA control system with the correct position of the body at the instant of the first observation of that SB.  As a result, it has slightly different positions in all three datasets, as seen by listobs:
 
<source lang="python">
# In CASA
listobs(vis='Band7multi_april22.ms',verbose=F)
</source>
 
<pre style="background-color: #fffacd;">
ID  Code Name                RA              Decl          Epoch  SrcId nRows 
0    none 3c279              12:56:11.16657 -05.47.21.5247 J2000  0    70866 
1    none Titan              12:49:25.97588 -02.22.41.3024 J2000  1    4842 
2    none TW Hya              11:01:51.84498 -34.42.17.1609 J2000  2    515151
3   none J1147-382=QSO      11:47:01.38151 -38.12.11.1179 J2000  3    40797 
4    none J1037-295=QSO      10:37:16.08989 -29.34.02.9888 J2000  4    171153
5    none Titan              12:49:26.53729 -02.22.27.1521 J2000  0    4833 
6    none Titan              12:49:26.53059 -02.22.18.7878 J2000  0    4833 
</pre>
 
If we want to image such moving objects observed across multiple SBs, we need to bring the positions into agreement, otherwise {{clean}} will try to make a mosaic.  Task [http://casa.nrao.edu/stable/docs/TaskRef/fixplanets-task.html fixplanets] can be used to do this.  Here, we set the direction to the direction of the first dataset as reported by listobs.  Note that the RA/Dec format is slightly different from the {{listobs}} output format.  Also, we do not
fix the uvw coordinates because they are already more correct now than they would be if we "fixed" them.
 
<source lang="python">
# In CASA
fixplanets(vis='Band7multi_april22.ms', field='Titan', direction='J2000 12h49m25.97588 -02d22m41.3024', fixuvw=False)
</source>
 
Check the header information again to see that the information for Titan has changed for the second
and third datasets.  They will appear as fields 5 and 6.
 
<source lang="python">
# In CASA
listobs(vis='Band7multi_april22.ms',verbose=F)
</source>
</source>
<pre style="background-color: #fffacd;">
  ID  Code Name        RA            Decl          Epoch  SrcId
  0    none 3c279              12:56:11.16657 -05.47.21.5247 J2000  0    70866 
  1    none Titan              12:49:25.97588 -02.22.41.3024 J2000  1    4842 
  2    none TW Hya              11:01:51.84498 -34.42.17.1609 J2000  2    515151
  3    none J1147-382=QSO      11:47:01.38151 -38.12.11.1179 J2000  3    40797 
  4    none J1037-295=QSO      10:37:16.08989 -29.34.02.9888 J2000  4    171153
  5    none Titan              12:49:25.97588 -02.22.41.3024 J2000  0    4833 
  6    none Titan              12:49:25.97588 -02.22.41.3024 J2000  0    4833 
</pre>
==Optional: Split Calibrated Titan Data==
When we {{split}} off the Titan data, a few dozen warnings like the following are written to the log:
<pre>
2012-05-15 22:00:35    WARN    split::SubMS::copySource()      Invalid SOURCE ID in SOURCE table row 20
</pre>
These can be ignored, because they do not indicate any problem that will prevent you from imaging Titan correctly at a single position using all the data in the output ms.


<source lang="python">
<source lang="python">
Line 1,174: Line 1,505:
       datacolumn='corrected',spw='3',field='1')
       datacolumn='corrected',spw='3',field='1')
</source>
</source>
<source lang="python">
# In CASA
os.system('rm -rf 3C279_CO3_2.ms')
split(vis='Band7multi_april22.ms',outputvis='3C279_CO3_2.ms',
      datacolumn='corrected',spw='2:1900~2000',field='0')
</source>
==Imaging Calibrators==
This section may be added soon.


==Continue on to Imaging of the Science Target==
==Continue on to Imaging of the Science Target==


Now you can continue on to the [http://casaguides.nrao.edu/index.php?title=TWHydraBand7_Imaging imaging guide].
Now you can continue on to the [http://casaguides.nrao.edu/index.php?title=TWHydraBand7_Imaging_3.4 imaging guide].
{{Checked 3.3.0}}

Latest revision as of 14:34, 25 July 2012

  • An introduction to this data set is available at TWHydraBand7.

Preparation

Once you have downloaded TWHYA_BAND7_UnCalibratedMSAndTablesForReduction.tgz, in a terminal unpack it with

tar -zxvf TWHYA_BAND7_UnCalibratedMSAndTablesForReduction.tgz

Please be aware that you will need about 100 GB of free space to do the data reduction. It is a good idea to check that now before you begin. Some of the plots described here require 9 GB of RAM; as little as 4 GB may be sufficient if additional data averaging is used when the plots are generated. When you are satisfied with the available drive space and memory on your machine:

cd TWHYA_BAND7_UnCalibratedMSAndTablesForReduction

NOTE: the calibration tables included TWHYA_BAND7_UnCalibratedMSAndTablesForReduction CANNOT be used with CASA 3.4, they should be discarded, or moved out of the working directory.

Then start CASA.

casapy

Confirm your version of CASA

This guide has been written for CASA release 3.4.0. Please confirm your version before proceeding.

# In CASA
version = casalog.version()
print "You are using " + version
if (int(version.split()[4][1:-1]) < 19988):
    print "\033[91m YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."
    print "\033[91m PLEASE UPDATE IT BEFORE PROCEEDING."
else:
    print "Your version of CASA is appropriate for this guide."

Install Analysis Utilities

Analysis Utilities (or analysisUtils for short) is a small set of Python scripts that provide a number of analysis and plotting utilities for ALMA data reduction. This guide uses a few of these utilities. They are very easy to install (just download and untar). See

http://casaguides.nrao.edu/index.php?title=Analysis_Utilities

for a full description and download instructions. If you do not wish to do this, see the CASA 3.3 version of the guide linked at the top of this page for alternative (but slow) plotting options. Analysis Utilities are updated frequently so if its been a while since you installed it, its probably worth doing it again. If you are at an ALMA site or ARC, the analysis utilities are probably already installed and up to date.

Fix Titan's coordinates

Note that in the near future this step will be unnecessary.

It is temporarily necessary to correct the positions of ephemeris objects observed during ALMA Cycle 0, because the control software revisions earlier than 9.0 erroneously write the data with coordinates of 00:00:00.0000 +00.00.00.0000 (J2000). For this dataset, we need to correct the position of the absolute flux calibrator Titan, as we can see from the first listobs:

# In CASA
os.system('rm -f X3c1.ms.listobs')
listobs('X3c1.ms', verbose=T, listfile='X3c1.ms.listobs')

You can view the listobs output files using command "less" from the CASA prompt.

  ID   Code Name           RA              Decl          Epoch   SrcId nRows
  0    none 3c279          12:56:11.16657 -05.47.21.5247 J2000   0     23625
  1    none Titan          00:00:00.00000 +00.00.00.0000 J2000   1     4842
  2    none TW Hya         11:01:51.84498 -34.42.17.1609 J2000   2     175176
  3    none J1147-382=QSO  11:47:01.38151 -38.12.11.1179 J2000   3     14832
  4    none J1037-295=QSO  10:37:16.08989 -29.34.02.9888 J2000   4     59877

To correct Titan's position, we will use the task fixplanets, which writes the actual coordinates at the instant of the first observation. This step takes a while because we are recalculating the uvw's accordingly.

# In CASA
fixplanets(vis='X3c1.ms', field='Titan', fixuvw=True)

Check the header information again with listobs to confirm that the information for Titan has changed:

# In CASA
os.system('rm -f X3c1.ms.listobs')
listobs('X3c1.ms', verbose=T, listfile='X3c1.ms.listobs')
  ID   Code Name           RA              Decl          Epoch   SrcId nRows
  0    none 3c279          12:56:11.16657 -05.47.21.5247 J2000   0     23625
  1    none Titan          12:49:25.97588 -02.22.41.3024 J2000   1     4842
  2    none TW Hya         11:01:51.84498 -34.42.17.1609 J2000   2     175176
  3    none J1147-382=QSO  11:47:01.38151 -38.12.11.1179 J2000   3     14832
  4    none J1037-295=QSO  10:37:16.08989 -29.34.02.9888 J2000   4     59877

Now fix the other two measurement sets similarly:

# In CASA
fixplanets(vis='X5d8.ms', field='Titan', fixuvw=True)
fixplanets(vis='X7ef.ms', field='Titan', fixuvw=True)

Observing Log and Priors

Below is some information that may not be obvious from the data

Like at most telescopes, the ALMA operators and astronomers at the site log any significant issues 
that were noticed from the online system during the observation. For these Band 7 observations of 
TW Hya on April 22, 2011, the only issue of note was that antenna DV04 could not observe at Band 7 
and will need to be flagged. 

First let's examine the basic properties of the data using listobs. Among other information we will be able to deduce what the source ids are and what each source was used for:

3c279 is the bandpass calibrator (field id=0)
Titan is the absolute flux calibrator (field id=1)
J1147-382 is the secondary phase calibrator (field id=3)
J1037-295 is the primary phase calibrator (field id=4)
# In CASA
data=['X3c1.ms','X5d8.ms','X7ef.ms']
for vis in data:
    os.system('rm '+vis+'.listobs')
    listobs(vis, verbose=T, listfile=vis+'.listobs')

You can view the listobs output files using command less from the CASA prompt. Below we copy select parts of the listobs output files for reference.

X3c1.ms:
Data records: 278352       Total integration time = 6109.06 seconds
   Observed from   22-Apr-2011/00:01:52.9   to   22-Apr-2011/01:43:42.0 (UTC)

X5d8.ms:
Data records: 278406       Total integration time = 5995.01 seconds
   Observed from   22-Apr-2011/01:48:05.8   to   22-Apr-2011/03:28:00.8 (UTC)

X7ef.ms:
Data records: 255717       Total integration time = 5407.49 seconds
   Observed from   22-Apr-2011/03:30:39.7   to   22-Apr-2011/05:00:47.2 (UTC)

Fields: 5
  ID   Code Name                RA              Decl          Epoch   SrcId nRows
  0    none 3c279               12:56:11.16657 -05.47.21.5247 J2000   0     23625
  1    none Titan               12:49:25.97588 -02.22.41.3024 J2000   1     4842
  2    none TW Hya              11:01:51.84498 -34.42.17.1609 J2000   2     175176
  3    none J1147-382=QSO       11:47:01.38151 -38.12.11.1179 J2000   3     14832
  4    none J1037-295=QSO       10:37:16.08989 -29.34.02.9888 J2000   4     59877 

  SpwID  #Chans Frame Ch1(MHz)    ChanWid(kHz)  TotBW(kHz)  Corrs
  0           4 TOPO  184550      1500000       7500000     I
  1         128 TOPO  355740.062  15625         2000000     XX  YY
  2           1 TOPO  356716.625  1796875       1796875     XX  YY
  3         128 TOPO  356507.813  15625         2000000     XX  YY
  4           1 TOPO  357484.375  1796875       1796875     XX  YY
  5         128 TOPO  346792.187  15625         2000000     XX  YY
  6           1 TOPO  345784.375  1796875       1796875     XX  YY
  7         128 TOPO  345182.438  15625         2000000     XX  YY
  8           1 TOPO  344174.625  1796875       1796875     XX  YY
  9         128 TOPO  344386.763  15625         2000000     XX  YY
  10          1 TOPO  343378.95   1796875       1796875     XX  YY
  11        128 TOPO  346324.263  15625         2000000     XX  YY
  12          1 TOPO  345316.45   1796875       1796875     XX  YY
  13        128 TOPO  354402.388  15625         2000000     XX  YY
  14          1 TOPO  355378.95   1796875       1796875     XX  YY
  15        128 TOPO  356402.388  15625         2000000     XX  YY
  16          1 TOPO  357378.95   1796875       1796875     XX  YY
  17       3840 TOPO  356497.936  122.070312    468750      XX  YY
  18          1 TOPO  356732.189  468750        468750      XX  YY
  19       3840 TOPO  357734.314  122.070312    468750      XX  YY
  20          1 TOPO  357499.939  468750        468750      XX  YY
  21       3840 TOPO  346034.314  122.070312    468750      XX  YY
  22          1 TOPO  345799.939  468750        468750      XX  YY
  23       3840 TOPO  343955.936  122.070312    468750      XX  YY
  24          1 TOPO  344190.189  468750        468750      XX  YY

Antennas: 9:
       Name  Station   Diam.    Long.         Lat.
  0    DV04  J505      12.0 m   -067.45.18.0  -22.53.22.8
  1    DV06  T704      12.0 m   -067.45.16.2  -22.53.22.1
  2    DV07  J510      12.0 m   -067.45.17.8  -22.53.23.5
  3    DV08  T703      12.0 m   -067.45.16.2  -22.53.23.9
  4    DV09  N602      12.0 m   -067.45.17.4  -22.53.22.3
  5    DV10  N606      12.0 m   -067.45.17.1  -22.53.23.6
  6    PM01  T702      12.0 m   -067.45.18.6  -22.53.24.1
  7    PM02  T701      12.0 m   -067.45.18.8  -22.53.22.2
  8    PM03  J504      12.0 m   -067.45.17.0  -22.53.23.0

Things to Notice from above:

  • There are three different data sets acquired close together in time. We will calibrate each dataset independently and then combine the calibrated data prior to imaging.
  • Titan appears to have slightly different positions in each dataset because it is a moving body. In fact, at the time of observation, due to temporary data capture issue in the ALMA system, the position was written has (0,0). We have pre-corrected this error using fixplanets. Later in the tutorial, we will run fixplanets again to force all three datasets to have the same fixed position for Titan.
  • There are a lot of spectral windows! Don't be alarmed. In ALMA data,
    • spw=0 is always reserved for the water vapor radiometry data.
    • spw=9, 11, 13, 15 are the wideband (TDM) correlator mode with 128 channels per spw default settings for doing pointing and this is all they are used for in these data.
    • Currently Tsys data can only be taken in the wide (TDM) correlator mode with 128 channels per spw, these correspond to spws=1, 3, 5, 7 above. The frequencies of these TDM spws were carefully chosen so the the narrowband FDM spws fall within them.
    • The 0.5 GHz, high spectral resolution spws that contain all the real source data (science target and calibrators) are 17, 19, 21, and 23
    • For quicklook purposes, the ALMA online system produces a channel averaged spw for each channelized spw, these correspond to spw=2,4,6,8,10,12,14,16,18,20,22,24 and shouldn't be used for anything in post-processing as bandpass calibration etc has not been applied.

In the portion of the listobs output that shows the timerange, the final column gives the scan intent. It is important to have a look at this because you can flag and do other operations in CASA using the scan intent as a selection option. Also, these intents will be used in the future for pipeline processing. You will usually want to use them to flag the CALIBRATE_POINTING* and CALIBRATE_ATMOS* (the latter correspond to the hot and cold load measurements used to calculate Tsys) data. This is essential for science or calibration data taken only in TDM (wide bandwidth) mode, i.e. the same mode that the pointing and Tsys data are taken in. For the current data however, that calibration data is recorded in different spws from the useful FDM (narrow bandwidth) data, so we'll be able to separate them by splitting them off at the final step prior to imaging.

<figure id="Ant_pos.png">

Antenna locations for the first dataset.

</figure>

Before we move on, its also nice to get an idea where the antennas are with respect to each other. We can use plotants to plot their positions. It is a good idea to check each file since an antenna may have entered or exited the array between observations.

# In CASA
for vis in data:
    plotants(vis=vis,figfile=vis+'.plotants.png')

You can view the output images using any standard image viewer.

Create the Tsys and WVR Tables, and Examine

Each ms include tables that contain the Tsys and WVR measurements associated with the visibility data. We must create calibration tables from these measurements. First we create the WVR calibration tables by running the task wvrgcal. This task examines the data for each ms as a whole and creates a calibration table containing only phase corrections for each antenna and spw.

# In CASA
basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
  os.system('rm -rf '+asdm+'.wvr')
  wvrgcal(vis=asdm+'.ms', caltable=asdm+'.wvr', segsource=True, toffset=-1)

Next we create the Tsys tables by running gencal:

# In CASA
basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
  os.system('rm -rf '+asdm+'.tsys')
  gencal(vis=asdm+'.ms', caltable=asdm+'.tsys', caltype='tsys')

It is very important that Tsys measurements taken as close in time and elevation as possible to a particular source are applied. To save telescope time, Tsys measurements are sometimes intentionally skipped in the scheduling block for specific sources. So the first step is to establish which sources have their own Tsys measurements and which do not. To do this, you may use the intent parameter of listobs:

# In CASA
basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
    listobs(vis=asdm+'.ms', verbose=F, selectdata=True, intent='CALIBRATE_ATMOS*')

<figure id="X3c1.tsys_vs_time_3.4.png">

Tsys vs. time for spw 1 of the X3c1.ms data.

</figure> <figure id="X5d8.tsys_vs_time_3.4.png">

Tsys vs. time for spw 1 of the X5d8.ms data.

</figure> <figure id="X7ef.tsys_vs_time_3.4.png">

Tsys vs. time for spw 1 of the X7ef.ms data.

</figure>

Fields: 4
  ID   Code Name                RA              Decl          Epoch   SrcId nRows  
  0    none 3c279               12:56:11.16657 -05.47.21.5247 J2000   0     1116   
  1    none Titan               12:49:25.97588 -02.22.41.3024 J2000   1     1125   
  2    none TW Hya              11:01:51.84498 -34.42.17.1609 J2000   2     6795   
  4    none J1037-295=QSO       10:37:16.08989 -29.34.02.9888 J2000   4     6777   
Spectral Windows:  (9 unique spectral windows and 2 unique polarization setups)
  SpwID  #Chans Frame Ch1(MHz)    ChanWid(kHz)  TotBW(kHz)  Corrs  
  0           4 TOPO  184550      1500000       7500000     I   
  1         128 TOPO  355740.062  15625         2000000     XX  YY  
  2           1 TOPO  356716.625  1796875       1796875     XX  YY  
  3         128 TOPO  356507.813  15625         2000000     XX  YY  
  4           1 TOPO  357484.375  1796875       1796875     XX  YY  
  5         128 TOPO  346792.187  15625         2000000     XX  YY  
  6           1 TOPO  345784.375  1796875       1796875     XX  YY  
  7         128 TOPO  345182.438  15625         2000000     XX  YY  
  8           1 TOPO  344174.625  1796875       1796875     XX  YY  

Because field '3' (the secondary phase calibrator) does not appear in the list, it has no tsys. Since the secondary phase calibrator is close on the sky to the primary phase calibrator and observed near in time, we will transfer the Tsys from the primary to the secondary phase calibrator. Also notice that spws 1,3,5,7 are the only multi-channel spws that contain Tsys data. At present, Tsys measurements can only be obtained with TDM spectral setups (128 channels/dual pol). Because our science target is observed in FDM (3840 channels/dual pol), we will need to interpolate the measurements from TDM to FDM. But first, to inspect the Tsys vs. time, we use plotcal:

# In CASA
basename_all = ['X3c1','X5d8','X7ef']
tsysfields=['0','1','2','4']
os.system('mkdir cal_plots; mkdir cal_plots/Tsys_plots') 
for asdm in basename_all:
  print "Plotting Tsys vs. time for "+asdm
  plotcal(caltable=asdm+'.tsys', xaxis='time',yaxis='tsys',
          antenna='1~8',plotrange=[0,0,100,500],
          iteration='antenna',subplot=421,poln='',spw='1:50~50',
          figfile='cal_plots/Tsys_plots/'+asdm+'.tsys_vs_time.png')
  if (asdm != basename_all[-1]):
    user_check=raw_input('press enter to continue script\n')

To inspect Tsys vs. frequency, we use plotbandpass from analysis_Utilities. (Note: You need to have installed analysis_Utilities before starting casapy.) There are many different options for plotbandpass, and we demonstrate some of the most useful ones. The option showtsky=T will overlay the effective temperature curve from the atmospheric model. This shows us the location of any atmospheric lines which will appear as emission lines in the autocorrelation data (from which the Tsys spectra are derived) from all antennas. In the example below, we set interactive=False, which will produce many pages of plots as individual pngs but will only show the final page in the graphics window. To view all the pages we use the image viewer eog (Eye of GNOME) available on Linux. The alternative is to set interactive=True and examine the plots in the casa graphics window as they are produced.

<figure id="X3c1.tsys.field0.DV04.spw1.t1.png">

Tsys vs. frequency on 3C279 for the X3c1.ms data, spw=1.

</figure> <figure id="X3c1.tsys.field0.DV04.spw3.t1.png">

Tsys vs. frequency on 3C279 for the X3c1.ms data, spw=3.

</figure>

basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
    print "Plotting Tsys vs. frequency for "+asdm
    for spw in [1,3,5,7]:
        for field in ['0','1']:
            au.plotbandpass(caltable=asdm+'.tsys', xaxis='freq',yaxis='amp',
                     showtsky=T,subplot=421,field=field,
                     spw=spw, interactive=False, plotrange=[0,0,0,0],
                     figfile='cal_plots/Tsys_plots/'+asdm+'.tsys.field%s.png'%field,
                     buildpdf=False)

In <xr id="X3c1.tsys.field0.DV04.spw1.t1.png"/> and <xr id="X3c1.tsys.field0.DV04.spw3.t1.png"/> we see the effect of atmospheric ozone lines on the Tsys measurements associated with 3C279 in spw 1 and 3.

For sources that have multiple Tsys measurements (typically the primary phase calibrator and/or the science target) one can use overlay="time" to overlay all the measurements for that source. This can help to identify any anomalous Tsys scans. As a fraction of the plots produced by this loop, here we show the Tsys recorded on spw=1 for TW Hya from the first dataset.

<figure id="X3c1.tsys.field2.DV04.spw1.png">

Tsys vs. freq for field 2, spw 1 of the X3c1.ms data (antennas 0..3).

</figure> <figure id="X3c1.tsys.field2.DV04.spw1.png">

Tsys vs. freq for field 2, spw 1 of the X3c1.ms data (antennas 4..7).

</figure> <figure id="X3c1.tsys.field2.PM03.spw1.png">

Tsys vs. freq for field 2, spw 1 of the X3c1.ms data (antenna 8).

</figure>

basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
    print "Plotting Tsys vs. frequency for "+asdm
    for spw in [1,3,5,7]:
        for field in ['2','4']:
            au.plotbandpass(caltable=asdm+'.tsys', xaxis='freq',yaxis='amp',
                     showtsky=T,subplot=221,field=field,
                     overlay='time',spw=spw, interactive=False, plotrange=[0,0,0,0],
                     figfile='cal_plots/Tsys_plots/'+asdm+'.tsys.field%s.png'%field,
                     buildpdf = False)

Alternatively, the overlay="antenna" option will quickly reveal any Antennas with discrepant Tsys values, as they will be obvious outliers. For FDM projects like this one, using the showfdm=True option can be helpful, as it will show where in the TDM bandpass each FDM spw was located. <figure id="X3c1.tsys.field0.spw1.t1.png">

Tsys vs Freq for field 0, spw 1 of the X3c1.ms data with all antennas overlaid.

</figure>

tsysfields=['0','1','2','4'] 
basename_all = ['X3c1','X5d8','X7ef']
for asdm in basename_all:
    print "Plotting Tsys vs. frequency for "+asdm
    for spw in [1,3,5,7]:
        for field in tsysfields:
            au.plotbandpass(caltable=asdm+'.tsys', xaxis='freq',yaxis='amp',
                  showtsky=T,subplot=111,field=field,
                  overlay='antenna',spw=spw, interactive=False,
                  figfile='cal_plots/Tsys_plots/'+asdm+'.tsys.field%s.png'%field,
                  buildpdf=False,showfdm=True)


Note that DV04 consistently has a significantly higher Tsys than the rest of the antennas. We already know from the Observation log that we need to flag that antenna, but had we not had that information, examining this plot would have demonstrated the situation.

Apply the Tsys and WVR Tables, and Split

Next we apply the calibrations. For the (4) sources with Tsys measurements, we use the field and gainfield parameters of applycal to apply solutions only to themselves. A new feature in casa 3.4 is the ability of applycal to interpolate gain tables from one spw onto another spw. In this case, we want to interpolate the TDM Tsys values in spws 1,3,5,7 onto the FDM spws 17,19,21,23. We use the interp parameter to request linear interpolation in the time dimension and spline interpolation in the channel/frequency dimension. To map the solutions for each spw, we use the spwmap parameter, which requires a list of all spws for each gain table to be applied, or a blank list ([]) which is a shorthand notation to apply the solution for each spw to itself. While applying Tsys, we will also apply the wvr calibration tables; wvr data is usually always present for all sources. Below we first set some definitions so we can loop over the correct parameters:

# In CASA
fdm='17,19,21,23'
nocal='3'  # This source had no Tsys measurements associated with it 
tsysfields=['0','1','2','4'] 
tsysmap = range(25)
tsysmap[17] = 1
tsysmap[19] = 3
tsysmap[21] = 5
tsysmap[23] = 7
for asdm in basename_all:
  for field in tsysfields:
    applycal(vis=asdm+'.ms', spw=fdm, field=field, gainfield=field,
             gaintable=[asdm+'.tsys', asdm+'.wvr'], spwmap=[tsysmap,[]],
             interp=['linear,spline','nearest'], flagbackup=F, calwt=T)

For the sources without Tsys (i.e. field=3), couple them with the best available source with Tsys (i.e. field=4).

# In CASA
for asdm in basename_all:
  applycal(vis=asdm+'.ms', spw=fdm, field=nocal,
           gaintable=[asdm+'.tsys', asdm+'.wvr'], spwmap=[tsysmap,[]],
           gainfield=['4',nocal], interp=['linear,spline','nearest'],flagbackup=F,
           calwt=T)

Check Tsys application with plotms. First we make plots with ydatacolumn='data' to look at the raw data. For simplicity we'll just look at the two strongest sources 3C279 and Titan.

<figure id="X5d8_wvrtsys_corrected_spw19.png">

Spectral plots of 3C279 (black) and Titan (magenta) for spw=19 after Tsys and wvr correction.

</figure>

# In CASA
plotms(vis='X5d8.ms',spw='17,19,21,23',xaxis='frequency',yaxis='amp',field='0,1',
       antenna='*&*',avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',
       xselfscale=T,ydatacolumn='data')

<figure id="X5d8_wvrtsys_corrected_spw21.png">

Spectral plots of 3C279 (black) and Titan (magenta) for spw=21 after Tsys and wvr correction.

</figure>

Note: the antenna='*&*' is specifying that we only want to see the cross-correlation data (i.e. not the autocorrelations).

Use the green arrows on the plotms display to cycle through the 4 FDM spws.

Now change Data Column to corrected on the "Axes" tab (this is the same as ydatacolumn in the task) and hit Plot button on the GUI. Flip through again.

Things to notice:

  • The amplitude scale has changed due to application of Tsys
  • spw=17 is clean and flat
  • spw=19 shows a strong dip around channel 3000 -- this is an atmospheric ozone absorption feature at 357.6 GHz. In the future, high spectral resolution Tsys measurements may help to remove the shape of the absorption, but until then we will need to flag this part of the spectrum.
  • spw=21 Titan shows both a narrow and a broad spectral feature. The broad feature is CO(3-2) and it completely fills the 0.5 GHz band so there are no line-free channels! Titan must be handled carefully when it is used as a calibrator because it contains strong line emission. Indeed, we will not be able to use the absolute flux transfer from this spw for other targets. When possible Titan should be avoided for absolute flux calibration. For these observations, no other suitable absolute flux calibrator was available.
  • spw=23 shows another strong line from Titan.

Beyond these things to notice, the application of Tsys and wvr seem to have gone well. We can now split off only the narrow band FDM spectral windows for further processing.

# In CASA
for asdm in basename_all:
  newvis = asdm + '_wvrtsys.ms'
  os.system('rm -rf ' + newvis)
  split(vis=asdm+'.ms',outputvis=newvis,datacolumn='corrected',spw=fdm)

Note: After split, the spectral windows will be renumbered to 0, 1, 2, 3 corresponding to the old spw=17, 19, 21, 23, see listobs excerpt below.

  SpwID  #Chans Frame Ch1(MHz)    ChanWid(kHz)  TotBW(kHz)  Corrs  
  0        3840 TOPO  356497.936  122.070312    468750      XX  YY  
  1        3840 TOPO  357734.314  122.070312    468750      XX  YY  
  2        3840 TOPO  346034.314  122.070312    468750      XX  YY  
  3        3840 TOPO  343955.936  122.070312    468750      XX  YY  

Initial Inspection and Flagging

From here we begin to operate on the *wvrtsys.ms files.

Before we begin flagging data, we unflag all data in the measurement sets. If this is your first pass through this section of the guide, no data in the measurement sets will be flagged, and you can skip this step. If you are rerunning the flagging commands below, this will reset your flag columns to their original state. (Warning messages about using task tflagdata can be ignored for now.)

# In CASA
splitdata=['X3c1_wvrtsys.ms','X5d8_wvrtsys.ms','X7ef_wvrtsys.ms']
for vis in splitdata:
  flagdata(vis=vis, mode='manualflag', unflag=T, flagbackup=F)

ALMA data contains both the cross correlation and autocorrelation data. Presently nothing more can be done with the autocorrelation data so we flag it. Additionally, for smaller configurations of the array, and northerly sources one antenna can shadow another, blocking its view. This data also needs to be flagged. Finally, the observing log told us DV04 was not behaving properly at Band 7 and shouldn't be used so we flag that as well.

# In CASA
splitdata=['X3c1_wvrtsys.ms','X5d8_wvrtsys.ms','X7ef_wvrtsys.ms']
for vis in splitdata:
  flagdata(vis=vis,autocorr=True, flagbackup=T)
  flagdata(vis=vis,mode='shadow',diameter=12.0, flagbackup=F)
  flagdata(vis=vis,antenna='DV04', flagbackup=F)

Next we inspect the data with plotms for additional issues that need flagging, first looking at amplitude vs. time for each of the three datasets. Use the green arrows on the plotms gui to cycle through spws.

<figure id="Tsyswvr_time_spw0_X3x1.png">

Amplitude as a function of time for X3c1_wvrtsys.ms, spw=0

</figure>

Note: when iteraxis is invoked in plotms, unzoom does not always work properly. If you have trouble with this, flip to next page and then back to current one. This usually fixes the problem.

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='',xaxis='time',yaxis='amp',field='',avgchannel='3840',
       coloraxis='field',iteraxis='spw')
# In CASA
plotms(vis='X5d8_wvrtsys.ms',spw='',xaxis='time',yaxis='amp',field='',avgchannel='3840',
       coloraxis='field',iteraxis='spw')
# In CASA
plotms(vis='X7ef_wvrtsys.ms',spw='',xaxis='time',yaxis='amp',field='',avgchannel='3840',
       coloraxis='field',iteraxis='spw')

<figure id="Tsyswvr_time_spw2corr_X3x1.png">

Amplitude as a function of time for X3x1_wvrtsys.ms, spw=2 with colorize='corr'.

</figure>

Things to Notice:

  • In spw=2 there are some low points in all three data files. Use the "Mark Regions" box (left of center on bottom row of icons) to draw small box on low points. Then click the magnifying glass icon to the right of center. The output will be sent to the logger window. Note: keep the marked region small or you can overwhelm the buffer. Locate suggests correlation YY on PM03 is the culprit.

To see this more clearly you can rerun plotms with coloraxis='field' switched to coloraxis='corr'

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='2',xaxis='time',yaxis='amp',field='',avgchannel='3840',
       coloraxis='corr')

To further check, you can exclude PM03 from the plot using antenna='!PM03'.

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='2',xaxis='time',yaxis='amp',field='',avgchannel='3840',
       coloraxis='corr',antenna='!PM03')

Having confirmed the problem antenna, we flag it below.

# In CASA
splitdata=['X3c1_wvrtsys.ms','X5d8_wvrtsys.ms','X7ef_wvrtsys.ms']
for vis in splitdata:
  flagdata(vis=vis, flagbackup=T,
         spw=['2'],
         antenna=['PM03'],
         correlation=['YY'])

Next we need to inspect the spectral properties of the data to look for issues.

First we look at phase as a function of frequency for a well behaved antenna like DV06. coloraxis='baselines' (note this parameter is called Colorize in the GUI "Display" tab) will show each baseline as a different color. Significant delay errors or baseline errors will show up as phase slopes in these plots. Again you will want to page through the spectral windows.

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='',xaxis='frequency',yaxis='phase',field='0',antenna='DV06',
       avgtime='1e8',avgscan=T,coloraxis='baseline',iteraxis='spw',xselfscale=T)
# In CASA
plotms(vis='X5d8_wvrtsys.ms',spw='',xaxis='frequency',yaxis='phase',field='0',antenna='DV06',
       avgtime='1e8',avgscan=T,coloraxis='baseline',iteraxis='spw',xselfscale=T)
# In CASA
plotms(vis='X7ef_wvrtsys.ms',spw='',xaxis='frequency',yaxis='phase',field='0',antenna='DV06',
       avgtime='1e8',avgscan=T,coloraxis='baseline',iteraxis='spw',xselfscale=T)

Overall these plots look good with no large delays or baseline errors apparent.

<figure id="Birdies_spw2_X3x1.png">

Phase calibrators (brown and green) and TW Hya (orange) showing both real CO(3-2) emission in TW Hya and weak birdie spectral features in all three sources for spw=2.

</figure>

With such high spectral resolution data, one often sees occasional "birdies" in the data. These are typically very narrow weak spectral features that are internally generated in the system. Over time as we track down issues the number of birdies should decrease, but you should always check. This is easiest to do by looking at amplitude vs. frequency for sources observed over a long time range (for sensitivity). It is helpful to look at more than one source to verify the nature of the emission. Below we look at both calibrators (brown and green) and TW Hya (orange). If you have enough sensitivity birdies should be seen on all sources, however, be careful not to mistake real line emission for a birdie even on a calibrator - they can be present as we've seen for Titan.

<figure id="Birdies_spw3_X3x1.png">

Phase calibrators (brown and green) and TW Hya (orange) showing only weak birdie spectral features in spw=3.

</figure>

# In CASA
plotms(vis='X3c1_wvrtsys.ms',spw='',xaxis='channel',yaxis='amp',field='2,3,4',
       avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',xselfscale=T,yselfscale=T)

Do a quick check that other two datasets are the same (they are usually similar if the source of internal resonance hasn't changed in the meantime).

# In CASA
plotms(vis='X5d8_wvrtsys.ms',spw='',xaxis='channel',yaxis='amp',field='2,3,4',
       avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',xselfscale=T,yselfscale=T)
# In CASA
plotms(vis='X7ef_wvrtsys.ms',spw='',xaxis='channel',yaxis='amp',field='2,3,4',
       avgtime='1e8',avgscan=T,coloraxis='field',iteraxis='spw',xselfscale=T,yselfscale=T)

Now you can zoom in on each region to get channels for flagging, or to save time just go ahead and run the flagging command below where this has been done for you.

# In CASA
splitdata=['X3c1_wvrtsys.ms','X5d8_wvrtsys.ms','X7ef_wvrtsys.ms']
for vis in splitdata:
  flagdata(vis=vis, flagbackup=T,
         spw=['0:1067~1068;1279~1280;2367~2368;3775~3776',
              '1:1279~1280;2367~2368;3775~3776',
              '2:1279~1280;3775~3776',
              '3:831~832;1535~1536;2367~2368;3775~3776;3839~3839'])

Replot in plotms to check that flagging has been done as anticipated.

Flag Calibrator Spectral Features

In this section, we will flag spectral features in the calibrators so they do not skew the calibration solutions. First make plots of 3C279 and Titan in channel space to get channels for flagging.

<figure id="3C279_Titan_spw1.png">

Spectral plots of 3C279 (black) and Titan (magenta) for spw=1 after Tsys and wvr correction.

</figure> <figure id="3c279_meso_freq.png">

Zoomed spectral plot of 3C279 showing mesospheric absorption of CO(3-2) in frequency space.

</figure> <figure id="3c279_meso_chann.png">

Zoomed spectral plot of 3C279 showing mesospheric absorption of CO(3-2) in channel space.

</figure>

# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='channel',yaxis='amp',field='0,1',
         avgtime='1e8',coloraxis='field',iteraxis='spw')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

The figure to the right shows a broad absorption line in spw 1 at channel 3000. This is the ozone absorption line at 357.62982 GHz. However, there is another narrow absorption feature in the spectra (spw 2) that is most easily seen on 3C279 (because it is the strongest calibrator). Let's look at it first in frequency space.

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='2:1600~2300',xaxis='frequency',yaxis='amp',
         field='0',avgtime='1e8',coloraxis='field')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

The absorption feature lies exactly at the rest frequency for CO 3-2 (345.79599 GHz). Because it is so narrow (< 1 MHz), it must originate from a very low pressure region (i.e. high altitude) in the Earth's atmosphere, otherwise it would be more pressure broadened. Indeed, the first detection of CO in the mesosphere was made over 35 years ago (see, e.g. Waters et al. 1976 or Goldsmith et al. 1979). Be aware that the line is stronger as you go up the CO ladder (strength ~ J^3 for low J) because the temperature at that altitude (~50km) is about 250 K. In April 2011, the apparent depth of the feature was about 10% in the 2-1 line and 35% in the 3-2 line. However, the depth of the absorption feature is exaggerated due to the way ALMA normalizes the cross-correlation spectra by the autocorrelation spectra prior to storage. While this technique generally leads to a flat bandpass shape, it will accentuate telluric features because they are emission lines in the single dish spectrum (e.g. JCMT observations of mesospheric CO 3-2 can be found in Preston et al. 1993). Finally, note that large seasonal variations in the line strength have been reported from observations at Onsala.

Now, let's re-plot the line with channel number as the x-axis in order to get the channel range for flagging.

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='2:1600~2300',xaxis='channel',yaxis='amp',
         field='0',avgtime='1e8',coloraxis='field')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Now lets look at Titan in more detail.

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='channel',yaxis='amp',field='1',
         avgtime='1e8',coloraxis='field',iteraxis='spw')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Explicitly back up the flag tables so that flagged regions can be restored later.

# In CASA
for asdm in basename:
  flagmanager(vis=asdm+'.ms',mode='save',versionname=asdm+'.before_calspectralflags')

<figure id="Titan_spw2.png">

Spectral plot of Titan (magenta) for spw=2.

</figure>

Flag absorption features for all sources.

# In CASA
for asdm in basename:
  print "Flagging absorption features in all sources for "+asdm
  flagdata(vis=asdm+'.ms', spw=['1:2000~3840','2:1945~1960'])

<figure id="Titan_spw3.png">

Spectral plot of Titan (magenta) for spw=3.

</figure>

Now we need to flag emission. The very broad CO(3-2) in spw=2 of Titan will prevent us from using it as a calibrator for this spectral window since there are no line-free channels (we will transfer, phase, amplitude, and absolute flux from another Titan spw below). We do want to flag the narrower Titan line in spw=3.

# In CASA
for asdm in basename:
  flagmanager(vis=asdm+'.ms',mode='save',versionname=asdm+'.before_emissionflags')
# In CASA
for asdm in basename:
  print "Flagging emission for "+asdm
  flagdata(vis=asdm+'.ms',
           field=['1'],
           spw=['3:1000~3000'])

If you like, check that the right things have been flagged.

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='channel',yaxis='amp',field='0,1',
         avgtime='1e8',coloraxis='field',iteraxis='spw')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Set Up the Flux Calibrator Model

Fill the model data column for Titan with a model for the flux density as a function of baseline. The model is a uniformly illuminated disk with the size obtained from the JPL Horizons ephemeris.

# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
  setjy(vis=asdm+'.ms',field='1',usescratch=F,
        standard='Butler-JPL-Horizons 2010',scalebychan=F)

<figure id="Titan amp vs uvdist.png">

Plot of Titan model for each of the 4 spws.

</figure>

After running setjy, it is a good idea to plot the model in order to confirm that it makes sense. In this case, Titan is partially resolved, so we expect the flux density to drop with uv distance, but not so much as to pass through a null. We also expect it to be brighter at higher frequencies since it has a thermal blackbody spectrum.

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',field='1',xaxis='uvdist',yaxis='amp',coloraxis='spw',
         ydatacolumn='model')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Bandpass Calibration

First we need to check how the amplitude and phase of 3C279 behave as a function of time. In order to set a fixed scale on the y-axis, we first make a plot of all the data, excluding antenna DV04. (We must specify ydatacolumn='data' explicitly here because the default value of ydatacolumn equals the value used in the previous execution of plotms. In the previous execution ydatacolumn was set to model. See the online help, help plotms, for details.)

# In CASA
plotms(vis='X3c1_wvrtsys.ms',xaxis='time',yaxis='amp',coloraxis='corr',
       field='0',avgchannel='3840',ydatacolumn='data')

<figure id="ThreeScansAmp.png">

Amplitude variation for three 3C279 scans, spw 0 (for one representative baseline).

</figure>

We see that the uncalibrated amplitudes range between 0.2-0.4, so let's set this as our scale and examine a representative baseline (DV06-DV07) to see how the amplitude changes with time.

basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for spw in ['0','1','2','3']:
  for asdm in basename:
    print "Now showing spw %s from %s" % (spw, asdm+'.ms')
    plotms(vis=asdm+'.ms',spw=spw,xaxis='time',yaxis='amp',coloraxis='corr',iteraxis='spw',
           field='0',avgchannel='3840',antenna='DV06&DV07',plotrange=[0,0,0.2,0.4])
    user_check=raw_input('press enter to go to the next plot\n')

<figure id="ThreeScansPhase.png">

Phase variation for three 3C279 scans, spw 0 (for one representative baseline).

</figure>

Page through the measurement sets for each spw. This shows significant variations in the amplitude across the three measurement sets. Now do the same with phase.

# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for spw in ['0','1','2','3']:
  for asdm in basename:
    print "Now showing spw %s from %s" % (spw, asdm+'.ms')
    plotms(vis=asdm+'.ms',spw=spw,xaxis='time',yaxis='phase',coloraxis='corr',iteraxis='spw',
           field='0',avgchannel='3840',antenna='DV06&DV07',plotrange=[0,0,-180,180])
    user_check=raw_input('press enter to go to the next plot\n')

This examination reveals two findings: (1) significant variation in the phase across the three scans, as well as (2) smaller but significant variations within a scan. The first finding suggests that we do not want to combine the scans for bandpass calibration, but instead derive an independent bandpass for each scan. Actually what is more important than a DC offset is if the shape of the amplitude or phase changes from scan to scan. There isn't enough S/N to tell for sure so we will keep them separate. This situation is often the case, which is why we did not concatenate the three datasets prior to calibration. The second finding suggests that we need to correct the phase vs. time behavior of the bandpass calibrator (3C279; field=0) within each scan, before doing the bandpass. We want to chose a relatively narrow range of channels near the center of the spws so that the bandpass phase slopes (to be corrected with the bandpass calibration itself) do not decorrelate the signal. You need to avoid spectral regions that were completely flagged above.

# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
  os.system('rm -rf ' + asdm + '.bpphase.gcal')
  gaincal(vis=asdm+'.ms',caltable=asdm+'.bpphase.gcal',
          field='0',spw='0~3:900~1100',refant='DV06',
          calmode='p',solint='int',minsnr=2.0,minblperant=4)

<figure id="X7ef_wvrtsys.bpphase.X.png">

Phase only solutions for correlation X on the third scan of the bandpass calibrator 3C279.

</figure>

Inspect the phase-only calibration solutions for the bandpass calibrator. Look for any noisy solutions. We do XX and YY separately to reduce confusion in the plot. It will help if you make your plotcal window wide.

# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
  plotcal(caltable=asdm+'.bpphase.gcal',xaxis='time',yaxis='phase',spw='',antenna='1~8', 
          iteration='antenna',subplot=421,plotrange=[0,0,-180,180],
          figfile=asdm+'.bpphase.X.png',poln='X')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

In the plotcal gui you can use the magnifying glass symbol to zoom in on one of the scans to see the phase variations. The colors are the 4 different spws.

# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
  plotcal(caltable=asdm+'.bpphase.gcal',xaxis='time',yaxis='phase',spw='',antenna='1~8', 
          iteration='antenna',subplot=421,plotrange=[0,0,-180,180],
          figfile=asdm+'.bpphase.Y.png',poln='Y')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Next we apply this phase-only correction on the fly while calculating the bandpass solutions.

# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
  os.system('rm -rf ' + asdm + '.bandpass.bcal')
  bandpass(vis=asdm+'.ms',caltable=asdm+'.bandpass.bcal',
           field='0',spw='',combine='',refant='DV06',
           solint='inf',solnorm=T,minblperant=4,fillgaps=17,
           gaintable=[asdm+'.bpphase.gcal'])

You will see some error messages in the terminal, these are just related to the flagged channels. We set fillgaps=17 to interpolate across the smaller regions of flagged channels (mesospheric features and birdies).

<figure id="Bandpass.ampspw0.png">

Bandpass amplitude solution plots.

</figure> <figure id="Bandpass.phasespw0.png">

Bandpass phase solution plots.

</figure>

A few words about solint and combine:

In bandpass, the use of solint='inf' (as in "infinite") will derive a bandpass solution for each 3C279 scan, unless combine='scan' (which is the default). Here we set combine=' ' explicitly so that it does not combine the scans into one bandpass. Likewise, field boundaries are only crossed if combine='field', and spw boundaries are only crossed if combine='spw'. In some cases it can be helpful to combine fields if you suffer from lack of S/N, but it is never a good idea to combine spws.

Now inspect the phase and amplitude solutions. You are looking for excursions from smooth fits, or particularly noisy solutions compared to the others.

# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
    for spw in [0,1,2,3]:
        au.plotbandpass(asdm+'.bandpass.bcal',xaxis='freq',yaxis='amp', spw=spw,
            antenna='1~8', subplot=421, figfile=asdm+'.bandpass.amp', showatm=T,
            interactive=True)
# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
    for spw in [0,1,2,3]:
        au.plotbandpass(asdm+'.bandpass.bcal',xaxis='freq',yaxis='phase',spw=spw,
            antenna='1~8',subplot=421,figfile=asdm+'.bandpass.phs', showatm=T,
            interactive=True)

The values of phase on DV06 are very close to zero because it was used as the reference antenna.

Gain Calibration

Now that we have a bandpass solution to apply we can solve for the antenna-based phase and amplitude gain calibration. Since the phase changes on a much shorter timescale than the amplitude, we will solve for them separately. In particular, if the phase changes significantly over a scan time, the amplitude would be decorrelated, if the un-corrected phase were averaged over this timescale. Note that we re-solve for the gain solutions of the bandpass calibrator, so we can derive new solutions that are corrected for the bandpass shape. Since the bandpass calibrator will not be used again, this is not strictly necessary, but is useful to check its calibrated flux density for example.

# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
  os.system('rm -rf ' + asdm + '.intphase.gcal')
  gaincal(vis=asdm+'.ms',caltable=asdm+'.intphase.gcal',
          field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
          calmode='p',solint='int',minsnr=2.0,minblperant=4,
          gaintable=[asdm+'.bandpass.bcal'])

Here solint='int' coupled with calmode='p' will derive a single phase solution for each 10 second integration. Note that the bandpass table is applied on-the-fly before solving for the phase solutions, however the bandpass is NOT applied to the data permanently until applycal is run later on.

Although solint='int' (i.e. the integration time of 10 seconds) is the best choice to apply before solving for the amplitude solutions, it is not a good idea to use this to apply to the target. This is because the phase-scatter within a scan can dominate the interpolation between calibrator scans. Instead, we also solve for the phase on the scan time, solint='inf' (but combine=' ' , since we want one solution per scan) for application to the target later on. Unlike the bandpass task, for gaincal, the default of the combine parameter is combine=' ' .

# In CASA
for asdm in basename:
  os.system('rm -rf ' + asdm + '.scanphase.gcal')
  gaincal(vis=asdm+'.ms',caltable=asdm+'.scanphase.gcal',
          field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
          calmode='p',solint='inf',minsnr=2.0,minblperant=4,
          gaintable=[asdm+'.bandpass.bcal'])

Alternatively, instead of making a separate phase solution for application to the target, one can also run smoothcal to smooth the solutions derived on the integration time.

Next we apply the bandpass and solint='int' phase-only calibration solutions on-the-fly to derive amplitude solutions. Here the use of solint='inf' , but combine=' ' will result in one solution per scan interval.

# In CASA
for asdm in basename:
  os.system('rm -rf ' + asdm + '.amp.gcal')
  gaincal(vis=asdm+'.ms',caltable=asdm+'.amp.gcal',
          field='0,1,3,4',spw='0~3:40~3800',refant='DV06',
          calmode='ap',solint='inf',minsnr=2.0,minblperant=4,
          gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal'])

Now carefully inspect all these solutions looking for discrepant solutions. If you see any, you will need to flag them and rerun the calibration tasks above.

We make plots in X and Y separately for clarity. The colors are showing the spectral windows. <figure id="X3c1_wvrtsys.intphase_X.png">

Phase solutions for the X polarization for every integration time of the first dataset.

</figure>

# In CASA
for asdm in basename:
  plotcal(caltable=asdm+'.intphase.gcal',xaxis='time',yaxis='phase',antenna='1~8', 
          spw='',field='0,1,3,4',iteration='antenna',subplot=421,
          plotrange=[0,0,-180,180],poln='X',figfile=asdm+'.intphase_X.png')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')
# In CASA
for asdm in basename:
  plotcal(caltable=asdm+'.intphase.gcal',xaxis='time',yaxis='phase',antenna='1~8', 
          spw='',field='0,1,3,4',iteration='antenna',subplot=421,
          plotrange=[0,0,-180,180],poln='Y',figfile=asdm+'.intphase_Y.png')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

<figure id="X3c1_wvrtsys.scanphase_X.png">

Phase solutions for the X polarization for each scan of the first dataset.

</figure>

# In CASA
for asdm in basename:
  plotcal(caltable=asdm+'.scanphase.gcal',xaxis='time',yaxis='phase',antenna='1~8', 
          spw='',field='0,1,3,4',iteration='antenna',subplot=421,
          plotrange=[0,0,-180,180],poln='X',figfile=asdm+'.scanphase_X.png')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')
# In CASA
for asdm in basename:
  plotcal(caltable=asdm+'.scanphase.gcal',xaxis='time',yaxis='phase',antenna='1~8', 
          spw='',field='0,1,3,4',iteration='antenna',subplot=421,
          plotrange=[0,0,-180,180],poln='Y',figfile=asdm+'.scanphase_Y.png')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Since we have taken out the phase as best we can by applying the solint='int' phase-only solution, this plot will give a good idea of the residual phase error. If you see scatter of more than a few degrees here, you should consider going back and looking for more data to flag, particularly bad timeranges etc.

<figure id="X3c1_wvrtsys.amp_phase.png">

Residual phase after applying intphase.gcal for both correlations in the first dataset.

</figure> <figure id="X3c1_wvrtsys.amp_X.png">

Amplitude solutions on a scan interval for correlation X in the first dataset.

</figure>

# In CASA
for asdm in basename:
  plotcal(caltable=asdm+'.amp.gcal',xaxis='time',yaxis='phase',antenna='1~8', 
          spw='',field='0,1,3,4',plotrange=[0,0,-1,1],
          iteration='antenna',subplot=421,figfile=asdm+'.amp_phase.png')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

These are very small, as they should be. Now look at the amplitude solutions.

# In CASA
for asdm in basename:
  plotcal(caltable=asdm+'.amp.gcal',xaxis='time',yaxis='amp',antenna='1~8', 
          iteration='antenna',subplot=421,spw='',poln='X',
          plotrange=[0,0,0.0,0.3],figfile=asdm+'.amp_X.png')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')
# In CASA
for asdm in basename:
  plotcal(caltable=asdm+'.amp.gcal',xaxis='time',yaxis='amp',antenna='1~8', 
          iteration='antenna',subplot=421,spw='',poln='Y',
          plotrange=[0,0,0.0,0.3],figfile=asdm+'.amp_Y.png')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Flux Calibration

Next we use the flux calibrator (whose flux density was set in setjy above) to derive the flux density of the other calibrators. Note that the flux table REPLACES the amp.gcal in terms of future application of the calibration to the data, i.e. the flux table contains both the amp.gcal and flux scaling. Unlike the gain calibration steps, this is not an incremental table.

# In CASA
for asdm in basename:
  os.system('rm -rf ' + asdm + '.flux.cal')
  fluxscale(vis=asdm+'.ms',caltable=asdm+'.amp.gcal',
            fluxtable=asdm+'.flux.cal',reference='1',refspwmap=[0,1,3,3],
            listfile=asdm+'.fluxscale.txt')

Its a good idea to record the derived fluxscale values using the listfile option. The values can also be viewed in the Log Messages window.

Found reference field(s): Titan
Found transfer field(s):  3c279 J1147-382=QSO J1037-295=QSO
Spw=2 will be referenced to spw=3
Flux density for 3c279 in SpW=0 is: 10.5734 +/- 0.0190156 (SNR = 556.039, N = 16)
Flux density for 3c279 in SpW=1 is: 10.8103 +/- 0.0258999 (SNR = 417.388, N = 16)
Flux density for 3c279 in SpW=2 (ref SpW=3) is: 10.4268 +/- 0.0524249 (SNR = 198.891, N = 14)
Flux density for 3c279 in SpW=3 is: 10.0122 +/- 0.0216329 (SNR = 462.822, N = 16)
Flux density for J1147-382=QSO in SpW=0 is: 1.04139 +/- 0.0167475 (SNR = 62.182, N = 16)
Flux density for J1147-382=QSO in SpW=1 is: 0.838983 +/- 0.0191563 (SNR = 43.7968, N = 16)
Flux density for J1147-382=QSO in SpW=2 (ref SpW=3) is: 1.02209 +/- 0.025659 (SNR = 39.8337, N = 14)
Flux density for J1147-382=QSO in SpW=3 is: 1.299 +/- 0.0199392 (SNR = 65.1484, N = 16)
Flux density for J1037-295=QSO in SpW=0 is: 0.967053 +/- 0.00942059 (SNR = 102.653, N = 16)
Flux density for J1037-295=QSO in SpW=1 is: 0.758689 +/- 0.0157661 (SNR = 48.1215, N = 16)
Flux density for J1037-295=QSO in SpW=2 (ref SpW=3) is: 0.963367 +/- 0.0181981 (SNR = 52.9377, N = 14)
Flux density for J1037-295=QSO in SpW=3 is: 1.23762 +/- 0.0150691 (SNR = 82.1297, N = 16)

<figure id="x3c1_wvrtsys.flux_X.png">

Absolute flux calibration solutions for correlation X for the first dataset.

</figure>

Now look at the flux solutions.

# In CASA
for asdm in basename:
  plotcal(caltable=asdm+'.flux.cal',xaxis='time',yaxis='amp',antenna='1~8', 
          iteration='antenna',subplot=421,spw='',poln='X',
          plotrange=[0,0,0.0,0.3],figfile=asdm+'.flux_X.png')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')
# In CASA
for asdm in basename:
  plotcal(caltable=asdm+'.flux.cal',xaxis='time',yaxis='amp',antenna='1~8', 
          iteration='antenna',subplot=421,spw='',poln='Y',
          plotrange=[0,0,0.0,0.3],figfile=asdm+'.flux_Y.png')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Apply Calibration and Inspect

Now we can use the flagmanager if we want to restore any of the spectral flagging we did prior to bandpass calibration. In this case, we choose to restore the flags of the emission lines on Titan, because we are interested in seeing how strong they are compared to the continuum. However, we leave the strong ozone line and mesospheric CO line flagged on all sources, because we want to get the most accurate continuum flux density for the science target.

# In CASA
basename=["X3c1_wvrtsys","X5d8_wvrtsys","X7ef_wvrtsys"]
for asdm in basename:
  flagmanager(vis=asdm+'.ms',mode='restore',versionname=asdm+'.before_emissionflags')

Next we apply the calibration solutions to each source individually, using the gainfield parameter to specify which calibrator's solutions should be applied from each of the gaintable calibration tables.

First, we do 3C279 (the bandpass calibrator), applying all 3 of its solutions to itself (that's why gainfield contains three zeros):

# In CASA
for asdm in basename:
  applycal(vis=asdm+'.ms',field='0',
           gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],
           interp=['nearest','nearest','nearest'],
           gainfield=['0','0','0'], flagbackup=T, calwt=F)

Next, we do Titan (the absolute flux calibrator) using the bandpass solution from 3C279:

# In CASA
for asdm in basename:
  applycal(vis=asdm+'.ms',field='1',
           gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],
           interp=['nearest','nearest','nearest'],
           gainfield=['0','1','1'], flagbackup=T, calwt=F)

For the secondary phase calibrator, we apply the phase and flux solutions from the primary phase calibrator. This will allow us to check how well the phase transfer to the science target (TW Hya) has worked:

# In CASA
for asdm in basename:
  applycal(vis=asdm+'.ms',field='3',
           gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],
           interp=['nearest','linear','linear'],
           gainfield=['0','4','4'], flagbackup=T, calwt=F)

Next is the Primary phase calibrator:

# In CASA
for asdm in basename:
  applycal(vis=asdm+'.ms',field='4',
           gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],
           interp=['nearest','nearest','nearest'],
           gainfield=['0','4','4'], flagbackup=T, calwt=F)

Finally, for the Science Target TW Hya, we apply the phase solutions from both the primary and secondary phase calibrators:

# In CASA
for asdm in basename:
  applycal(vis=asdm+'.ms',field='2',
           interp=['nearest','linear','linear'],
           gaintable=[asdm+'.bandpass.bcal',asdm+'.scanphase.gcal',asdm+'.flux.cal'],
           gainfield=['0','3,4','3,4'], flagbackup=T, calwt=F)

Now we can check the results of applying the calibration solutions.

<figure id="Corrected_vs_time_1.png">

The calibrated data for the first dataset (amplitude vs. time).

</figure>

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='time',yaxis='amp',field='',avgchannel='3840',
         coloraxis='field',iteraxis='spw',ydatacolumn='corrected')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

In amplitude, it looks good but there are some noisy points toward the end of the first scheduling block, but it mostly only affects the secondary phase calibrator (green). In phase, we expect all the points to cluster about zero. The large scatter in phase on the secondary phase calibrator is readily apparent:

<figure id="Corrected_phase_vs_time_1.png">

The calibrated data on the calibrators for the first dataset (phase vs. time).

</figure>

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='time',yaxis='phase',field='0,1,3,4',avgchannel='3840',
         coloraxis='field',iteraxis='spw',ydatacolumn='corrected')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Let's check whether the situation improves when we apply this calibrator's solutions to itself rather than transferring the solutions from the primary phase calibrator (which is 17 degrees away, and observed at a different time).

# In CASA
for asdm in basename:
  applycal(vis=asdm+'.ms',field='3',
           gaintable=[asdm+'.bandpass.bcal',asdm+'.intphase.gcal',asdm+'.flux.cal'],
           interp=['nearest','nearest','nearest'],
           gainfield=['0','3','3'],flagbackup=T, calwt=T)

<figure id="Corrected_vs_time_1_field3.png">

The calibrated data for the first dataset (amplitude vs. time), but now with field 3, the secondary phase calibrator, calibrated with itself.

</figure>

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='time',yaxis='amp',field='',avgchannel='3840',
         coloraxis='field',iteraxis='spw',ydatacolumn='corrected')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

<figure id="Corrected_phase_vs_time_1_field3.png">

The calibrated data from the first dataset (phase vs. time), but now with field 3, the secondary phase calibrator, calibrated with itself.

</figure>

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='time',yaxis='phase',field='0,1,3,4',
         avgchannel='3840', coloraxis='field',iteraxis='spw',
         ydatacolumn='corrected')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Indeed, the secondary calibrator looks better now in amplitude and phase. This is an indication that the calibration transfer is not working well in this timerange. Because the effect is not catastrophic and we know we can self-calibrate on TW Hya later, we will let this go for now. Or, if you want you can delve deeper into the data and try to solve the mystery...

In any case, we will re-issue the original applycal so that it is this calibration that our subsequent split will use. This will allow us to check the effect of correcting the secondary phase calibrator with the primary phase calibrator later.

# In CASA
for asdm in basename:
  applycal(vis=asdm+'.ms',field='3',
           gaintable=[asdm+'.bandpass.bcal', asdm+'.scanphase.gcal', asdm+'.flux.cal'],
           interp=['nearest','linear','linear'],
           gainfield=['0','4','4'], flagbackup=T, calwt=F)


Let's check the spectral calibration now. First 3C279 and Titan:

<figure id="X3c1_spw2_corrected_3.4.png">

Spectral UV-plots of 3C279 and Titan of spw=2 for the first dataset.

</figure>

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='frequency',yaxis='amp',field='0,1',
         avgtime='1e8',avgscan=T,coloraxis='field',ydatacolumn='corrected',
         iteraxis='spw',xselfscale=T)
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Flip through the spws. These look good. Next the two phase calibrators:

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='frequency',yaxis='amp',field='3,4',
         avgtime='1e8',avgscan=T,coloraxis='field',ydatacolumn='corrected',
         iteraxis='spw',xselfscale=T)
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Flip through the spws. This also looks good, the secondary phase calibrator is a bit noisier but this is normal. The upswing at the lower frequency end of spw=3 will probably need to be flagged on the science target as well. It corresponds to the edge of an atmospheric feature.

Now for the exciting part, what does the science target look like...

# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='',xaxis='frequency',yaxis='amp',field='2',
         avgtime='1e8',avgscan=T,coloraxis='field',ydatacolumn='corrected',
         iteraxis='spw',xselfscale=T)
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

We see HCO+(4-3) in spw=0 and CO(3-2) in spw=2 as expected. Because the shape of the line profiles varies with baseline, you can already tell that the line emission is resolved.

<figure id="X3c1_CO3_2_uvplot_3.4.png">

UV-Plot of the TW Hya CO(3-2) emission from the first dataset.

</figure> <figure id="X3c1_HCOp4_3_uvplot_3.4.png">

UV-Plot of the TW Hya HCO+(4-3) emission from the first dataset.

</figure>

Now check that the velocity of TWHydra is correct in the LSRK frame, it should be around 2.88 km/s.

  • CO 3-2 rest freq 345.79599 GHz
  • HCO+ 4-3 rest freq 356.7342 GHz
# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='2',xaxis='velocity',yaxis='amp',field='2',
         avgtime='1e8',avgscan=T,transform=T,freqframe='LSRK',
         restfreq='345.79599GHz', plotrange=[-10,15,0,0],coloraxis='spw')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')
# In CASA
for asdm in basename:
  plotms(vis=asdm+'.ms',spw='0',xaxis='velocity',yaxis='amp',field='2',
         avgtime='1e8',avgscan=T,transform=T,freqframe='LSRK',
         restfreq='356.7342GHz',plotrange=[-10,15,0,0],coloraxis='spw')
  print('When you are done with the graphics window,')
  print('quit that window, and')
  user_check=raw_input('press enter to continue script\n')

Both lines show up at the expected velocity.


Concatenate the Data

Here we will concatenate the three datasets prior to imaging.

# In CASA
splitdata=['X3c1_wvrtsys.ms','X5d8_wvrtsys.ms','X7ef_wvrtsys.ms']
os.system('rm -rf Band7multi_april22.ms')
concat(vis=splitdata,concatvis='Band7multi_april22.ms')

If you like you can run listobs on new combined dataset

# In CASA
listfile = 'Band7multi_april22.listobs.txt'
os.system('rm ' + listfile)
listobs(vis='Band7multi_april22.ms',verbose=F, listfile=listfile)

<figure id="All_spw2_corrected_3.4.png">

Spectral UV-plots of 3C279 and Titan of spw=2 for the combined datasets.

</figure>

You can also examine the spectral uv plots for the combined dataset to see the improvement in S/N:

# In CASA
plotms(vis='Band7multi_april22.ms',spw='',xaxis='frequency',yaxis='amp',field='0,1',
       avgtime='1e8',avgscan=T,coloraxis='field',ydatacolumn='corrected',
       iteraxis='spw',xselfscale=T)

<figure id="All_CO3_2_uvplot_3.4.png">

UV-Plot of the TW Hya CO(3-2) emission from the combined datasets.

</figure>

...and the CO line profile for the combined dataset:

# In CASA
plotms(vis='Band7multi_april22.ms',spw='2',xaxis='velocity',yaxis='amp',field='2',
         avgtime='1e8',avgscan=T,transform=T,freqframe='LSRK',restfreq='345.79599GHz',
         plotrange=[-10,15,0,0],coloraxis='spw')

Split Calibrated Data

Now we split off the calibrated data for the Science Target as well as the interesting parts of the calibrators for imaging.

# In CASA
os.system('rm -rf TWHydra_corrected.ms')
split(vis='Band7multi_april22.ms',outputvis='TWHydra_corrected.ms',
      datacolumn='corrected',spw='',field='2')
# In CASA
os.system('rm -rf J1037_corrected.ms')
split(vis='Band7multi_april22.ms',outputvis='J1037_corrected.ms',
     datacolumn='corrected',spw='',field='4')
# In CASA
os.system('rm -rf J1147_corrected.ms')
split(vis='Band7multi_april22.ms',outputvis='J1147_corrected.ms',
      datacolumn='corrected',spw='',field='3')
# In CASA
os.system('rm -rf 3C279_CO3_2.ms')
split(vis='Band7multi_april22.ms',outputvis='3C279_CO3_2.ms',
      datacolumn='corrected',spw='2:1900~2000',field='0')

Optional: Reconcile Titan's Coordinates

If you do not care to image Titan, then you can skip this step and simply continue on to the imaging guide.

Our earlier treatment of Titan's coordinates using fixplanets replaced the zeros written by the ALMA control system with the correct position of the body at the instant of the first observation of that SB. As a result, it has slightly different positions in all three datasets, as seen by listobs:

# In CASA
listobs(vis='Band7multi_april22.ms',verbose=F)
ID   Code Name                RA              Decl          Epoch   SrcId nRows  
0    none 3c279               12:56:11.16657 -05.47.21.5247 J2000   0     70866  
1    none Titan               12:49:25.97588 -02.22.41.3024 J2000   1     4842   
2    none TW Hya              11:01:51.84498 -34.42.17.1609 J2000   2     515151 
3    none J1147-382=QSO       11:47:01.38151 -38.12.11.1179 J2000   3     40797  
4    none J1037-295=QSO       10:37:16.08989 -29.34.02.9888 J2000   4     171153 
5    none Titan               12:49:26.53729 -02.22.27.1521 J2000   0     4833   
6    none Titan               12:49:26.53059 -02.22.18.7878 J2000   0     4833   

If we want to image such moving objects observed across multiple SBs, we need to bring the positions into agreement, otherwise clean will try to make a mosaic. Task fixplanets can be used to do this. Here, we set the direction to the direction of the first dataset as reported by listobs. Note that the RA/Dec format is slightly different from the listobs output format. Also, we do not fix the uvw coordinates because they are already more correct now than they would be if we "fixed" them.

# In CASA
fixplanets(vis='Band7multi_april22.ms', field='Titan', direction='J2000 12h49m25.97588 -02d22m41.3024', fixuvw=False)

Check the header information again to see that the information for Titan has changed for the second and third datasets. They will appear as fields 5 and 6.

# In CASA
listobs(vis='Band7multi_april22.ms',verbose=F)
  ID   Code Name         RA            Decl           Epoch   SrcId 
  0    none 3c279               12:56:11.16657 -05.47.21.5247 J2000   0     70866  
  1    none Titan               12:49:25.97588 -02.22.41.3024 J2000   1     4842   
  2    none TW Hya              11:01:51.84498 -34.42.17.1609 J2000   2     515151 
  3    none J1147-382=QSO       11:47:01.38151 -38.12.11.1179 J2000   3     40797  
  4    none J1037-295=QSO       10:37:16.08989 -29.34.02.9888 J2000   4     171153 
  5    none Titan               12:49:25.97588 -02.22.41.3024 J2000   0     4833   
  6    none Titan               12:49:25.97588 -02.22.41.3024 J2000   0     4833   

Optional: Split Calibrated Titan Data

When we split off the Titan data, a few dozen warnings like the following are written to the log:

2012-05-15 22:00:35     WARN    split::SubMS::copySource()      Invalid SOURCE ID in SOURCE table row 20 

These can be ignored, because they do not indicate any problem that will prevent you from imaging Titan correctly at a single position using all the data in the output ms.

# In CASA
os.system('rm -rf Titan_cont.ms')
split(vis='Band7multi_april22.ms',outputvis='Titan_cont.ms',
      datacolumn='corrected',spw='0',field='1')
# In CASA
os.system('rm -rf Titan_CO3_2.ms')
split(vis='Band7multi_april22.ms',outputvis='Titan_CO3_2.ms',
      datacolumn='corrected',spw='2',field='1')
# In CASA
os.system('rm -rf Titan_unknown.ms')
split(vis='Band7multi_april22.ms',outputvis='Titan_unknown.ms',
      datacolumn='corrected',spw='3',field='1')

Continue on to Imaging of the Science Target

Now you can continue on to the imaging guide.