From Loading Data to Images

Steps involved in the CASA workflow

 The subsections below provide a brief overview of the steps you will need to load data into CASA and obtain a final, calibrated image. Each subject is covered in more detail in other chapters. 

An end-to-end workflow diagram for CASA data reduction for interferometry data is shown in the Figure below. This might help you chart your course through the package. In the following sub-sections, we will chart a rough course through this process, with the later chapters filling in the individual boxes.

 
Type Figure
ID dataflow-fig-schematic
Caption Flow chart of the data processing operations that a general user will carry out in an end-to-end CASA reduction session.

 

Note that single-dish data reduction (for example with the ALMA single-dish system) follows a similar course. This is detailed in the corresponding chapters.

Loading Data into CASA

 

The key data and image import tasks are (see "Visibility Data Import Export"):

  • importuvfits — import visibility data in UVFITS format
  • importvla — import data from VLA that is in export format 
  • importasdm — import ALMA data in ASDM format 
  • importfits — import a FITS image into a CASA image format table

These are used to bring in your interferometer data, to be stored as a CASA MeasurementSet (MS), and any previously made images or models (to be stored as CASA image tables).

The data import tasks will create a MS with a path and name specified by the vis parameter.  The MeasurementSet is the internal data format used by CASA, and conversion from any other native format is necessary for most of the data reduction tasks.

Once data is imported, there are other operations you can use to manipulate the datasets:

  • concat — concatenate multiple MSs into a given or a new MS 

 

VLA: Filling data from VLA archive format

Jansky VLA data in "archive SDM format are read into CASA via importasdm.  Historic VLA data can be filled with the tasl importvla.

 

Fillin data from Scantable format

CASA can import data from the Scantable format, since the development of Single-Dish started with that format (based on ASAP format ). Currently, CASA tasks in Scantable format is no longer supported, but Scantable format can be converted into MeasurementSet format, with importASAP.

 

Filling data from UVFITS format

 For UVFITS format, use the importuvfits task. A subset of popular flavors of UVFITS (in particular UVFITS as written by AIPS) is supported by the CASA filler. FITSIDI (frequently used for VLBI data) can be read by importfitsidi. See "Visibility Data Import Export" for details. 

 

Loading FITS images

 For FITS format images, such as those to be used as calibration models, use the importfits task. Most, though not all, types of FITS images written by astronomical software packages can be read in. See "Image Analysis" for more information.

 

Concatenation of multiple MS

 Once you have loaded data into MeasurementSets on disk, you can use the tasks concat or virtualconcat to combine them.

 

Data Examination, Editing, and Flagging

 The main data examination and flagging tasks are:

  • listobs — summarize the contents of a MS 
  • flagmanager — save and manage versions of the flagging entries in the MeasurementSet
  • plotms — interactive X-Y plotting and flagging of visibility data 
  • flagdata — flagging (and unflagging) of specified data
  • viewer — the CASA viewer can display (as a raster image) MS data, with some editing capabilities

These tasks allow you to list, plot, and/or flag data in a CASA MS.

Descriptions can be found in "Data Examination and Editing".

 

Interactive X-Y Plotting and Flagging

 

The principal tool for making X-Y plots of visibility data is plotms (see "Data Examination and Editing"). Amplitudes and phases (among other things) can be plotted against several x-axis options.

Interactive flagging (i.e., “see it – flag it”) is possible on the plotms X-Y displays of the data. Since flags are inserted into the MeasurementSet, it is useful to backup (or make a copy) of the current flags before further flagging is done, using flagmanager. Copies of the flag table can also be restored to the MS in this way.

plotms can also be invoked without starting CASA. Launch it with 

casaplotms &

from any terminal. 

 

Flag the Data Non-interactively

The flagdata task ("Data Examination and Editing") will flag the visibility data set based on the specified data selections. The listobs task may be run (e.g. with verbose=True) to provide some of the information needed to specify the flagging scope. flagdata also contains autoflagging routines.

 

Viewing and Flagging the MS

The CASA viewer can be used to display the data in the MS as a (grayscale or color) raster image. The specific part of the viewer can also be launched with msview. The MS can also be edited ("Data Examination and Editing"). 

 

Calibration

 The major calibration tasks are:

  • setjy — Computes the model visibilities for a specified source given a flux density or model image, knows about standard calibrator sources 
  • initweights — if necessary, supports (re-)initialization of the data weights, including an option for enabling spectral weight accounting
  • gencal — Creates a calibration table for known delay and antenna position offsets, opacities, and requantizer gains
  • bandpass — Solves for frequency-dependent (bandpass) complex gains
  • gaincal — Solves for time-dependent (frequency-independent) complex gains
  • fluxscale — Bootstraps the flux density scale from standard calibrators
  • polcal — polarization calibration
  • applycal — Applies calculated calibration solutions
  • clearcal — Re-initializes calibrated visibility data in a given MeasurementSet
  • listcal — Lists calibration solutions
  • plotcal — Plots (and optionally flags) calibration solutions
  • uvcontsub — carry out uv-plane continuum subtraction for spectral-line data
  • split — write out a new (calibrated) MS for specified sources
  • cvel — Regrid a spectral MS onto a new frequency channel system 

During the course of calibration, the user will specify a set of calibrations to pre-apply before solving for a particular type of effect, for example gain or bandpass or polarization. The solutions are stored in a calibration table (subdirectory) which is specified by the user, not by the task: care must be taken in naming the table for future use. The user then has the option, as the calibration process proceeds, to accumulate the current state of calibration in a new cumulative table. Finally, the calibration can be applied to the dataset.

See "Synthesis Calibration" for more information.

 

Prior Calibration

The setjy task calculates absolute fluxes for MeasurementSet base on known calibrator sources. This can then be used in later calibration tasks. Currently, setjy knows the flux density as a function of frequency for several standard VLA flux calibrators and solar system objects, and the value of the flux density can be manually inserted for any other source. If the source is not well-modeled as a point source, then a model image of that source structure can be used (with the total flux density scaled by the values given or calculated above for the flux density). Models are provided for the standard VLA calibrators and calculated for solar system objects.

Antenna gain-elevation curves (e.g. for the VLA antennas), gain curves, requantizer gains, and atmospheric optical depth corrections (applied as an elevation-dependent function) may be pre-applied before solving for the bandpass and gains. The task gencal will generate those to be applied for further calibration.

See "Synthesis Calibration" for more information.

 

Delay Calibration

A delay for each antenna can be calculated using gaincal with option "K". The delay calibration will remove delay errors that cause systematic slopes in the phases as a function opf time. In particular phase wraps will be removed. 

 

Bandpass Calibration

The bandpass task calculates a bandpass calibration solution: that is, it solves for gain variations in frequency as well as in time. Since the bandpass (relative gain as a function of frequency) generally varies much more slowly than the changes in overall (mean) gain solved for by gaincal, one generally uses a long time scale when solving for the bandpass. The default ’B’ solution mode solves for the gains in frequency slots consisting of channels or averages of channels.

A polynomial fit for the solution (solution type ’BPOLY’) may be carried out instead of the default frequency-slot based ’B’ solutions. This single solution will span (combine) multiple spectral windows.

Bandpass calibration is discussed in detail in "Synthesis Calibration".

If the gains of the system are changing over the time that the bandpass calibrator is observed, then you may need to do an initial gain calibration (see next step).

 

Gain Calibration

The gaincal task determines solutions for the time-based complex antenna gains, for each spectral window, from the specified calibration sources. A solution interval may be specified. The default ’G’ solution mode solves for antenna-based gains in each polarization in specified time solution intervals. The ’T’ solution mode is the same as ’G’ except that it solves for a single solution shared by both polarizations.

A spline fit for the solution (solution type ’GSPLINE’) may be carried out instead of the default time-slot based ’G’ solutions.

Gain calibration is discussed in detail in "Synthesis Calibration".

 

Polarization Calibration

The polcal task will solve for any unknown polarization leakage and cross-hand phase terms (’D’ and ’X’ solutions). The ’D’ leakage solutions will work on sources with no polarization and sources with known (and supplied, e.g., using smodel) polarization. For sources with unknown polarization tracked through a range in parallactic angle on the sky, using poltype ’D+QU’, which will first estimate the calibrator polarization for you.

The solution for the unknown cross-hand polarization phase difference ’X’ term requires a polarized source with known linear polarization (Q,U).

Frequency-dependent (i.e., per channel) versions of all of these modes are also supported (poltypes ’Df’, ’Df+QU’, and ’Xf’.

 

Examining Calibration Solutions

The plotcal task and plotms will plot the solutions in a calibration table. The xaxis choices include time (for gaincal solutions) and channel (e.g. for bandpass calibration). 

The listcal task will print out the calibration solutions in a specified table.

 

Bootstrapping Flux Calibration

The fluxscale task bootstraps the flux density scale from “primary” standard calibrators to the “secondary” calibration sources. Note that the flux density scale must have been previously established on the “primary” calibrator(s) using setjy, and of course a calibration table containing valid solutions for all calibrators must be available.

 

Correcting the Data

The final step in the calibration process, applycal may be used to apply several calibration tables (e.g., from gaincal or bandpass, along with prior calibration tables). The corrections are applied to the DATA column of the visibility, writing the CORRECTED_DATA column which can then be plotted in plotms, split out as the DATA column of a new MS, or imaged (e.g. using clean). Any existing corrected data are overwritten.

 

Splitting the Data

After a suitable calibration is achieved, it may be desirable to create one or more new MeasurementSets containing the data for selected sources. This can be done using the split task (see "UV Manipulation").

Further imaging and calibration (e.g. self-calibration) can be carried out on these split MeasurementSets.

 

UV Continuum subtraction

For spectral line data, continuum subtraction can be performed in the image domain (imcontsub) or in the uv domain. For the latter, uvcontsub subtracts polynomial of desired order from each baseline, defined by line-free channels.

 

Transforming the Data to a new frame

If you want to transform your dataset to a different frequency and velocity frame than the one it was observed in, then you can use the cvel task ("UV Manipulation"). Alternatively, you can do the regridding during the imaging process in clean without running cvel before.

 

Synthesis Imaging

 

The key synthesis imaging tasks are:

  • clean (and tclean)— Calculates a deconvolved image based on the visibility data, using one of several clean algorithms
  • feather — Combines a single dish and synthesis image in the Fourier plane

Most of these tasks are used to take calibrated interferometer data, with the possible addition of a single-dish image, and reconstruct a model image of the sky.

See Chapter "Synthesis Imaging" and "Image Combination" for more information.

 

Cleaning a single-field image or a mosaic

 The CLEAN algorithm is the most popular and widely-studied method for reconstructing a model image based on interferometer data. It iteratively removes at each step a fraction of the flux in the brightest pixel in a defined region of the current “dirty” image, and places this in the model image. The clean task implements the CLEAN algorithm for single-field data. The user can choose from a number of options for the particular flavor of CLEAN to use.

Often, the first step in imaging is to make a simple gridded Fourier inversion of the calibrated data to make a “dirty” image. This can then be examined to look for the presence of noticeable emission above the noise, and to assess the quality of the calibration by searching for artifacts in the image. This is done using clean with niter=0.

The clean task can jointly deconvolve mosaics as well as single fields, and also has options to do wide-field and wide-band multi-frequency synthesis imaging.

See "Synthesis Imaging" for an in-depth discussion of the clean task.

 

Feathering in a Single-Dish image

 If you have a single-dish image of the large-scale emission in the field, this can be “feathered” in to the image obtained from the interferometer data. This is carried out using the feather task as the weighted sum in the uv-plane of the gridded transforms of these two images. While not as accurate as a true joint reconstruction of an image from the synthesis and single-dish data together, it is sufficient for most purposes. A graphical version of feather is provided by casafeather

See "Image Combination" for an in-depth discussion of the feather task.

 

 

Self Calibration

Once a calibrated dataset is obtained, and a first deconvolved model image is computed, a “self-calibration” loop can be performed. Effectively, the model (not restored) image is passed back to another calibration process (on the target data). This refines the calibration of the target source, which up to this point has had (usually) only external calibration applied. This process follows the regular calibration procedure outlined above.

Any number of self-calibration loops can be performed. As long as the images are improving, it is usually prudent to continue the self-calibration iterations.

This process is described in "Synthesis Calibration".

 

Data and Image Analysis

The key data and image analysis tasks are:

  • imhead — summarize and manipulate the “header” information in a CASA image
  • imcontsub — perform continuum subtraction on a spectral-line image cube 
  • immath — perform mathematical operations on or between images 
  • immoments — compute the moments of an image cube 
  • imstat — calculate statistics on an image or part of an image 
  • imval — extract values of one or more pixels, as a spectrum for cubes, from an image 
  • imfit — simple 2D Gaussian fitting of single components to a region of an image 
  • imregrid — regrid an image onto the coordinate system of another image 
  • viewer — there are useful region statistics and image cube plotting capabilities in the viewer

 

What’s in an image?

The imhead task will print out a summary of image “header” keywords and values. This task can also be used to retrieve and change the header values.

See "Image Analysis" for more.

 

Image statistics

The imstat task will print image statistics. There are options to restrict this to a box region, and to specified channels and Stokes of the cube. This task will return the statistics in a Python dictionary return variable.

 

Image values

The imval task will return values from an image. There are options to restrict this to a box region, and to return specified channels and Stokes of the cube as a spectrum. This task will return these values in a Python dictionary return variable which can then be operated on in the CASA environment.

 

Moments of an image cube

The immoments task will compute a “moments” image of an input image cube. A number of options are available, from the traditional true moments (zero, first, second) and variations thereof, to other images such as median, minimum, or maximum along the moment axis.

 

Image math

The immath task will allow you to form a new image by mathematical combinations of other images (or parts of images). This is a powerful task to use.

 

Regridding an Image

It is occasionally necessary to regrid an image onto a new coordinate system. The imregrid task can be used to regrid an input image onto the coordinate system of an existing template image, creating a new output image.

 

Displaying Images

To display an image use the viewer task. The viewer will display images in raster, contour, or vector form. Blinking and movies are available for spectral-line image cubes. To start the viewer, type:

viewer

within CASA or 

casaviewer &

Executing the viewer task will bring up two windows: a viewer screen showing the data or image, and a file catalog list. Click on an image or MS from the file catalog list, choose the proper display, and the image should pop up on the screen. Clicking on the wrench tool (second from left on upper left) will obtain the data display options. Most functions are self-documenting.

 

See "Image / Cube Visualization" for more details. 

 

Getting data and images out of CASA

The key data and image export tasks are:

  • exportuvfits — export a CASA MS in UVFITS format
  • exportfits — export a CASA image table as FITS

These tasks can be used to export a CASA MS or image to UVFITS or FITS respectively. See the individual sections referred to above for more on each.