VLBA AIPS and CASA Walkthrough

From CASA Guides
Jump to navigationJump to search

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 sampler and gain corrections (ACCOR, ACSCL, APCAL), fringe-fitting (FRING), and self-calibration (CALIB)
  • 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.

NOTE: When using importfitsidi with VLBA data, it is normal to see several warnings in the casalogger and the casa window. These can usually be ignored. However, do not ignore any SEVERE warnings because these can indicate there are serious problems with the data.

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
aparm(9) 1
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 2
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.