VLBA AIPS ans CASA Guide: Difference between revisions

From CASA Guides
Jump to navigationJump to search
Jlinford (talk | contribs)
No edit summary
Jlinford (talk | contribs)
No edit summary
 
(179 intermediate revisions by the same user not shown)
Line 1: Line 1:
The Guide walks through the calibration of the data set used in the [https://casaguides.nrao.edu/index.php?title=VLBA_Basic_Phase-referencing_Calibration_and_Imaging][VLBA Basic Phase-referencing Calibration and Imaging] tutorial.  It presents the steps that should be taken to calibrate the data using both AIPS and CASA.  In several cases the AIPS VLBAUTIL procedures are shown, as well as the AIPS tasks that those procedures call.
This Guide walks through the calibration of the data set used in the [https://casaguides.nrao.edu/index.php?title=VLBA_Basic_Phase-referencing_Calibration_and_Imaging VLBA Basic Phase-referencing Calibration and Imaging] tutorial.  It presents the steps that should be taken to calibrate the data using both AIPS and CASA.  In several cases the AIPS [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] procedures are shown, as well as the AIPS tasks that those procedures call. To use the [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] procedures, first enter "run vlbautil" in AIPS to initialize all of the procedures. 


Note that some steps are performed in different order depending on whether you are using AIPS or CASA.  Also, be aware that not all tasks in AIPS have an equivalent task in CASA (yet).
Because this is more of a walk-through and side-by-side comparison of AIPS and CASA, example images of what uses might see while using the various interactive tools (e.g., [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMAGR IMAGR], [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.imaging.tclean.html tclean], etc.) are not provided.
 
Note that some steps are performed in a different order depending on whether you are using AIPS or CASA.  Also, be aware that not all tasks in AIPS have an equivalent task in CASA (yet).
 
To follow along with this Guide, users should download the [http://casa.nrao.edu/Data/VLBA/TL016B.idifits TL016B.idifits] data set used in the [https://casaguides.nrao.edu/index.php?title=VLBA_Basic_Phase-referencing_Calibration_and_Imaging VLBA Basic Phase-referencing Calibration and Imaging] CASA Guide tutorial.
 
For a more detailed tutorial on AIPS continuum calibration, including self-calibration, see the [https://casaguides.nrao.edu/index.php/AIPS-Simple-Self-Cal AIPS Simple Self-calibration Tutorial].
 
== Starting the Programs ==
 
Starting CASA is very simple.  Once CASA is installed, simply type "casa" in the command line of a terminal.
 
Starting AIPS is also easy, but requires a few more steps than CASA.  Once AIPS is installed, type "aips tv=local" in the command line of a terminal.  The "tv=local" forces AIPS to use a tv window on the local machine rather than on a network.  Sometimes, it may be necessary to type "aips tv=local:0.0".  Once AIPS starts, users may be asked to select a printer (this depends on the installation).  Finally, users will be instructed to enter a user ID number.  Users can pick any number EXCEPT FOR 1.  Typically, users will pick a four digit number, such as 1000.  It is usually best to pick a new AIPS user ID number for each project, in order to keep data separate.  Users should make a note of the user ID number they choose at the start of each AIPS session.
 
 
== Running Tasks ==
 
In CASA, users can enter commands using the "inp-go" method or as a function call.  In the "inp-go" method, users will typically set all task parameters to their default values by typing "default(<task>)"; for example, "default(importfitsidi)".  Next, users would check the parameters associated with that task by typing "inp".  Then, users would enter the parameter values in the command line one at a time (or in sets separated by a semi-colon).  Once all necessary parameters have been entered, users can run the task by typing the task name or "go(<taskname>)".  When running a CASA task with a function call, users enter all of the non-default parameters in parentheses following the taskname and the task runs immediately; for example, importfitsidi(fitsidifile='TL016B.idifits', vis='tl018b.ms', constobsiid=True, scanreindexgap_s=15).
 
In AIPS, all tasks should be run using the "inp-go" method.  Set the default task parameters by typing "default <taskname>"; for example, "default fitld".  Then, type "inp" to see all the parameters associated with that task.  Enter the values for the parameters one at a time (or in sets separated by semi-colons) in the command line.  Check that all parameters are properly set by typing "inp" again and inspecting each parameter.  Finally, run the task by typing "go" or "go <taskname>"; for example, "go fitld".
 
Running the [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] procedures in AIPS is very similar to running a task.  Users should set the default parameter values by typing "default <procedure>"; for example, "default vlbaload".  Next, enter the parameter values.  The main difference between a task and a procedure in AIPS is that users should not type "go" to run a procedure.  Instead, just type the procedure name.  For example, once all of the parameters have been entered for [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBALOAD VLBALOAD], simply type "vlbaload" and the procedure will run.
 
The calibration steps shown below all use the "inp-go" style for both AIPS and CASA.
 
 
== Some Notes on AIPS ==
 
For those used to CASA, the way AIPS works will be a bit different.  Here are a few things that might be useful to know.
 
=== AIPS Tables ===
 
Both AIPS and CASA create calibration tables containing solutions derived by various tasks.  CASA stores these tables as extrenal files, and can use them on the fly or to create the CORRECTED_DATA column in the Measurement Set.  AIPS uses a set of pre-defined tables to hold the solutions and corrections stored internally to the program and applies all corrections on the fly (i.e., it never creates a new "corrected data" column).  AIPS users can see the tables associated with a data set at any time by typing "imh" (or "imhead").
 
Here are some of the table types and what they contain:
*GC = gain curve tables; contain the DPFU values and the gain curve corrections for amplitude calibration, usually from the FITS-IDI file but can also be read in from an antab file
*TY = system temperature tables; contain the system temperature values, usually from the FITS-IDI file but can also be read in from an antab file
*SN = solution tables; contain solutions derived by operations like fringe-fitting bandpass calibration, and self-calibration
*CL = calibration tables; contain the corrections that will be applied to the data, usually with values interpolated from an SN table via the task [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL]
*BP = bandpass tables; contain the corrections for the shape of the bandpass created by the task [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?BPASS BPASS]
*FG = flag tables; contain all of the flags, both from the FITS-IDI file (i.e., the online flags) and those created by users
 
It is a good idea to keep track of which table was create by which task, in case there are problems with the calibration and something needs to be rolled back.
 
=== Some Useful AIPS Commands ===
 
*uc: short for "ucat", lists all of the uv data sets in the current user ID
*mc: short for "mcat", lists all of the images in the current user ID
*getn #: get the data set associated with the catalog number #; this will populate the INNAME, INCLASS, and INSEQ parameters for a task
*get2n #: get the data set associated with the catalog number #; this will populate the IN2NAME, IN2CLASS, and IN2SEQ parameters for a task
*imh: short for "imhead", show the header for a selected catalog entry (uv data set or image), including all tables
*tget <task>: get all of the parameters that were used when running the task the last time (CASA has a similar feature)
*tvini: initialize the AIPS TV window (clear the window so something new can be displayed)
*restore 0: clear all inputs and return all tasks to default state; helpful when things go very wrong
*zap: destroy the current catalog entry (uv data set or image) and all tables associated with it - '''USE WITH EXTREME CAUTION'''
**Example: Destroy the data in catalog entry #4 - getn 4; zap
*extdest: destroy the current table - '''USE WITH EXTREME CAUTION '''
**Example: Destroy SN table #3 on the first uv data set - getn 1; inext 'sn'; inver 3; extdest
 
=== IF vs SPW ===
 
CASA labels the data channels as "spw" for "spectral window".  The first spectral window is spw 0.
 
AIPS labels the data channels as "IF" for "intermediate frequency".  The first intermediate frequency is IF 1.
 
When converting between CASA and AIPS, it is important to remember that spw 0 = IF 1.


To follow along with this Guide, users should download the TL016B.idifits data set used in the [https://casaguides.nrao.edu/index.php?title=VLBA_Basic_Phase-referencing_Calibration_and_Imaging VLBA Basic Phase-referencing Calibration and Imaging] tutorial.


== Initial Calibration ==
== Initial Calibration ==
This first section shows the steps for the initial calibration (instrumental delay, fringe fitting, bandpass correction).
This section shows the steps for the initial calibration (instrumental delay, fringe fitting, bandpass correction).


=== Loading Data ===
=== Loading Data ===
Line 14: Line 78:
{| class="wikitable"
{| class="wikitable"
|-
|-
! VLBAUTIL Procedure !! AIPS Task(s) !! CASA Task(s)
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|-
| VLBALOAD<br/>datain 'TL016B.idifits<br/>outname 'TL016B' || FITLD<br/>datain 'TL016B.idifits<br/>outname 'TL016B'<br/>clint 0.25 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.data.importfitsidi.html importfitsidi]<br/>fitsidifile='TL016B.idifits'<br/>vis='tl018b.ms'<br/>constobsiid=True<br/>scanreindexgap_s=15
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBALOAD VLBALOAD]<br/>datain 'PWD:TL016B.idifits<br/>outname 'TL016B'<br/>clint 0.25 || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FITLD FITLD]<br/>datain 'PWD:TL016B.idifits<br/>outname 'TL016B'<br/>clint 0.25 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.data.importfitsidi.html importfitsidi]<br/>fitsidifile='TL016B.idifits'<br/>vis='tl018b.ms'<br/>constobsiid=True<br/>scanreindexgap_s=15
|}
|}


Note that the lack of a trailing single tick (') in the datain parameter is not a typo.  Any parameter defined inside single ticks will be converted to all capital letters (e.g., datain 'PWD:TL016B.idifits' will set the DATAIN parameter to "PWD:TL016B.IDIFITS").  Omitting the trailing single tick will force AIPS to set the parameter exactly as typed.
Setting the DATAIN parameter to 'PWD:<datafile> will tell AIPS to look in the present working directory.  If the data are not located in the present working directory, users can define a directory using the export command in the terminal (e.g., export MYAIP=/home/user/mydata/; datain 'MYAIP:TL016B.idifits).  Users working in a C shell will need to use the setenv command instead of export.  Defining the directory must be done prior to starting AIPS.


=== Observation Summary ===
=== Observation Summary ===


Printing a summary of the observation is often useful for identifying the fringe finder, bandpass calibrator, phase reference calibrator, and science target.  It is also useful for locating a good time range to use for the instrumental delay correction.
Printing a summary of the observations is often useful for identifying the fringe finder, bandpass calibrator, phase reference calibrator, and science target.  It is also useful for locating a good time range to use for the instrumental delay correction.


{| class="wikitable"
{| class="wikitable"
|-
|-
! VLBAUTIL Procedure !! AIPS Task(s) !! CASA Task(s)
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|-
|rowspan="2"| VLBASUMM<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>docrt 132  
|rowspan="2"| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBASUMM VLBASUMM]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>docrt 132  
|PRTAN<br/> inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>docrt 132<br/>dotv 1  
|[http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?PRTAN PRTAN]<br/> inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>docrt 132<br/>dotv 1  
|rowspan="2"| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.information.listobs.html listobs]<br/>vis='tl016b.ms'
|rowspan="2"| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.information.listobs.html listobs]<br/>vis='tl016b.ms'
|-
|-
|LISTR<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>optype 'scan'
|[http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?LISTR LISTR]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>optype 'scan'
|}
<b>NOTE: </b>In CASA, to have listobs save the observation summary to a file called 'tl018b_listobs.txt', set listfile='tl016b_listobs.txt'.
 
 
=== Inspecting the Data and Choosing a Reference Antenna ===
Before getting into the actual calibration steps, it is a good idea to inspect the data and choose a good reference antenna.  Start by inspecting a scan on the bandpass calibrator that is near the middle of the data set.  For tutorial data set, the third scan on 4C39.25 (scan 91) is a good place to start.
 
In CASA, this is done with [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casaplotms.plotms.html plotms]. 
 
In AIPS, this is done with [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?POSSM POSSM].  [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?POSSM POSSM] will display the phases and amplitudes for each baseline in a single plot.  By setting the nplots parameter to 9, [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?POSSM POSSM] will display nine baselines at a time.
 
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?POSSM POSSM]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>sources '4C39.25'<br/>stokes 'half'<br/>timerang 0 9 16 23 0 9 19 53<br/>aparm(9) 1<br/>nplots 9<br/>dotv 1 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casaplotms.plotms.html plotms]<br/>vis='tl016b.ms'<br/>xaxis='frequency'<br/>yaxis='phase'<br/>field='4C39.25'<br/>scan='91'<br/>correlation='ll'<br/>antenna='FD,LA,PT'<br/>iteraxis='baseline'<br/>coloraxis='spw'
|}
<b>NOTE:</b> If you invoke [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] in AIPS, you can auto-populate the TIMERANG parameter by setting "timerang=scantime(91)".
 
In [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?POSSM POSSM], to display the next group of baselines, click in the AIPS TV window and then press "B".
 
When using [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casaplotms.plotms.html plotms] to inspect the data, remember to change the correlation to 'rr' and change the yaxis to 'amp' in order to look at all the relevant data.
 
 
=== Quacking the Data ===
"Quacking" refers to flagging the beginning and/or end of each scan in a data set.  This is a completely optional step, but it is often useful for VLBA data.
 
Flag the first 4 seconds of each scan.
 
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?QUACK QUACK]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>opcode 'BEG'<br/>reason 'QUACK'<br/>aparm 0 4/60 0 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl018b.ms'<br/>mode='quack'<br/>quackmode='beg'<br/>quackinterval=4.0<br/>quackincrement=True
|}
 
Flag the last 4 seconds of each scan.
 
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?QUACK QUACK]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>opcode 'ENDB'<br/>reason 'QUACK'<br/>aparm 0 4/60 0 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl018b.ms'<br/>mode='quack'<br/>quackmode='endb'<br/>quackinterval=4.0<br/>quackincrement=True
|}
 
<b>NOTE:</b> Setting the REASON parameter in [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?QUACK QUACK] (and later in [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG UVFLG]) can be useful if flags need to be undone.
 
 
=== Automated Flagging ===
The [https://casaguides.nrao.edu/index.php?title=VLBA_Basic_Phase-referencing_Calibration_and_Imaging VLBA Basic Phase-referencing Calibration and Imaging] tutorial shows users how to run the TFCrop automated flagging routine on the data to remove some time-based RFI.  AIPS does not have an equivalent task to TFCrop, but users can opt to use the [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?RFLAG RFLAG] automated flagging after the bandpass corrections have been applied (later in the calibration).
 
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || ''none'' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl016b.ms'<br/>mode='tfcrop'<br/>datacolumn='data'<br/>timecutoff=4.0<br/>flagdimension='time'<br/>action='calculate'<br/>display='both'<br/>
|}
With action='calculate', no flags will be generated.  Instead, you should just verify that the TFCrop flagging is doing what you expect.  You can always click 'Quit' and adjust the timecutoff parameter as you see fit.
 
Once you are satisfied that the program is going to flag things appropriately, set action='apply' and run it again.
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || ''none'' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl016b.ms'<br/>mode='tfcrop'<br/>datacolumn='data'<br/>timecutoff=4.0<br/>flagdimension='time'<br/>action='apply'<br/>display='both'<br/>
|}
Double check that the flags look appropriate, then click "Stop Display" to have the TFCrop routine set and apply the flags.
 
For some observations, especially at frequencies below 4 GHz, it will be useful to have TFCrop look for RFI in both frequency and time.  In this case, set fladimension='freqtime' (the default), and freqcutoff=3.0.  Check that the flags look appropriate and adjust the freqcutoff parameter as necessary before applying the flags.
 
=== Interactive Flagging ===
 
AIPS has multiple tasks that allow users to display the data and flag them in the AIPS TV window.  For VLBI arrays, where the number of stations is relatively small, these are very powerful tools for finding and flagging bad data.
 
<b>FTFLG</b>
 
[http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FTFLG FTFLG] combines the data from all the baselines and displays them in a waterfall plot with spectral channels on the horizontal axis, and time going up on the vertical axis (i.e., the bottom-most data are the first data taken in the observation).  Hopefully, you will not see anything obviously bad in [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FTFLG FTFLG] plots of VLBA data (RFI is usually confined to a single antenna, so averaging all the stations together tends to wash it out).  However, it is a very good tool to find any satellite transmissions that might be in your data.
 
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FTFLG FTFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1 || ''none''
|}
Be sure to switch between the polarizations using the GUI controls (select "Display LL", hit "A", select "Load", hit "A").
You can change what data is displayed using the DPARM parameter (DPARM(1) 0 = display amplitude, DPRAM(1) 1 = display phase, etc.).
 
<b>SPFLG</b>
 
Like [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FTFLG FTFLG], [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPFLG SPFLG] displays a waterfall plot with spectral channels on the horizontal axis and time going up on the vertical axis.  Unlike [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FTFLG FTFLG], [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPFLG SPFLG] does not combine the data.  Instead, it displays a single baseline at a time.  You can move through all the baselines using the GUI controls.
 
[http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPFLG SPFLG] is an excellent tool for finding narrow-band (and sometimes wide-band) RFI on each baseline.
 
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPFLG SPFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1 || ''none''
|}
You can switch between polarizations just as in [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FTFLG FTFLG], and the DPARM parameters are also similar.
 
<b>NOTE:</b> It is generally a good idea to set the STOKES flag to "1111" - select "ENTER STOKES FLAG", press "A", in the terminal type "1111" and hit enter.  This means whenever a flag is created, it will flag across all polarizations (RR, LL, RL, & LR).
 
<b>TVFLG</b>
 
[http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TVFLG TVFLG] displays a waterfall plot with baseline on the horizontal axis and time going up on the vertical axis.  It is often helpful to average the spectral channels together when running [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TVFLG TVFLG], especially if you have already inspected/flagged the data with [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPFLG SPFLG].  [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TVFLG TVFLG] is an excellent tool for finding and flagging time-variable problems in the data.  It can also reveal if one station was having problems.
 
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TVFLG TVFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>nchav 128 || ''none''
|}
For the tutorial data set, setting NCHAV 128 will average all of the spectral channels together.
 
Use the GUI tools to step through the IFs (remember, the AIPS term for "spectral window" is "intermediate frequency" or "IF").  Once you have gone through all IFs in one polarization, [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TVFLG TVFLG] will start showing the other polarization.
 
<b>NOTE:</b> Just as for [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPFLG SPFLG], it is generally a good idea to set the STOKES flag to "1111" - select "ENTER STOKES FLAG", press "A", in the terminal type "1111" and hit enter.  This means whenever a flag is created, it will flag across all polarizations (RR, LL, RL, & LR).
 
You can inspect the data with any of these interactive flagging tools at any time throughout the calibration.  Just remember to set the calibration parameters properly.  Setting DOCAL 1 will apply the CL table that is specified with GAINUSE (GAINUSE 0 means use the highest number CL table).  Once you have done the bandpass calibration, remember to set DOBAND 1 and BPVER 1 (or to the desired bandpass table, if there is more than one).
 
=== Manual Flagging ===
The [https://casaguides.nrao.edu/index.php?title=VLBA_Basic_Phase-referencing_Calibration_and_Imaging VLBA Basic Phase-referencing Calibration and Imaging] tutorial includes a significant amount of additional flagging.  AIPS users should start their flagging by using the graphical tools [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FTFLG FTFLG], [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPFLG SPFLG], and [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TVFLG TVFLG].  CASA does not have equivalent graphical flagging tools.  CASA users can try using the viewer to display the data in a manner similar to [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPFLG SPFLG] and [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TVFLG TVFLG], as described in Section 2.1.2 of [https://library.nrao.edu/public/memos/vlba/sci/VLBAS_38.pdf VLBA Scientific Memo #38].  However, the CASA viewer is not very reliable, especially for creating flags.
 
Fortunately, both AIPS and CASA have tasks for creating flags without a graphical interface.  Here are examples of flagging some of the data:
 
<b>Flag all baselines to HN on final scan of 4C39.5</b>
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG UVFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>timerang 0 12 13 23 0 12 16 53<br/>antennas 3 0<br/>opcode 'FLAG'<br/>reason 'HNLOW' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl018b.ms'<br/>mode='manual'<br/>field='4C39.25'<br/>antenna='HN'<br/>scan='181'
|}
<b>NOTE: </b>Entering a short note in the reason parameter in UVLFG can be useful if the flags need to be undone at some point.
 
<b>Flag the BR-PT baseline on scan 10</b>
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG UVFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>timerang 0 6 30 57 0 6 31 37<br/>antennas 1 0<br/>baseline 9 0<br/>opcode 'FLAG'<br/>reason 'BRPT10HOT' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl018b.ms'<br/>mode='manual'<br/>field='J1154+6022'<br/>antenna='BR&PT'<br/>scan='10'
|}
|}
To see all the flags that are recommended for this data set, refer to the [https://casaguides.nrao.edu/index.php?title=VLBA_Basic_Phase-referencing_Calibration_and_Imaging VLBA Basic Phase-referencing Calibration and Imaging] tutorial.  It may be easier to flag the data by running [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPFLG SPFLG] again, but set SOURCE 'J1154+6022' to only see the phase reference calibrator.  Then try again just looking at the science target J1203+6031.




=== Total Electron Content Correction ===
=== Total Electron Content Correction ===
To make the TEC correction using [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TECOR TECOR], you will first need to download the appropriate TEC file from ftp://gdc.cddis.eosdis.nasa.gov/gps/products/ionex/.  The [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBATECR VLBATECR] procedure will download the necessary file automatically.


{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBATECR VLBATECR]<br/> inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1 || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TECOR TECOR]<br/> inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>aparm 1 0<br/>infile ' ''tec file'' ' || ''no equivalent CASA task yet''
|}
<b>NOTE: </b>Do not use the tec_maps CASA tool with VLBA data.  It does not work properly for VLBI observations.
=== Earth Orientation Parameter Correction ===
To make the EOP correction using [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCOR CLCOR], you will first need to download the appropriate file from ftp://cddis.gsfc.nasa.gov/vlbi/gsfc/ancillary/solve_apriori/usno_finals.erp.  The [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAEOPS VLBAEOPS] procedure will download the necessary file automatically.


{| class="wikitable"
{| class="wikitable"
|-
|-
! VLBAUTIL Procedure !! AIPS Task(s) !! CASA Task(s)
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|-
| VLBATECR || TECOR || no equivalent CASA task yet
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAEOPS VLBAEOPS]<br/> inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1 || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCOR CLCOR]<br/> inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>opcode 'eops'<br>infile ' ''eop file'' ' || ''no equivalent CASA task yet''
|}
|}


<b>NOTE: </b>Do not use the tec_maps tool with VLBA data. It does not work properly for VLBI observations.
 
=== Sampler Corrections ===
For VLBA data, it is necessary to make corrections based on the autocorrelations.  This step is not required when calibrating EVN data because it is performed during correlation.
 
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|rowspan="3"| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBACCOR VLBACCOR]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?ACCOR ACCOR]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>solint -0.5
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.accor.html accor]<br/>vis='tl016b.ms'<br/>caltable='tl016b.accor'<br/>solint='30s'
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNSMO SNSMO]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>inver 0<br/>samptype 'mwf'<br/>smotype 'ampl'<br/>cparm 0.5 0 0 0 0 1<br/>outvers 0
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.smoothcal.html smoothcal]<br/>vis='tl016b.ms'<br/>tablein='tl016b.accor'<br/>caltable='tl016b_smooth.accor'<br/>smoothtype='median'<br/>smoothtime=1800.0
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>opcode 'cali'<br/>interp 'self'<br/>snver 0<br/>dobalnk -1<br/>gainver 0<br/>gainuse 0
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.applycal.html applycal]<br/>vis='tl016b.ms'<br/>gaintable=['tl016b_smooth.accor']<br/>interp=['nearest']<br/>parang=True
|}
<b>NOTE:</b> There may be times when it is necessary to edit an SN table in AIPS.  You can do this interactively with [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNEDT SNEDT].




== Earth Orientation Parameter Correction ==
=== ''A Priori'' Calibration ===


When calibrating VLBA data in CASA, it is usual to generate the ''a priori'' calibration tables at this point: gain curve and system temperature.  This step is unnecessary in AIPS because the gain curve (GC) and system temperature (TY) tables are created automatically with [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FITLD FITLD] or [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBALOAD VLBALOAD].


<b>Gain Curve</b>
{| class="wikitable"
{| class="wikitable"
|-
|-
! VLBAUTIL Procedure !! AIPS Task(s) !! CASA Task(s)
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|-
| VLBAEOPS || CLCOR<br/>opcode 'eops' || no equivalent CASA task yet
| ''none, done in [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBALOAD VLBALOAD]'' || ''none, done in [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FITLD FITLD]'' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.gencal.html gencal]<br/>vis='tl018b.ms'<br/>caltable='tl016b.gcal'<br/>caltype='gc'
|}
|}


<b>System Temperature</b>
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none, done in [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBALOAD VLBALOAD]'' || ''none, done in [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FITLD FITLD]'' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.gencal.html gencal]<br/>vis='tl018b.ms'<br/>caltable='tl016b.tsys'<br/>caltype='tsys'<br/>uniform=False
|}


=== Sampler Corrections ===


=== Inspect the System Temperature Values ===
It is always a good idea to plot the system temperature values and look for obvious outliers. 
In AIPS, it will be necessary to type "tvini" to initialize the AIPS TV window prior to running [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNPLT SNPLT].  If the AIPS TV window is not initialized (cleared), [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNPLT SNPLT] will plot its data over the previous image and it can look very messy.
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNPLT SNPLT]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>inext 'ty'<br/>inver 1<br/>nplots 4<br>optype 'tsys'<br/>dotv 1 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casaplotms.plotms.html plotms]<br/>vis='tl018b.tsys'<br/>xaxis='time'<br/>yaxis='tsys'<br/>iteraxis='antenna'<br/>coloraxis='spw'
|}
<b>NOTE:</b> In [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNPLT SNPLT], if DOTV is set to -1, it will not display the plots in the AIPS TV window.  Instead, it will create the plots as PL tables attached to the uvdata file.  PL tables can be displayed in the AIPS TV window using the TVPL task.
=== Flag the Data with Bad Tsys ===
Flag the final scan of 4C39.5
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG UVFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>timerang 0 12 13 23 0 12 16 53<br/>opcode 'FLAG'<br/>reason '4C39LOWE' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl018b.ms'<br/>mode='manual'<br/>field='4C39.25'<br/>scan='181'
|}
Flag the last two data channels on BR
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG UVFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>antennas 1<br/>bif 3<br/>eif 4<br/>opcode 'FLAG'<br/>reason 'BRIF34HOT' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl018b.ms'<br/>mode='manual'<br/>antenna='BR'<br/>spw='2,3'
|}
<b>NOTE:</b> Recall that spw 0 = IF 1, spw 1 = IF 2, spw 2 = IF 3, and spw 3 = IF 4.
Flag the last data channel on KP
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG UVFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>antennas 4<br/>bif 4<br/>eif 4<br/>opcode 'FLAG'<br/>reason 'KPIF4HOT' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl018b.ms'<br/>mode='manual'<br/>antenna='KP'<br/>spw='3'
|}
Flag the third data channel on LA
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG UVFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>antennas 5<br/>bif 3<br/>eif 3<br/>opcode 'FLAG'<br/>reason 'LAIF3HOT' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl018b.ms'<br/>mode='manual'<br/>antenna='LA'<br/>spw='2'
|}
Flag the last data channel on NL
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG UVFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>antennas 7<br/>bif 4<br/>eif 4<br/>opcode 'FLAG'<br/>reason 'NLIF4HOT' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl018b.ms'<br/>mode='manual'<br/>antenna='NL'<br/>spw='3'
|}


Flag the last data channel on SC for the end of the obsevration
{| class="wikitable"
{| class="wikitable"
|-
|-
! VLBAUTIL Procedure !! AIPS Task(s) !! CASA Task(s)
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|-
|rowspan="2"| VLBACCOR
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG UVFLG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>antennas 10<br/>bif 4<br/>eif 4<br/>timerang 0 10 46 48 0 13 27 09<br/>opcode 'FLAG'<br/>reason 'SC4BADEND' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>vis='tl018b.ms'<br/>mode='manual'<br/>antenna='SC'<br/>spw='3'<br/>scan='135~223'
| ACCOR
|}
| accor
 
 
=== Parallactic Angle Correction ===
 
It often will not make a big difference when you apply the parallactic angle correction.  However, there are some cases when it is important to do the parallactic angle correction before moving on to the next calibration step.  In particular, if a data set requires phase referencing, the parallactic angle correction should be made prior to any fringe fitting (also, when you plan to combine polarizations for fringe fitting).  So, we will make that correction early in the calibration for our data set.
 
{| class="wikitable"
|-
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|-
| SNSMO
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAPANG VLBAPANG]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1 || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCOR CLCOR]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>gainver 0<br/>gainuse 0<br/>opcode 'pang'<br/>clcorprm 1 0 || ''done by setting parang=True in future fringefit, bandpass, and applycal steps''
| smoothcal
|}
|}


=== Instrumental Delay Correction ===
=== Instrumental Delay Correction ===


<b>NOTE: </b>Many VLBA users are likely familiar with the VLBAUTIL procedure VLBAPCOR and the associated AIPS task PCCOR, which use the pulse-cal tone information from the VLBA to correct for the instrumental delay.  CASA does not currently have a means of working with the pulse-cal tones, so it cannot use this functionality.  It is an area of active development for the NRAO and JIVE CASA software engineers and scientists.
<b>NOTE: </b>Many VLBA users are likely familiar with the [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] procedure [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAPCOR VLBAPCOR] and the associated AIPS task [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?PCCOR PCCOR], which use the pulse-cal tone information from the VLBA to correct for the instrumental delay.  CASA does not currently have a means of working with the pulse-cal tones, so it cannot use this functionality.  In order to do a direct comparison between AIPS and CASA, we will use the [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAMPCL VLBAMPCL] procedure, which runs [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FRING FRING] and [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL].  Using the pulse-cal tones in CASA is an area of active development for the NRAO and JIVE CASA software engineers and scientists.  In practice, fringe fitting a bright source on each IF/spw separately has been shown to be a satisfactory substitute for pulse-cal tones in EVN usage; for a very long experiment it may be necessary to have multiple such single-band delay calibrations.  


{| class="wikitable"
{| class="wikitable"
|-
|-
! VLBAUTIL Procedure !! AIPS Task(s) !! CASA Task(s)
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|-
|rowspan="2"| VLBAMPCL  
|rowspan="2"| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAMPCL VLBAMPCL]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>timerang 0 9 17 0 0 9 18 0<br/>calsour '4C39.25'<br/>refant 2
| FRING  
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FRING FRING]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>docal 1<br/>gainuse 0<br/>timerang 0 9 17 0 0 9 18 0<br/>solint 0<br/>calsour '4C39.25'<br/>refant 2<br/>aparm(1) 2<br/>dparm(1) 1<br/>dparm(8) 1<br/>snver 0
| fringefit
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.fringefit.html fringefit]<br/>vis='tl016b.ms'<br/>caltable='tl016b.sbd'<br/>field='4C39.25'<br/>timerange='09:17:00~09:18:00'<br/>solint='inf'<br/>zerorates=True<br/>refant='FD'<br/>minsnr=10<br/>gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys']<br/>interp=['nearest', 'nearest', 'nearest,nearest']<br/>parang=True
|-
|-
| CLCAL
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>timer 0<br/>interp '2pt'<br/>snver 0<br/>refant 2<br/>calsour '4C39.25'<br/>opcode 'CALP'<br/>gainver 0<br/>gainuse 0
| applycal
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.applycal.html applycal]<br/>vis='tl016b.ms'<br/>gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd']<br/>interp=['nearest', 'nearest', 'nearest,nearest', 'nearest']<br/>parang=True
|}
|}
<b>NOTE:</b> For very long observations, it is a good idea to make the delay-rate solutions zero before extrapolating them to the rest of data.  To do so in AIPS, use the [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNCOR SNCOR] task and set OPCODE to 'ZRAT'.  This should be done after creating the SN table with [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FRING FRING], and before creating the CL table with [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL].  If the delay-rates solutions are extrapolated in the time dimension too far from the solution interval, it can cause huge problems with the data.  In the CASA [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.fringefit.html fringefit] task, we set zerorates=True to avoid this problem.
<b>IMPORTANT</b>
Note that in the CASA calibration process, the gain curve and system temperature calibration tables have been applied at this point.  That means the the amplitude values are now in Janskys.  The AIPS amplitude calibration is not done until after the bandpass correction.




=== Global Fringe Fitting ===
=== Global Fringe Fitting ===


The VLBAUTIL package contains 2 methods for doing the global fringe fit:  
The [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] package contains 2 methods for doing the global fringe fit:  
* VLBAFRNG does a fringe fit on every source in the observation
* [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAFRNG VLBAFRNG] does a fringe fit on every source in the observation
* VLBAFRGP does a fringe fit on the phase-reference calibrator(s) and transfers those solutions to the science target(s)
* [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAFRGP VLBAFRGP] does a fringe fit on the phase-reference calibrator(s) and transfers those solutions to the science target(s)
 
This data set required phase referencing, so we will use the [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAFRGP VLBAFRGP] method.


{| class="wikitable"
{| class="wikitable"
|-
|-
! VLBAUTIL Procedure !! AIPS Task(s) !! CASA Task(s)
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|-
|rowspan="2"| VLBAFRNG<br/>or VLBAFRGP
|rowspan="2"| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAFRGP VLBAFRGP]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>calsour 'J1154+6022','4C39.25'<br/>gainuse 0<br/>refant 2<br/>search 9 5 4 8 7 3<br/>solint 0.5<br/>sources 'J1154+6022','4C39.25','J1203+6031'<br/>interpol '2pt'
| FRING  
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FRING FRING]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>calsour '4C39.25','J1154+6022'<br/>docal 1<br/>gainuse 0<br/>refant 2<br/>search 9 5 4 8 7 3<br/>solint 0.5<br/>snver 0
| fringefit
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.fringefit.html fringefit]<br/>vis='tl016b.ms'<br/>caltable='tl016b.mbd'<br/>field='4C39.25, J1154+6022'<br/>solint='30s'<br/>minsnr=5<br/>zerorates=False<br/>refant='FD,PT,LA,KP,OV,NL,HN'<br/>gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd']<br/>interp=['nearest', 'nearest', 'nearest,nearest', 'nearest']<br/>parang=True
|-
|-
| CLCAL
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>timer 0<br/>interp '2pt'<br/>snver 0<br/>refant 2<br/>calsour '4C39.25','J1154+6022'<br/>opcode 'CALP'<br/>gainver 0<br/>gainuse 0
| applycal
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.applycal.html applycal]<br/>vis='tl016b.ms'<br/>gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd', 'tl016b.mbd']<br/>interp=['nearest', 'nearest', 'nearest,nearest', 'nearest', 'linear']<br/>parang=True
|}
|}
<b>NOTE:</b> For the global fringe fitting step, it is a good idea to provide a list of possible alternate reference antennas.  In AIPS, this is done using the SEARCH parameter in [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FRING FRING].  In CASA, the first antenna listed in the refant parameter is the primary reference antenna, and the others listed are alternates (in order of priority; e.g., the second antenna listed is the first choice for an alternate reference antenna).
For the provided data set, the phase reference calibrator is bright enough to derive good solutions on a per IF/spw basis.  Users who have data sets with dimmer phase reference calibrators may find it necessary to combine the IFs/spws when doing the global fringe fitting step to get good signal-to-noise ratios.  In the AIPS task [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FRING FRING], this is done by setting the APARM(5) paramenter to 1.  In the CASA task [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.fringefit.html fringefit], this is done by setting combine='spw'.  For more information on this in CASA, see the [https://www.jb.man.ac.uk/DARA/unit4/Workshops/EVN_continuum_part_1.html#multiband_delay DARA EVN Continuum Tutorial: Part 1, Section 5B - Multi-band Delays].




Line 115: Line 442:
{| class="wikitable"
{| class="wikitable"
|-
|-
! VLBAUTIL Procedure !! AIPS Task(s) !! CASA Task(s)
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|-
| VLBABPSS || BPASS || bandpass
| rowspan="2"| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBABPSS VLBABPSS]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>calsour '4C39.25'<br/>refant 2
| rowspan="2"| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?BPASS BPASS]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>calsour '4C39.25'<br/>refant 2<br/>docal 1<br/>ginause 0<br/>solint -1<br/>bpassprm(5) 1<br/>bpassprm(9) 1<br/>bpassprm(10) 6
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.bandpass.html bandpass]<br/>vis='tl016b.ms'<br/>caltable='tl016b.bpass'<br/>field='4C39.25'<br/>solint='inf'<br/>refant='FD'<br/>solnorm=True<br/>bandtype='B'<br/>gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd', 'tl016b.mbd']<br/>interp=['nearest', 'nearest', 'nearest,nearest', 'nearest', 'linear']<br/>parang=True)
|-
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.applycal.html applycal]<br/>vis='tl016b.ms'<br/>gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd', 'tl016b.mbd', 'tl016b.bpass']<br/>interp=['nearest', 'nearest', 'nearest,nearest', 'nearest', 'linear', 'linear,linear']<br/>parang=True
|}
|}
<b>NOTE: </b>In AIPS, you do not need to apply the bandpass correction with [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL]; you simply need to set doband=1 in all subsequent calibration steps.




Line 125: Line 457:
{| class="wikitable"
{| class="wikitable"
|-
|-
! VLBAUTIL Procedure !! AIPS Task(s) !! CASA Task(s)
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
|-
|-
|rowspan="5"| VLBAAMP
|rowspan="5"| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAAMP VLBAAMP]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>ichansel 8 122 1 0
| ACSCL  
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?ACSCL ACSCL]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>docal 1<br/>gainuse 0<br/>doband 1<br/>bpver 1<br/>solint -2<br/>ichansel 8 122 1 0
| accor
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.accor.html accor]<br/>vis='tl016b.ms'<br/>spw='*:7~121'<br/>caltable='tl016b.acscl'<br/>solint='2min'<br/>gaintable=['tl016b_smooth.accor', 'tl016b.sbd', 'tl016b.mbd', 'tl016b.bpass']<br/>interp=['nearest', 'nearest', 'linear', 'linear,linear']
|-
|-
| SNSMO
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNSMO SNSMO]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>samptype 'mwf'<br/>doblank -1<br/>smotype 'ampl'<br/>cparm 0.5 0 0 0 0 1<br/>inver 0<br/>outver 0
| smoothcal
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.smoothcal.html smoothcal]<br/>vis='tl016b.ms'<br/>tablein='tl016b.acscl'<br/>caltable='tl016b_smooth.acscl'<br/>smoothtype='median'<br/>smoothtime=1800.0
|-
|-
| CLCAL
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>opcode 'cali'<br/>interpol 'self'<br/>snver 0<br/>doblank -1<br/>gianver 0<br/>gainuse 0
| applycal
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.applycal.html applycal]<br/>vis='tl016b.ms'<br/>gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd', 'tl016b.mbd', 'tl016b.bpass', 'tl016b_smooth.acscl']<br/>interp=['nearest', 'nearest', 'nearest,nearest', 'nearest', 'linear', 'linear,linear', 'nearest']<br/>parang=True
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?APCAL APCAL]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>tyver 0<br/>gcver 0<br/>snver 0
| ''done with gencal in the A Priori Calibration section above''
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>opcode 'cali'<br/>interp 'self'<br/>snver 0<br/>doblank -1<br/>gainver 0<br/>gainuse 0
| ''already applied above''
|}
<b>IMPORTANT: </b> When doing the final accor step in CASA, DO NOT apply the gain curve or system temperatures!
 
 
=== Split the Calibrated Data Into a New File ===
At this point, it is good practice to apply all the calibration and split the calibrated data into a new file.  It is usually a good idea to drop any of the edge channels that look bad, or that were not used in the final amplitude calibration step ([http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAAMP VLBAAMP], [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?ACSCL ACSCL], etc.).  We will not be doing any further calibration with the bandpass calibrator (4C39.25), so we can omit that from the new file.
 
In CASA, the [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.manipulation.split.html split] task will create a new MS file with all of the sources included in the field variable.  Also, it is safe to drop the autocorrelations from the new file by setting antennas='*&*'.
 
In AIPS, there are two options for applying the calibration and creating new files.  The task [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPLIT SPLIT] will create a separate single-source file for each source included in the SOURCES parameter.  If SOURCES is blank, it will create a new file for each source in the data set.  The task [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPLAT SPLAT] will create a new multi-source file for each source included in the SOURCES parameter.  This walk through will use the [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPLAT SPLAT] task to create a new multi-source file with the calibration applied in order to mimic the CASA tutorial as closely as possible.
 
{| class="wikitable"
|-
|-
| APCAL
! [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] Procedure !! AIPS Task(s) !! CASA Task(s)
| gencal
|-
|-
| CLCAL
| ''none'' || [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPLAT SPLAT]<br/>inname 'TL016B'<br/>inclass 'UVDATA'<br/>inseq 1<br/>sources 'J1154+6022','J1203+6031'<br/>bchan 8<br/>echan 122<br/>docal 1<br/>gainuse 0<br/>doband 1<br/>bpver 1<br/>outname 'tl016b'<br/>outclass 'splat1' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.manipulation.split.html split]<br/>vis='tl016b.ms'<br/>outputvis='tl016b_cal1.ms'<br/>field='J1154+6022,J1203+6031'<br/>spw='*:7~121'<br/>antenna='*&*'<br/>datacolumn='corrected'
| applycal
|}
|}
<b>NOTE:</b> When moving forward with self-calibration on the SPLAT1 file, it will be necessary to set doband -1 and bpver -1 in all of the self-calibration steps below (the splat1 file will have the bandpass calibration applied and will not contain a BP table).


=== Parallactic Angle Correction ===
 
== Self-Calibration Steps ==
This sections covers the steps needed to perform phase and amplitude self-calibration of the dataset.
 
<b>NOTE: </b>The [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?VLBAUTIL VLBAUTIL] procedures do not include self-calibration options, so the following subsections will only include AIPS tasks and the equivalent CASA tasks.
 
''ASIDE:''  Some seasoned VLBA users will do the imaging steps in Difmap (see the [https://sites.astro.caltech.edu/~tjp/citvlb/ Caltech VLBI Programs page]) rather than in AIPS.  If you want to try this, use [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPLIT SPLIT] to create a UVFITS file with only one source in it, then use [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FITTP FITTP] to write the single-source UVFITS file to disk, make the image in Difamp, save the image, then read it back into AIPS with [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMLOD IMLOD].
 
 
=== Imaging the Phase Reference Calibrator ===
The first step in self-calibration is to build a model of the phase reference calibrator with an imaging tool.
 
{| class="wikitable"
|-
! AIPS Task(s) !! CASA Task(s)
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMAGR IMAGR]<br/>inname 'TL016B'<br/>inclass 'SPLAT1'<br/>inseq 1<br/>sources 'J1154+6022'<br/>docal 1<br/>gainuse 0<br/>stokes 'i'<br/>nchav 115<br/>outname 'J1154+6022'<br/>cellsize 0.0002<br/>imsize 512<br/>robust 5<br/>niter 1000<br/>dotv 1 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.imaging.tclean.html tclean]<br/>vis='tl016b_cal1.ms'<br/>field='J1154+6022'<br/>imagename='J1154_sc1'<br/>imsize=[640], cell=['0.2mas']<br/>stokes='I'<br/>deconvolver='clark'<br/>weighting='natural'<br/>niter=1000<br/>interactive=True<br/>savemodel='modelcolumn'
|}
<b>NOTE:</b> In [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMAGR IMAGR], we set the NCHAV parameter to 115 to average all of the spectral channels together for a Stokes I image.  This makes the cleaning process go much faster for continuum observations.  If NCHAV is set to 1, [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMAGR IMAGR] will clean one spectral channel at a time.
 
=== Phase Self-Calibration ===
 
Now that we have a model of the calibrator, we will make corrections to the phases based on that model.
 
{| class="wikitable"
|-
! AIPS Task(s) !! CASA Task(s)
|-
| rowspan="2" | [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CALIB CALIB]<br/>inname 'TL016B'<br/>inclass 'SPLAT1'<br/>inseq 1<br/>calsour 'J1154+6022'<br/>docal 1<br/>gainuse 0<br/>doband -1<br/>bpver -1<br/>in2name 'J1154+6022'<br/>in2class 'icl001'<br/>in2seq 1<br/>refant 2<br/>solmode 'p'<br/>solint 20/60<br/>cmethod 'dft'<br>aparm 3 0
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.gaincal.html gaincal]<br/>vis='tl016b_cal1.ms'<br/>field='J1154+6022'<br/>caltable='tl016b_cal1.dcal'<br/>solint='inf'<br/>refant='FD'<br/>minblperant=3<br/>gaintype='K'<br/>calmode='p'<br/>parang=False
|-
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.gaincal.html gaincal]<br/>vis='tl016b_cal1.ms'Mbr/>field='J1154+6022'<br/>caltable='tl016b_cal1.pcal'<br/>solint='20s'<br/>refant='FD'<br/>minblperant=3<br/>gaintype='G'<br/>calmode='p'<br/>parang=False
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL]<br/>inname 'TL016B'<br/>inclass 'SPLAT1'<br/>inseq 1<br/>calsour 'J1154+6022'<br/>opcode 'calp'<br/>interp '2pt'<br/>snver 0<br/>doblank -1<br/>gainver 0<br/>gainuse 0
| [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.applycal.html applycal]<br/>vis='tl016b_cal1.ms'<br/>field='J1154+6022'<br/>gaintable=['tl016b_cal1.dcal','tl016b_cal1.pcal']<br/>interp=['linear','linear']<br/>parang=False
|}
 
<b>NOTE: </b>In CASA, we first perform a delay self-calibration using solint='inf' and gaintype='K'.  Then, we perform the phase self-calibration using solint='20s' and gaintype='G'.
 
 
=== New Image of Calibrator ===
 
Once the phase calibration has been improved, it is time to make a new (hopefully nicer) image.
 
{| class="wikitable"
|-
! AIPS Task(s) !! CASA Task(s)
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMAGR IMAGR]<br/>inname 'J1154+6022'<br/>inclass 'SPLAT1'<br/>inseq 1<br/>sources 'J1154+6022'<br/>docal 1<br/>gainuse 0<br/>doband -1<br/>bpver -1<br/>stokes 'i'<br/>nchav 115<br/>outname 'J1154+6022'<br/>cellsize 0.0002<br/>imsize 512<br/>robust 5<br/>niter 1000<br/>dotv 1 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.imaging.tclean.html tclean]<br/>vis='tl016b_cal1.ms'<br/>field='J1154+6022'<br/>imagename='J1154_sc2'<br/>imsize=[640]<br/>cell=['0.2mas']<br/>stokes='I'<br/>deconvolver='clark'<br/>weighting='natural'<br/>niter=1000<br/>interactive=True<br/>savemodel='modelcolumn'
|}
 
 
=== Amplitude Self-Calibration ===
 
Now, we will use our improved model (the image made with the improved phase calibration) to make corrections to the amplitudes and phases.
 
<b>IMPORTANT!</b>  Be very careful when doing amplitude self-calibration!  It is possible to "build in" false structures to your data if the model is not a good represenation of the calibrator.
 
{| class="wikitable"
|-
! AIPS Task(s) !! CASA Task(s)
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CALIB CALIB]<br/>inname 'TL016B'<br/>inclass 'SPLAT1'<br/>inseq 1<br/>calsour 'J1154+6022'<br/>docal 1<br/>gainuse 0<br/>doband -1<br/>bpver -1<br/>in2name 'J1154+6022'<br/>in2class 'icl001'<br/>in2seq 2<br/>refant 2<br/>solmode 'a&p'<br/>solint 0<br/>cmethod 'dft'<br/>aparm 4 0 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.gaincal.html gaincal]<br/>vis='tl016b_cal1.ms'<br/>field='J1154+6022'<br/>caltable='tl016b_cal1.apcal'<br/>solint='inf'<br/>refant='FD'<br/>minblperant=4<br/>gaintype='G'<br/>calmode='ap'<br/>solnorm=True<br/>gaintable=['tl016b_cal1.dcal','tl016b_cal1.pcal']<br/>interp=['linear','linear']<br/>parang=False
|-
|[http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL]<br/>inname 'TL016B'<br/>inclass 'SPLAT1'<br/>inseq 1<br/>opcode 'calp'<br/>interp '2pt'<br/>snver 0<br/>doblank -1<br/>gainver 0<br/>gainuse 0 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.applycal.html applycal]<br/>vis='tl016b_cal1.ms'<br/>field='J1154+6022'<br/>gaintable=['tl016b_cal1.dcal','tl016b_cal1.pcal','tl016b_cal1.apcal']<br/>interp=['linear','linear','linear']<br/>parang=False
|}
 
 
=== Apply the Self-calibration to the Science Target ===
 
In the CASA tutorial, the calibration has only been applied to the phase reference calibrator up to this point.  So, before imaging the science target, we need to apply the self-calibration corrections to it.
 
This step is not necessary for the AIPS calibration because we have been applying the corrections to every source with [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL].
 
{| class="wikitable"
|-
! AIPS Task(s) !! CASA Task(s)
|-
| ''not necessary'' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.applycal.html applycal]<br/>vis='tl016b_cal1.ms'<br/>field='J1203+6031'<br/>gaintable=['tl016b_cal1.dcal','tl016b_cal1.pcal','tl016b_cal1.apcal']<br/>interp=['linear','linear','linear']<br/>applymode='calonly'<br/>parang=False
|}
 
<b>NOTE: </b>We have set applymode='calonly' in this step to avoid flagging any time when calibration corrections are unavailable.  You should carefully inspect the data to make certain you do not need to do any more flagging.
 
 
=== Split Out Science Target ===
Apply the calibration to the science target (J1203+6031) and make a single-source file.
 
{| class="wikitable"
|-
! AIPS Task(s) !! CASA Task(s)
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPLIT SPLIT]<br/>inname 'TL016B'<br/>inclass 'SPLAT1'<br/>inseq 1<br/>sources 'J1203+6031'<br/>bchan 1<br/>echan 0<br/>docal 1<br/>gainuse 0<br/>doband -1<br/>bpver -1<br/>outclass 'split1' || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.manipulation.split.html split]<br/>vis='tl016b_cal1.ms'<br/>outputvis='tl016b_cal2.ms'<br/>field='J1203+6031'<br/>datacolumn='corrected'
|}
 
 
== Imaging the Science Target ==
 
Just like when we imaged the phase reference calibrator, we will use [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMAGR IMAGR] and [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.imaging.tclean.html tclean] again to make images of the science target J1203+3061.
 
<b>NOTE: </b>If you expect to do any self-calibration on the science target in CASA, you should make sure to set savemodel='modelcolumn' in [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.imaging.tclean.html tclean].


{| class="wikitable"
{| class="wikitable"
|-
|-
! VLBAUTIL Procedure !! AIPS Task(s) !! CASA Task(s)
! AIPS Task(s) !! CASA Task(s)
|-
|-
| VLBAPANG || CLCOR<br/>opcode 'pang' || set parang=True in applycal, fringefit, and bandpass
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMAGR IMAGR]<br/>inname 'J1203+6031'<br/>inclass 'SPLIT1'<br/>inseq 1<br/>sources 'J1203+6031'<br/>docal -1<br/>stokes 'i'<br/>nchav 115<br/>cellsize 0.0002<br/>imsize 512<br/>robust 5<br/>niter 1000<br/>dotv 1 || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.imaging.tclean.html tclean]<br/>vis='tl016b_cal2.ms'<br/>field='J1203+6031'<br/>imagename='J1203_im1'<br/>imsize=[640], cell=['0.2mas']<br/>stokes='I'<br/>deconvolver='clark'<br/>weighting='natural'<br/>niter=1000<br/>interactive=True<br/>savemodel='modelcolumn'
|}
|}
<b>NOTE:</b> In [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMAGR IMAGR], if docal is set to 1, you may see an error saying something like "REQUESTED SN FILE 0 DOES NOT EXIST".


== Additional Tasks ==
To view the resulting image in AIPS, use the TVLOD or TVAL to put the image in the AIPS TV window.  First, type "mc" to list all of the images in the image catalog.  Find the J1203+6031.ICL001.1 file, and type "getn #" where # is the catalog number for the file.  Type "tvini" to clear the AIPS TV window.  Then type "tvlod" or "tval" to put the image in the window.  TVAL is a little more flexible and allows you change from grayscale to color (click in the window, and hit "A" twice", and adjust the color scale (click in the window, hit "A" and and click & drag the mouse); when you are done making changes, hit "D" and AIPS will exit TVAL but leave the image in the TV window.
 
J1203+6031 is bright enough to do phase self-calibration.  Users are welcome to attempt this by following the same steps outlined in the "Phase Self-Calibration" section above, but changing the source name and the solution interval.
 
 
== Exiting the Programs ==
Once the data are calibrated and images are made, users will want to cleanly exit the programs.
 
To exit CASA, simply type "quit" in the command line.  This will exit CASA and close the message log.
 
To exit AIPS, type "kleenex" in the command line.  This will exit AIPS, close the message log, and close any AIPS TV windows that are open.
 
 
== AIPS and CASA Tasks ==
 
Here are some of the AIPS tasks commonly used in VLBI calibration, and their equivalent CASA tasks (when one exists).


{| class="wikitable"
{| class="wikitable"
Line 159: Line 623:
! AIPS Task !! CASA Task
! AIPS Task !! CASA Task
|-
|-
| SPLIT || split
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?ACCOR ACCOR] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.accor.html accor]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?ACSCL ACSCL] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.accor.html accor] with special inputs
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?ANTAB ANTAB] || ''none''
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?APCAL APCAL] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.gencal.html gencal]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?BPASS BPASS] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.bandpass.html bandpass]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CALIB CALIB] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.gaincal.html gaincal]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCAL CLCAL] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.applycal.html applycal]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?CLCOR CLCOR] || ''none''
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?DELZN DELZN] || ''none''
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?DTSUM DTSUM] || ''none''
|-
|-
| IMAGR || tclean
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FITLD FITLD] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.data.importfitsidi.html importfitsidi]
|-
|-
| CALIB || gaincal
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FITTP FITTP] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.data.exportfits.html exportfits] or [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.data.exportuvfits.html exportuvfits]
|-
|-
| POSSM || plotms
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FRING FRING] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.fringefit.html fringefit]
|-
|-
| SNPLT || plotms
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?FTFLG FTFLG] || ''none''
|-
|-
| UVPLT || plotms
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMAGR IMAGR] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.imaging.tclean.html tclean]
|-
|-
| UVFLG || flagadata
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?IMLOD IMLOD] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.data.importfits.html importfits]
|-
|-
| FITTP || exportuvfits or exportfits
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?LISTR LISTR] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.information.listobs.html listobs]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?LPCAL LPCAL] || ''none''
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?POSSM POSSM] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casaplotms.plotms.html plotms]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?QUACK QUACK] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>mode='quack'
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?RFLAG RFLAG] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]<br/>mode='rflag'
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?RLDLY RLDLY] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.gaincal.html gaincal]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNCOR SNCOR] || ''none''
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNEDT SNEDT] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casaplotms.plotms.html plotms]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNPLT SNPLT] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casaplotms.plotms.html plotms]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SNSMO SNSMO] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.calibration.smoothcal.html smoothcal]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPFLG SPFLG] || ''none''
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPLAT SPLAT] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.manipulation.split.html split]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?SPLIT SPLIT] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.manipulation.split.html split]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TECOR TECOR] || ''none''
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?TVFLG TVFLG] || ''none''
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG UVFLG] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casatasks.flagging.flagdata.html flagdata]
|-
| [http://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVPLT UVPLT] || [https://casadocs.readthedocs.io/en/v6.4.0/api/tt/casaplotms.plotms.html plotms]
|}
|}
In some cases where there is no equivalent CASA task, there may be an equivalent CASA tool (code that works in CASA but is not maintained by the CASA Development Team).  For example, the CASA tool polsolve (e.g., [https://ui.adsabs.harvard.edu/abs/2021A%26A...646A..52M/abstract Marti-Vidal et al. 2021]) is designed to function similar to the AIPS task LPCAL.

Latest revision as of 23:14, 1 June 2023

This Guide walks through the calibration of the data set used in the VLBA Basic Phase-referencing Calibration and Imaging tutorial. It presents the steps that should be taken to calibrate the data using both AIPS and CASA. In several cases the AIPS VLBAUTIL procedures are shown, as well as the AIPS tasks that those procedures call. To use the VLBAUTIL procedures, first enter "run vlbautil" in AIPS to initialize all of the procedures.

Because this is more of a walk-through and side-by-side comparison of AIPS and CASA, example images of what uses might see while using the various interactive tools (e.g., IMAGR, tclean, etc.) are not provided.

Note that some steps are performed in a different order depending on whether you are using AIPS or CASA. Also, be aware that not all tasks in AIPS have an equivalent task in CASA (yet).

To follow along with this Guide, users should download the TL016B.idifits data set used in the VLBA Basic Phase-referencing Calibration and Imaging CASA Guide tutorial.

For a more detailed tutorial on AIPS continuum calibration, including self-calibration, see the AIPS Simple Self-calibration Tutorial.

Starting the Programs

Starting CASA is very simple. Once CASA is installed, simply type "casa" in the command line of a terminal.

Starting AIPS is also easy, but requires a few more steps than CASA. Once AIPS is installed, type "aips tv=local" in the command line of a terminal. The "tv=local" forces AIPS to use a tv window on the local machine rather than on a network. Sometimes, it may be necessary to type "aips tv=local:0.0". Once AIPS starts, users may be asked to select a printer (this depends on the installation). Finally, users will be instructed to enter a user ID number. Users can pick any number EXCEPT FOR 1. Typically, users will pick a four digit number, such as 1000. It is usually best to pick a new AIPS user ID number for each project, in order to keep data separate. Users should make a note of the user ID number they choose at the start of each AIPS session.


Running Tasks

In CASA, users can enter commands using the "inp-go" method or as a function call. In the "inp-go" method, users will typically set all task parameters to their default values by typing "default(<task>)"; for example, "default(importfitsidi)". Next, users would check the parameters associated with that task by typing "inp". Then, users would enter the parameter values in the command line one at a time (or in sets separated by a semi-colon). Once all necessary parameters have been entered, users can run the task by typing the task name or "go(<taskname>)". When running a CASA task with a function call, users enter all of the non-default parameters in parentheses following the taskname and the task runs immediately; for example, importfitsidi(fitsidifile='TL016B.idifits', vis='tl018b.ms', constobsiid=True, scanreindexgap_s=15).

In AIPS, all tasks should be run using the "inp-go" method. Set the default task parameters by typing "default <taskname>"; for example, "default fitld". Then, type "inp" to see all the parameters associated with that task. Enter the values for the parameters one at a time (or in sets separated by semi-colons) in the command line. Check that all parameters are properly set by typing "inp" again and inspecting each parameter. Finally, run the task by typing "go" or "go <taskname>"; for example, "go fitld".

Running the VLBAUTIL procedures in AIPS is very similar to running a task. Users should set the default parameter values by typing "default <procedure>"; for example, "default vlbaload". Next, enter the parameter values. The main difference between a task and a procedure in AIPS is that users should not type "go" to run a procedure. Instead, just type the procedure name. For example, once all of the parameters have been entered for VLBALOAD, simply type "vlbaload" and the procedure will run.

The calibration steps shown below all use the "inp-go" style for both AIPS and CASA.


Some Notes on AIPS

For those used to CASA, the way AIPS works will be a bit different. Here are a few things that might be useful to know.

AIPS Tables

Both AIPS and CASA create calibration tables containing solutions derived by various tasks. CASA stores these tables as extrenal files, and can use them on the fly or to create the CORRECTED_DATA column in the Measurement Set. AIPS uses a set of pre-defined tables to hold the solutions and corrections stored internally to the program and applies all corrections on the fly (i.e., it never creates a new "corrected data" column). AIPS users can see the tables associated with a data set at any time by typing "imh" (or "imhead").

Here are some of the table types and what they contain:

  • GC = gain curve tables; contain the DPFU values and the gain curve corrections for amplitude calibration, usually from the FITS-IDI file but can also be read in from an antab file
  • TY = system temperature tables; contain the system temperature values, usually from the FITS-IDI file but can also be read in from an antab file
  • SN = solution tables; contain solutions derived by operations like fringe-fitting bandpass calibration, and self-calibration
  • CL = calibration tables; contain the corrections that will be applied to the data, usually with values interpolated from an SN table via the task CLCAL
  • BP = bandpass tables; contain the corrections for the shape of the bandpass created by the task BPASS
  • FG = flag tables; contain all of the flags, both from the FITS-IDI file (i.e., the online flags) and those created by users

It is a good idea to keep track of which table was create by which task, in case there are problems with the calibration and something needs to be rolled back.

Some Useful AIPS Commands

  • uc: short for "ucat", lists all of the uv data sets in the current user ID
  • mc: short for "mcat", lists all of the images in the current user ID
  • getn #: get the data set associated with the catalog number #; this will populate the INNAME, INCLASS, and INSEQ parameters for a task
  • get2n #: get the data set associated with the catalog number #; this will populate the IN2NAME, IN2CLASS, and IN2SEQ parameters for a task
  • imh: short for "imhead", show the header for a selected catalog entry (uv data set or image), including all tables
  • tget <task>: get all of the parameters that were used when running the task the last time (CASA has a similar feature)
  • tvini: initialize the AIPS TV window (clear the window so something new can be displayed)
  • restore 0: clear all inputs and return all tasks to default state; helpful when things go very wrong
  • zap: destroy the current catalog entry (uv data set or image) and all tables associated with it - USE WITH EXTREME CAUTION
    • Example: Destroy the data in catalog entry #4 - getn 4; zap
  • extdest: destroy the current table - USE WITH EXTREME CAUTION
    • Example: Destroy SN table #3 on the first uv data set - getn 1; inext 'sn'; inver 3; extdest

IF vs SPW

CASA labels the data channels as "spw" for "spectral window". The first spectral window is spw 0.

AIPS labels the data channels as "IF" for "intermediate frequency". The first intermediate frequency is IF 1.

When converting between CASA and AIPS, it is important to remember that spw 0 = IF 1.


Initial Calibration

This section shows the steps for the initial calibration (instrumental delay, fringe fitting, bandpass correction).

Loading Data

Both AIPS and CASA need to take the FITS-IDI file and convert it into a format they can use. AIPS uses the UVDATA format, and CASA uses the Measurement Set (MS) format.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
VLBALOAD
datain 'PWD:TL016B.idifits
outname 'TL016B'
clint 0.25
FITLD
datain 'PWD:TL016B.idifits
outname 'TL016B'
clint 0.25
importfitsidi
fitsidifile='TL016B.idifits'
vis='tl018b.ms'
constobsiid=True
scanreindexgap_s=15

Note that the lack of a trailing single tick (') in the datain parameter is not a typo. Any parameter defined inside single ticks will be converted to all capital letters (e.g., datain 'PWD:TL016B.idifits' will set the DATAIN parameter to "PWD:TL016B.IDIFITS"). Omitting the trailing single tick will force AIPS to set the parameter exactly as typed.

Setting the DATAIN parameter to 'PWD:<datafile> will tell AIPS to look in the present working directory. If the data are not located in the present working directory, users can define a directory using the export command in the terminal (e.g., export MYAIP=/home/user/mydata/; datain 'MYAIP:TL016B.idifits). Users working in a C shell will need to use the setenv command instead of export. Defining the directory must be done prior to starting AIPS.

Observation Summary

Printing a summary of the observations is often useful for identifying the fringe finder, bandpass calibrator, phase reference calibrator, and science target. It is also useful for locating a good time range to use for the instrumental delay correction.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
VLBASUMM
inname 'TL016B'
inclass 'UVDATA'
inseq 1
docrt 132
PRTAN
inname 'TL016B'
inclass 'UVDATA'
inseq 1
docrt 132
dotv 1
listobs
vis='tl016b.ms'
LISTR
inname 'TL016B'
inclass 'UVDATA'
inseq 1
optype 'scan'

NOTE: In CASA, to have listobs save the observation summary to a file called 'tl018b_listobs.txt', set listfile='tl016b_listobs.txt'.


Inspecting the Data and Choosing a Reference Antenna

Before getting into the actual calibration steps, it is a good idea to inspect the data and choose a good reference antenna. Start by inspecting a scan on the bandpass calibrator that is near the middle of the data set. For tutorial data set, the third scan on 4C39.25 (scan 91) is a good place to start.

In CASA, this is done with plotms.

In AIPS, this is done with POSSM. POSSM will display the phases and amplitudes for each baseline in a single plot. By setting the nplots parameter to 9, POSSM will display nine baselines at a time.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none POSSM
inname 'TL016B'
inclass 'UVDATA'
inseq 1
sources '4C39.25'
stokes 'half'
timerang 0 9 16 23 0 9 19 53
aparm(9) 1
nplots 9
dotv 1
plotms
vis='tl016b.ms'
xaxis='frequency'
yaxis='phase'
field='4C39.25'
scan='91'
correlation='ll'
antenna='FD,LA,PT'
iteraxis='baseline'
coloraxis='spw'

NOTE: If you invoke VLBAUTIL in AIPS, you can auto-populate the TIMERANG parameter by setting "timerang=scantime(91)".

In POSSM, to display the next group of baselines, click in the AIPS TV window and then press "B".

When using plotms to inspect the data, remember to change the correlation to 'rr' and change the yaxis to 'amp' in order to look at all the relevant data.


Quacking the Data

"Quacking" refers to flagging the beginning and/or end of each scan in a data set. This is a completely optional step, but it is often useful for VLBA data.

Flag the first 4 seconds of each scan.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none QUACK
inname 'TL016B'
inclass 'UVDATA'
inseq 1
opcode 'BEG'
reason 'QUACK'
aparm 0 4/60 0
flagdata
vis='tl018b.ms'
mode='quack'
quackmode='beg'
quackinterval=4.0
quackincrement=True

Flag the last 4 seconds of each scan.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none QUACK
inname 'TL016B'
inclass 'UVDATA'
inseq 1
opcode 'ENDB'
reason 'QUACK'
aparm 0 4/60 0
flagdata
vis='tl018b.ms'
mode='quack'
quackmode='endb'
quackinterval=4.0
quackincrement=True

NOTE: Setting the REASON parameter in QUACK (and later in UVFLG) can be useful if flags need to be undone.


Automated Flagging

The VLBA Basic Phase-referencing Calibration and Imaging tutorial shows users how to run the TFCrop automated flagging routine on the data to remove some time-based RFI. AIPS does not have an equivalent task to TFCrop, but users can opt to use the RFLAG automated flagging after the bandpass corrections have been applied (later in the calibration).

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none none flagdata
vis='tl016b.ms'
mode='tfcrop'
datacolumn='data'
timecutoff=4.0
flagdimension='time'
action='calculate'
display='both'

With action='calculate', no flags will be generated. Instead, you should just verify that the TFCrop flagging is doing what you expect. You can always click 'Quit' and adjust the timecutoff parameter as you see fit.

Once you are satisfied that the program is going to flag things appropriately, set action='apply' and run it again.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none none flagdata
vis='tl016b.ms'
mode='tfcrop'
datacolumn='data'
timecutoff=4.0
flagdimension='time'
action='apply'
display='both'

Double check that the flags look appropriate, then click "Stop Display" to have the TFCrop routine set and apply the flags.

For some observations, especially at frequencies below 4 GHz, it will be useful to have TFCrop look for RFI in both frequency and time. In this case, set fladimension='freqtime' (the default), and freqcutoff=3.0. Check that the flags look appropriate and adjust the freqcutoff parameter as necessary before applying the flags.

Interactive Flagging

AIPS has multiple tasks that allow users to display the data and flag them in the AIPS TV window. For VLBI arrays, where the number of stations is relatively small, these are very powerful tools for finding and flagging bad data.

FTFLG

FTFLG combines the data from all the baselines and displays them in a waterfall plot with spectral channels on the horizontal axis, and time going up on the vertical axis (i.e., the bottom-most data are the first data taken in the observation). Hopefully, you will not see anything obviously bad in FTFLG plots of VLBA data (RFI is usually confined to a single antenna, so averaging all the stations together tends to wash it out). However, it is a very good tool to find any satellite transmissions that might be in your data.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none FTFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
none

Be sure to switch between the polarizations using the GUI controls (select "Display LL", hit "A", select "Load", hit "A"). You can change what data is displayed using the DPARM parameter (DPARM(1) 0 = display amplitude, DPRAM(1) 1 = display phase, etc.).

SPFLG

Like FTFLG, SPFLG displays a waterfall plot with spectral channels on the horizontal axis and time going up on the vertical axis. Unlike FTFLG, SPFLG does not combine the data. Instead, it displays a single baseline at a time. You can move through all the baselines using the GUI controls.

SPFLG is an excellent tool for finding narrow-band (and sometimes wide-band) RFI on each baseline.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none SPFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
none

You can switch between polarizations just as in FTFLG, and the DPARM parameters are also similar.

NOTE: It is generally a good idea to set the STOKES flag to "1111" - select "ENTER STOKES FLAG", press "A", in the terminal type "1111" and hit enter. This means whenever a flag is created, it will flag across all polarizations (RR, LL, RL, & LR).

TVFLG

TVFLG displays a waterfall plot with baseline on the horizontal axis and time going up on the vertical axis. It is often helpful to average the spectral channels together when running TVFLG, especially if you have already inspected/flagged the data with SPFLG. TVFLG is an excellent tool for finding and flagging time-variable problems in the data. It can also reveal if one station was having problems.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none TVFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
nchav 128
none

For the tutorial data set, setting NCHAV 128 will average all of the spectral channels together.

Use the GUI tools to step through the IFs (remember, the AIPS term for "spectral window" is "intermediate frequency" or "IF"). Once you have gone through all IFs in one polarization, TVFLG will start showing the other polarization.

NOTE: Just as for SPFLG, it is generally a good idea to set the STOKES flag to "1111" - select "ENTER STOKES FLAG", press "A", in the terminal type "1111" and hit enter. This means whenever a flag is created, it will flag across all polarizations (RR, LL, RL, & LR).

You can inspect the data with any of these interactive flagging tools at any time throughout the calibration. Just remember to set the calibration parameters properly. Setting DOCAL 1 will apply the CL table that is specified with GAINUSE (GAINUSE 0 means use the highest number CL table). Once you have done the bandpass calibration, remember to set DOBAND 1 and BPVER 1 (or to the desired bandpass table, if there is more than one).

Manual Flagging

The VLBA Basic Phase-referencing Calibration and Imaging tutorial includes a significant amount of additional flagging. AIPS users should start their flagging by using the graphical tools FTFLG, SPFLG, and TVFLG. CASA does not have equivalent graphical flagging tools. CASA users can try using the viewer to display the data in a manner similar to SPFLG and TVFLG, as described in Section 2.1.2 of VLBA Scientific Memo #38. However, the CASA viewer is not very reliable, especially for creating flags.

Fortunately, both AIPS and CASA have tasks for creating flags without a graphical interface. Here are examples of flagging some of the data:

Flag all baselines to HN on final scan of 4C39.5

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none UVFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
timerang 0 12 13 23 0 12 16 53
antennas 3 0
opcode 'FLAG'
reason 'HNLOW'
flagdata
vis='tl018b.ms'
mode='manual'
field='4C39.25'
antenna='HN'
scan='181'

NOTE: Entering a short note in the reason parameter in UVLFG can be useful if the flags need to be undone at some point.

Flag the BR-PT baseline on scan 10

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none UVFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
timerang 0 6 30 57 0 6 31 37
antennas 1 0
baseline 9 0
opcode 'FLAG'
reason 'BRPT10HOT'
flagdata
vis='tl018b.ms'
mode='manual'
field='J1154+6022'
antenna='BR&PT'
scan='10'

To see all the flags that are recommended for this data set, refer to the VLBA Basic Phase-referencing Calibration and Imaging tutorial. It may be easier to flag the data by running SPFLG again, but set SOURCE 'J1154+6022' to only see the phase reference calibrator. Then try again just looking at the science target J1203+6031.


Total Electron Content Correction

To make the TEC correction using TECOR, you will first need to download the appropriate TEC file from ftp://gdc.cddis.eosdis.nasa.gov/gps/products/ionex/. The VLBATECR procedure will download the necessary file automatically.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
VLBATECR
inname 'TL016B'
inclass 'UVDATA'
inseq 1
TECOR
inname 'TL016B'
inclass 'UVDATA'
inseq 1
aparm 1 0
infile ' tec file '
no equivalent CASA task yet

NOTE: Do not use the tec_maps CASA tool with VLBA data. It does not work properly for VLBI observations.


Earth Orientation Parameter Correction

To make the EOP correction using CLCOR, you will first need to download the appropriate file from ftp://cddis.gsfc.nasa.gov/vlbi/gsfc/ancillary/solve_apriori/usno_finals.erp. The VLBAEOPS procedure will download the necessary file automatically.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
VLBAEOPS
inname 'TL016B'
inclass 'UVDATA'
inseq 1
CLCOR
inname 'TL016B'
inclass 'UVDATA'
inseq 1
opcode 'eops'
infile ' eop file '
no equivalent CASA task yet


Sampler Corrections

For VLBA data, it is necessary to make corrections based on the autocorrelations. This step is not required when calibrating EVN data because it is performed during correlation.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
VLBACCOR
inname 'TL016B'
inclass 'UVDATA'
inseq 1
ACCOR
inname 'TL016B'
inclass 'UVDATA'
inseq 1
solint -0.5
accor
vis='tl016b.ms'
caltable='tl016b.accor'
solint='30s'
SNSMO
inname 'TL016B'
inclass 'UVDATA'
inseq 1
inver 0
samptype 'mwf'
smotype 'ampl'
cparm 0.5 0 0 0 0 1
outvers 0
smoothcal
vis='tl016b.ms'
tablein='tl016b.accor'
caltable='tl016b_smooth.accor'
smoothtype='median'
smoothtime=1800.0
CLCAL
inname 'TL016B'
inclass 'UVDATA'
inseq 1
opcode 'cali'
interp 'self'
snver 0
dobalnk -1
gainver 0
gainuse 0
applycal
vis='tl016b.ms'
gaintable=['tl016b_smooth.accor']
interp=['nearest']
parang=True

NOTE: There may be times when it is necessary to edit an SN table in AIPS. You can do this interactively with SNEDT.


A Priori Calibration

When calibrating VLBA data in CASA, it is usual to generate the a priori calibration tables at this point: gain curve and system temperature. This step is unnecessary in AIPS because the gain curve (GC) and system temperature (TY) tables are created automatically with FITLD or VLBALOAD.

Gain Curve

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none, done in VLBALOAD none, done in FITLD gencal
vis='tl018b.ms'
caltable='tl016b.gcal'
caltype='gc'

System Temperature

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none, done in VLBALOAD none, done in FITLD gencal
vis='tl018b.ms'
caltable='tl016b.tsys'
caltype='tsys'
uniform=False


Inspect the System Temperature Values

It is always a good idea to plot the system temperature values and look for obvious outliers.

In AIPS, it will be necessary to type "tvini" to initialize the AIPS TV window prior to running SNPLT. If the AIPS TV window is not initialized (cleared), SNPLT will plot its data over the previous image and it can look very messy.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none SNPLT
inname 'TL016B'
inclass 'UVDATA'
inseq 1
inext 'ty'
inver 1
nplots 4
optype 'tsys'
dotv 1
plotms
vis='tl018b.tsys'
xaxis='time'
yaxis='tsys'
iteraxis='antenna'
coloraxis='spw'

NOTE: In SNPLT, if DOTV is set to -1, it will not display the plots in the AIPS TV window. Instead, it will create the plots as PL tables attached to the uvdata file. PL tables can be displayed in the AIPS TV window using the TVPL task.


Flag the Data with Bad Tsys

Flag the final scan of 4C39.5

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none UVFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
timerang 0 12 13 23 0 12 16 53
opcode 'FLAG'
reason '4C39LOWE'
flagdata
vis='tl018b.ms'
mode='manual'
field='4C39.25'
scan='181'

Flag the last two data channels on BR

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none UVFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
antennas 1
bif 3
eif 4
opcode 'FLAG'
reason 'BRIF34HOT'
flagdata
vis='tl018b.ms'
mode='manual'
antenna='BR'
spw='2,3'

NOTE: Recall that spw 0 = IF 1, spw 1 = IF 2, spw 2 = IF 3, and spw 3 = IF 4.

Flag the last data channel on KP

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none UVFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
antennas 4
bif 4
eif 4
opcode 'FLAG'
reason 'KPIF4HOT'
flagdata
vis='tl018b.ms'
mode='manual'
antenna='KP'
spw='3'

Flag the third data channel on LA

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none UVFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
antennas 5
bif 3
eif 3
opcode 'FLAG'
reason 'LAIF3HOT'
flagdata
vis='tl018b.ms'
mode='manual'
antenna='LA'
spw='2'

Flag the last data channel on NL

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none UVFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
antennas 7
bif 4
eif 4
opcode 'FLAG'
reason 'NLIF4HOT'
flagdata
vis='tl018b.ms'
mode='manual'
antenna='NL'
spw='3'

Flag the last data channel on SC for the end of the obsevration

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none UVFLG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
antennas 10
bif 4
eif 4
timerang 0 10 46 48 0 13 27 09
opcode 'FLAG'
reason 'SC4BADEND'
flagdata
vis='tl018b.ms'
mode='manual'
antenna='SC'
spw='3'
scan='135~223'


Parallactic Angle Correction

It often will not make a big difference when you apply the parallactic angle correction. However, there are some cases when it is important to do the parallactic angle correction before moving on to the next calibration step. In particular, if a data set requires phase referencing, the parallactic angle correction should be made prior to any fringe fitting (also, when you plan to combine polarizations for fringe fitting). So, we will make that correction early in the calibration for our data set.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
VLBAPANG
inname 'TL016B'
inclass 'UVDATA'
inseq 1
CLCOR
inname 'TL016B'
inclass 'UVDATA'
inseq 1
gainver 0
gainuse 0
opcode 'pang'
clcorprm 1 0
done by setting parang=True in future fringefit, bandpass, and applycal steps


Instrumental Delay Correction

NOTE: Many VLBA users are likely familiar with the VLBAUTIL procedure VLBAPCOR and the associated AIPS task PCCOR, which use the pulse-cal tone information from the VLBA to correct for the instrumental delay. CASA does not currently have a means of working with the pulse-cal tones, so it cannot use this functionality. In order to do a direct comparison between AIPS and CASA, we will use the VLBAMPCL procedure, which runs FRING and CLCAL. Using the pulse-cal tones in CASA is an area of active development for the NRAO and JIVE CASA software engineers and scientists. In practice, fringe fitting a bright source on each IF/spw separately has been shown to be a satisfactory substitute for pulse-cal tones in EVN usage; for a very long experiment it may be necessary to have multiple such single-band delay calibrations.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
VLBAMPCL
inname 'TL016B'
inclass 'UVDATA'
inseq 1
timerang 0 9 17 0 0 9 18 0
calsour '4C39.25'
refant 2
FRING
inname 'TL016B'
inclass 'UVDATA'
inseq 1
docal 1
gainuse 0
timerang 0 9 17 0 0 9 18 0
solint 0
calsour '4C39.25'
refant 2
aparm(1) 2
dparm(1) 1
dparm(8) 1
snver 0
fringefit
vis='tl016b.ms'
caltable='tl016b.sbd'
field='4C39.25'
timerange='09:17:00~09:18:00'
solint='inf'
zerorates=True
refant='FD'
minsnr=10
gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys']
interp=['nearest', 'nearest', 'nearest,nearest']
parang=True
CLCAL
inname 'TL016B'
inclass 'UVDATA'
inseq 1
timer 0
interp '2pt'
snver 0
refant 2
calsour '4C39.25'
opcode 'CALP'
gainver 0
gainuse 0
applycal
vis='tl016b.ms'
gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd']
interp=['nearest', 'nearest', 'nearest,nearest', 'nearest']
parang=True

NOTE: For very long observations, it is a good idea to make the delay-rate solutions zero before extrapolating them to the rest of data. To do so in AIPS, use the SNCOR task and set OPCODE to 'ZRAT'. This should be done after creating the SN table with FRING, and before creating the CL table with CLCAL. If the delay-rates solutions are extrapolated in the time dimension too far from the solution interval, it can cause huge problems with the data. In the CASA fringefit task, we set zerorates=True to avoid this problem.

IMPORTANT Note that in the CASA calibration process, the gain curve and system temperature calibration tables have been applied at this point. That means the the amplitude values are now in Janskys. The AIPS amplitude calibration is not done until after the bandpass correction.


Global Fringe Fitting

The VLBAUTIL package contains 2 methods for doing the global fringe fit:

  • VLBAFRNG does a fringe fit on every source in the observation
  • VLBAFRGP does a fringe fit on the phase-reference calibrator(s) and transfers those solutions to the science target(s)

This data set required phase referencing, so we will use the VLBAFRGP method.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
VLBAFRGP
inname 'TL016B'
inclass 'UVDATA'
inseq 1
calsour 'J1154+6022','4C39.25'
gainuse 0
refant 2
search 9 5 4 8 7 3
solint 0.5
sources 'J1154+6022','4C39.25','J1203+6031'
interpol '2pt'
FRING
inname 'TL016B'
inclass 'UVDATA'
inseq 1
calsour '4C39.25','J1154+6022'
docal 1
gainuse 0
refant 2
search 9 5 4 8 7 3
solint 0.5
snver 0
fringefit
vis='tl016b.ms'
caltable='tl016b.mbd'
field='4C39.25, J1154+6022'
solint='30s'
minsnr=5
zerorates=False
refant='FD,PT,LA,KP,OV,NL,HN'
gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd']
interp=['nearest', 'nearest', 'nearest,nearest', 'nearest']
parang=True
CLCAL
inname 'TL016B'
inclass 'UVDATA'
inseq 1
timer 0
interp '2pt'
snver 0
refant 2
calsour '4C39.25','J1154+6022'
opcode 'CALP'
gainver 0
gainuse 0
applycal
vis='tl016b.ms'
gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd', 'tl016b.mbd']
interp=['nearest', 'nearest', 'nearest,nearest', 'nearest', 'linear']
parang=True

NOTE: For the global fringe fitting step, it is a good idea to provide a list of possible alternate reference antennas. In AIPS, this is done using the SEARCH parameter in FRING. In CASA, the first antenna listed in the refant parameter is the primary reference antenna, and the others listed are alternates (in order of priority; e.g., the second antenna listed is the first choice for an alternate reference antenna).

For the provided data set, the phase reference calibrator is bright enough to derive good solutions on a per IF/spw basis. Users who have data sets with dimmer phase reference calibrators may find it necessary to combine the IFs/spws when doing the global fringe fitting step to get good signal-to-noise ratios. In the AIPS task FRING, this is done by setting the APARM(5) paramenter to 1. In the CASA task fringefit, this is done by setting combine='spw'. For more information on this in CASA, see the DARA EVN Continuum Tutorial: Part 1, Section 5B - Multi-band Delays.


Bandpass Correction

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
VLBABPSS
inname 'TL016B'
inclass 'UVDATA'
inseq 1
calsour '4C39.25'
refant 2
BPASS
inname 'TL016B'
inclass 'UVDATA'
inseq 1
calsour '4C39.25'
refant 2
docal 1
ginause 0
solint -1
bpassprm(5) 1
bpassprm(9) 1
bpassprm(10) 6
bandpass
vis='tl016b.ms'
caltable='tl016b.bpass'
field='4C39.25'
solint='inf'
refant='FD'
solnorm=True
bandtype='B'
gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd', 'tl016b.mbd']
interp=['nearest', 'nearest', 'nearest,nearest', 'nearest', 'linear']
parang=True)
applycal
vis='tl016b.ms'
gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd', 'tl016b.mbd', 'tl016b.bpass']
interp=['nearest', 'nearest', 'nearest,nearest', 'nearest', 'linear', 'linear,linear']
parang=True

NOTE: In AIPS, you do not need to apply the bandpass correction with CLCAL; you simply need to set doband=1 in all subsequent calibration steps.


Final Amplitude Calibration

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
VLBAAMP
inname 'TL016B'
inclass 'UVDATA'
inseq 1
ichansel 8 122 1 0
ACSCL
inname 'TL016B'
inclass 'UVDATA'
inseq 1
docal 1
gainuse 0
doband 1
bpver 1
solint -2
ichansel 8 122 1 0
accor
vis='tl016b.ms'
spw='*:7~121'
caltable='tl016b.acscl'
solint='2min'
gaintable=['tl016b_smooth.accor', 'tl016b.sbd', 'tl016b.mbd', 'tl016b.bpass']
interp=['nearest', 'nearest', 'linear', 'linear,linear']
SNSMO
inname 'TL016B'
inclass 'UVDATA'
inseq 1
samptype 'mwf'
doblank -1
smotype 'ampl'
cparm 0.5 0 0 0 0 1
inver 0
outver 0
smoothcal
vis='tl016b.ms'
tablein='tl016b.acscl'
caltable='tl016b_smooth.acscl'
smoothtype='median'
smoothtime=1800.0
CLCAL
inname 'TL016B'
inclass 'UVDATA'
inseq 1
opcode 'cali'
interpol 'self'
snver 0
doblank -1
gianver 0
gainuse 0
applycal
vis='tl016b.ms'
gaintable=['tl016b_smooth.accor', 'tl016b.gcal', 'tl016b.tsys', 'tl016b.sbd', 'tl016b.mbd', 'tl016b.bpass', 'tl016b_smooth.acscl']
interp=['nearest', 'nearest', 'nearest,nearest', 'nearest', 'linear', 'linear,linear', 'nearest']
parang=True
APCAL
inname 'TL016B'
inclass 'UVDATA'
inseq 1
tyver 0
gcver 0
snver 0
done with gencal in the A Priori Calibration section above
CLCAL
inname 'TL016B'
inclass 'UVDATA'
inseq 1
opcode 'cali'
interp 'self'
snver 0
doblank -1
gainver 0
gainuse 0
already applied above

IMPORTANT: When doing the final accor step in CASA, DO NOT apply the gain curve or system temperatures!


Split the Calibrated Data Into a New File

At this point, it is good practice to apply all the calibration and split the calibrated data into a new file. It is usually a good idea to drop any of the edge channels that look bad, or that were not used in the final amplitude calibration step (VLBAAMP, ACSCL, etc.). We will not be doing any further calibration with the bandpass calibrator (4C39.25), so we can omit that from the new file.

In CASA, the split task will create a new MS file with all of the sources included in the field variable. Also, it is safe to drop the autocorrelations from the new file by setting antennas='*&*'.

In AIPS, there are two options for applying the calibration and creating new files. The task SPLIT will create a separate single-source file for each source included in the SOURCES parameter. If SOURCES is blank, it will create a new file for each source in the data set. The task SPLAT will create a new multi-source file for each source included in the SOURCES parameter. This walk through will use the SPLAT task to create a new multi-source file with the calibration applied in order to mimic the CASA tutorial as closely as possible.

VLBAUTIL Procedure AIPS Task(s) CASA Task(s)
none SPLAT
inname 'TL016B'
inclass 'UVDATA'
inseq 1
sources 'J1154+6022','J1203+6031'
bchan 8
echan 122
docal 1
gainuse 0
doband 1
bpver 1
outname 'tl016b'
outclass 'splat1'
split
vis='tl016b.ms'
outputvis='tl016b_cal1.ms'
field='J1154+6022,J1203+6031'
spw='*:7~121'
antenna='*&*'
datacolumn='corrected'

NOTE: When moving forward with self-calibration on the SPLAT1 file, it will be necessary to set doband -1 and bpver -1 in all of the self-calibration steps below (the splat1 file will have the bandpass calibration applied and will not contain a BP table).


Self-Calibration Steps

This sections covers the steps needed to perform phase and amplitude self-calibration of the dataset.

NOTE: The VLBAUTIL procedures do not include self-calibration options, so the following subsections will only include AIPS tasks and the equivalent CASA tasks.

ASIDE: Some seasoned VLBA users will do the imaging steps in Difmap (see the Caltech VLBI Programs page) rather than in AIPS. If you want to try this, use SPLIT to create a UVFITS file with only one source in it, then use FITTP to write the single-source UVFITS file to disk, make the image in Difamp, save the image, then read it back into AIPS with IMLOD.


Imaging the Phase Reference Calibrator

The first step in self-calibration is to build a model of the phase reference calibrator with an imaging tool.

AIPS Task(s) CASA Task(s)
IMAGR
inname 'TL016B'
inclass 'SPLAT1'
inseq 1
sources 'J1154+6022'
docal 1
gainuse 0
stokes 'i'
nchav 115
outname 'J1154+6022'
cellsize 0.0002
imsize 512
robust 5
niter 1000
dotv 1
tclean
vis='tl016b_cal1.ms'
field='J1154+6022'
imagename='J1154_sc1'
imsize=[640], cell=['0.2mas']
stokes='I'
deconvolver='clark'
weighting='natural'
niter=1000
interactive=True
savemodel='modelcolumn'

NOTE: In IMAGR, we set the NCHAV parameter to 115 to average all of the spectral channels together for a Stokes I image. This makes the cleaning process go much faster for continuum observations. If NCHAV is set to 1, IMAGR will clean one spectral channel at a time.

Phase Self-Calibration

Now that we have a model of the calibrator, we will make corrections to the phases based on that model.

AIPS Task(s) CASA Task(s)
CALIB
inname 'TL016B'
inclass 'SPLAT1'
inseq 1
calsour 'J1154+6022'
docal 1
gainuse 0
doband -1
bpver -1
in2name 'J1154+6022'
in2class 'icl001'
in2seq 1
refant 2
solmode 'p'
solint 20/60
cmethod 'dft'
aparm 3 0
gaincal
vis='tl016b_cal1.ms'
field='J1154+6022'
caltable='tl016b_cal1.dcal'
solint='inf'
refant='FD'
minblperant=3
gaintype='K'
calmode='p'
parang=False
gaincal
vis='tl016b_cal1.ms'Mbr/>field='J1154+6022'
caltable='tl016b_cal1.pcal'
solint='20s'
refant='FD'
minblperant=3
gaintype='G'
calmode='p'
parang=False
CLCAL
inname 'TL016B'
inclass 'SPLAT1'
inseq 1
calsour 'J1154+6022'
opcode 'calp'
interp '2pt'
snver 0
doblank -1
gainver 0
gainuse 0
applycal
vis='tl016b_cal1.ms'
field='J1154+6022'
gaintable=['tl016b_cal1.dcal','tl016b_cal1.pcal']
interp=['linear','linear']
parang=False

NOTE: In CASA, we first perform a delay self-calibration using solint='inf' and gaintype='K'. Then, we perform the phase self-calibration using solint='20s' and gaintype='G'.


New Image of Calibrator

Once the phase calibration has been improved, it is time to make a new (hopefully nicer) image.

AIPS Task(s) CASA Task(s)
IMAGR
inname 'J1154+6022'
inclass 'SPLAT1'
inseq 1
sources 'J1154+6022'
docal 1
gainuse 0
doband -1
bpver -1
stokes 'i'
nchav 115
outname 'J1154+6022'
cellsize 0.0002
imsize 512
robust 5
niter 1000
dotv 1
tclean
vis='tl016b_cal1.ms'
field='J1154+6022'
imagename='J1154_sc2'
imsize=[640]
cell=['0.2mas']
stokes='I'
deconvolver='clark'
weighting='natural'
niter=1000
interactive=True
savemodel='modelcolumn'


Amplitude Self-Calibration

Now, we will use our improved model (the image made with the improved phase calibration) to make corrections to the amplitudes and phases.

IMPORTANT! Be very careful when doing amplitude self-calibration! It is possible to "build in" false structures to your data if the model is not a good represenation of the calibrator.

AIPS Task(s) CASA Task(s)
CALIB
inname 'TL016B'
inclass 'SPLAT1'
inseq 1
calsour 'J1154+6022'
docal 1
gainuse 0
doband -1
bpver -1
in2name 'J1154+6022'
in2class 'icl001'
in2seq 2
refant 2
solmode 'a&p'
solint 0
cmethod 'dft'
aparm 4 0
gaincal
vis='tl016b_cal1.ms'
field='J1154+6022'
caltable='tl016b_cal1.apcal'
solint='inf'
refant='FD'
minblperant=4
gaintype='G'
calmode='ap'
solnorm=True
gaintable=['tl016b_cal1.dcal','tl016b_cal1.pcal']
interp=['linear','linear']
parang=False
CLCAL
inname 'TL016B'
inclass 'SPLAT1'
inseq 1
opcode 'calp'
interp '2pt'
snver 0
doblank -1
gainver 0
gainuse 0
applycal
vis='tl016b_cal1.ms'
field='J1154+6022'
gaintable=['tl016b_cal1.dcal','tl016b_cal1.pcal','tl016b_cal1.apcal']
interp=['linear','linear','linear']
parang=False


Apply the Self-calibration to the Science Target

In the CASA tutorial, the calibration has only been applied to the phase reference calibrator up to this point. So, before imaging the science target, we need to apply the self-calibration corrections to it.

This step is not necessary for the AIPS calibration because we have been applying the corrections to every source with CLCAL.

AIPS Task(s) CASA Task(s)
not necessary applycal
vis='tl016b_cal1.ms'
field='J1203+6031'
gaintable=['tl016b_cal1.dcal','tl016b_cal1.pcal','tl016b_cal1.apcal']
interp=['linear','linear','linear']
applymode='calonly'
parang=False

NOTE: We have set applymode='calonly' in this step to avoid flagging any time when calibration corrections are unavailable. You should carefully inspect the data to make certain you do not need to do any more flagging.


Split Out Science Target

Apply the calibration to the science target (J1203+6031) and make a single-source file.

AIPS Task(s) CASA Task(s)
SPLIT
inname 'TL016B'
inclass 'SPLAT1'
inseq 1
sources 'J1203+6031'
bchan 1
echan 0
docal 1
gainuse 0
doband -1
bpver -1
outclass 'split1'
split
vis='tl016b_cal1.ms'
outputvis='tl016b_cal2.ms'
field='J1203+6031'
datacolumn='corrected'


Imaging the Science Target

Just like when we imaged the phase reference calibrator, we will use IMAGR and tclean again to make images of the science target J1203+3061.

NOTE: If you expect to do any self-calibration on the science target in CASA, you should make sure to set savemodel='modelcolumn' in tclean.

AIPS Task(s) CASA Task(s)
IMAGR
inname 'J1203+6031'
inclass 'SPLIT1'
inseq 1
sources 'J1203+6031'
docal -1
stokes 'i'
nchav 115
cellsize 0.0002
imsize 512
robust 5
niter 1000
dotv 1
tclean
vis='tl016b_cal2.ms'
field='J1203+6031'
imagename='J1203_im1'
imsize=[640], cell=['0.2mas']
stokes='I'
deconvolver='clark'
weighting='natural'
niter=1000
interactive=True
savemodel='modelcolumn'

NOTE: In IMAGR, if docal is set to 1, you may see an error saying something like "REQUESTED SN FILE 0 DOES NOT EXIST".

To view the resulting image in AIPS, use the TVLOD or TVAL to put the image in the AIPS TV window. First, type "mc" to list all of the images in the image catalog. Find the J1203+6031.ICL001.1 file, and type "getn #" where # is the catalog number for the file. Type "tvini" to clear the AIPS TV window. Then type "tvlod" or "tval" to put the image in the window. TVAL is a little more flexible and allows you change from grayscale to color (click in the window, and hit "A" twice", and adjust the color scale (click in the window, hit "A" and and click & drag the mouse); when you are done making changes, hit "D" and AIPS will exit TVAL but leave the image in the TV window.

J1203+6031 is bright enough to do phase self-calibration. Users are welcome to attempt this by following the same steps outlined in the "Phase Self-Calibration" section above, but changing the source name and the solution interval.


Exiting the Programs

Once the data are calibrated and images are made, users will want to cleanly exit the programs.

To exit CASA, simply type "quit" in the command line. This will exit CASA and close the message log.

To exit AIPS, type "kleenex" in the command line. This will exit AIPS, close the message log, and close any AIPS TV windows that are open.


AIPS and CASA Tasks

Here are some of the AIPS tasks commonly used in VLBI calibration, and their equivalent CASA tasks (when one exists).

AIPS Task CASA Task
ACCOR accor
ACSCL accor with special inputs
ANTAB none
APCAL gencal
BPASS bandpass
CALIB gaincal
CLCAL applycal
CLCOR none
DELZN none
DTSUM none
FITLD importfitsidi
FITTP exportfits or exportuvfits
FRING fringefit
FTFLG none
IMAGR tclean
IMLOD importfits
LISTR listobs
LPCAL none
POSSM plotms
QUACK flagdata
mode='quack'
RFLAG flagdata
mode='rflag'
RLDLY gaincal
SNCOR none
SNEDT plotms
SNPLT plotms
SNSMO smoothcal
SPFLG none
SPLAT split
SPLIT split
TECOR none
TVFLG none
UVFLG flagdata
UVPLT plotms

In some cases where there is no equivalent CASA task, there may be an equivalent CASA tool (code that works in CASA but is not maintained by the CASA Development Team). For example, the CASA tool polsolve (e.g., Marti-Vidal et al. 2021) is designed to function similar to the AIPS task LPCAL.