This page describes the hands-on imaging portion of the ALMA data reduction workshop. In this session you will use ALMA Science Verification data to explore CASA's imaging capabilities. This page describes the data and introduces the scripts. It is not a full-fledged CASA guide, only background for the hands on portion of the workshop. For the self-calibration session in the afternoon go here: WorkshopSelfcal
Currently five ALMA Science Verification data sets have been released. The calibrated u-v data for all five projects should appear in your cluster account in the directory "imaging/calib/". Briefly the projects are:
- NGC3256_Band3 Single-field observations of the nearby starburst galaxy NGC 3256 in Band 3. The data were taken in "TDM" mode and so have low frequency resolution compared to the other data sets here (about 15 MHz per channel). The spectral windows cover the CO J=1-0 line, a CN doublet, and the 3mm continuum. All three types of emission are visible and extended in the data. There is a full CASA Guide describing the reduction and imaging of these data here: NGC3256Band3.
- TWHYA_BAND7 Single-field observations of the debris disk around the nearby pre main sequence star TW Hya in Band 7. These data have high frequency resolution (they are "FDM" mode) and cover the 850 micron continuum, the CO J=3-2 line, and HCO+ J=4-3 line. There is a full CASA Guide describing the reduction and imaging of these data here: TWHydraBand7.
- TWHYA_BAND6 Single-field observations of TW Hya in Band 6. These data have high frequency resolution and cover 1mm continuum, the CO J=2-1 line, and the DCN J=3-2 line. These data do not have an associated CASA guide because the approach closely resembles that used for TW Hya Band 7. They were released with an annotated script, which is included in the same directory as the calibrated data.
- TWHYA_BAND3 Single-field observations of TW Hya in Band 3. These data have high frequency resolution and cover 3mm continuum and the HCO+ J=1-0 line. These data do not have an associated CASA guide because the approach closely resembles that used for TW Hya Band 7. They were released with an annotated script, which is included in the same directory as the calibrated data.
- Antennae_Band7 Two mosaics targeting the nearby merging galaxies NGC 4038 and NGC 4039 in Band 7. These data have high frequency resolution (though they have been somewhat averaged) and cover the 850 micron continuum and the CO J=3-2 line. These data contain two separate mosaics (collections of pointings), one targeting the northern component of the Antennae galaxies and the other targeting the southern component. The mosaics do not overlap but are close enough that they can be combined into a single image if desired. There is a full CASA Guide describing the reduction and imaging of these data here: AntennaeBand7.
In each case, you should see a single measurement set (".ms" file) inside the directory associated with the data. These have already been bandpass, phase, and amplitude calibrated following the procedures described in the first day of the workshop. The science targets have been separated out from the rest of the data (using the split task), yielding the calibrated measurement sets in your directories. We will use these to explore imaging in CASA.
Imaging in CASA revolves around the clean task. clean has a wide array of modes and options, many of which have been discussed in the morning lecture. For the imaging hands-on session, we provide scripts to set you up imaging the science verification data. These scripts all center on calls to clean. Given the size of the data and the power of the cluster you should have no problem running them repeatedly, changing key parameters to explore their effects on the output image. The scripts cover:
- Basic continuum imaging In the first script, you will take any of the data sets and produce a "continuum" image by averaging together data at all frequencies into a single image. This will introduce you to the basic setup of the clean task and using the viewer for interactive cleaning and data inspection. You have the opportunity to explore the effects stopping conditions, u-v weighting, and gridding parameters.
- Multifrequency synthesis with spectral indices For high signal-to-noise data sets with large fractional bandwidth it can be important to account for the frequency dependence ("spectral index") of continuum emission when constructing an image. CASA's multifrequency synthesis ("mfs") mode allows modeling of sources with frequency-dependent intensity. Using this script you can explore the application of this algorithm to the TW Hydra data sets.
- Line imaging Imaging spectral lines introduces two new complexities. The spectral axis needs to be specified via the "velocity", "frequency", or "channel" modes of clean and line and continuum emission need to be separated from one another. We will see how to separate line and continuum emission in the u-v domain using uvcontsub and then build data cubes using clean.
- Mosaic imaging clean can build mosaics out of data sets with multiple pointing centers. We will experiment with this mode on the Antennae data sets.
We suggest working through in order of increasing complexity. Each call should take no longer than a minute to run, so there should be plenty of time to experiment with each type of imaging during the two hour session.
Setup: We recommend that you open each script in turn in your favorite editor and start up a "casapy" session in another window. Most of the scripts have a few preparatory calls, often averaging or copying the data to make a working copy that can be quickly processed. Step through these, reading the comments and making sure that you understand what is going on, then focus on the clean call.
Syntax: In the scripts tasks other than clean are called using inline parameters, e.g., "split(vis='suchandsuch.ms')", and can be directly pasted in to the command line. This approach is generally favored for scripting because of the ease of copying and ready reproducibility (the task only knows about the parameters that you can see in the call). For the clean calls in these examples we will use the more instructive but potentially messier "AIPS-style" approach. We always initialize clean with its default parameters using:
# In CASA default('clean')
and then we define the parameters of interest to us as global python variables with the appropriate names. At any time, you can check the current inputs to clean by typing
# In CASA inp
CASA will indicate invalid selections via red color-coding.
Once you are happy with the parameters that you have set you can fire off clean by typing
# In CASA go
# In CASA clean
Script 1: Basic Continuum Imaging
This script provides your basic introduction to imaging. You need to run it in a directory so that "../../calib/" points to the provided science verification data.
You can image the continuum from any and all of the single-field science verification data. A few comments:
- "help" and "inp" are your friends. Use these to explore any tasks that you are unfamiliar with.
- listobs is always a good first bet to get your bearings. Remember that you can direct the output to a file via the "listfile" parameter.
- "#" is the python comment symbol. Lines beginning with this will not be processed by the casapy shell. The script includes some suggestions for alternative settings commented out and you can edit it (it's your copy) to change between these.
- split is used here to copy and average the data in frequency. From listobs you will see that the NGC 3256 data have much coarser channels to begin with, so we suggest to only average these by a factor of 4. To make the TW Hya data run quickly, a factor of ~ 100 is more appropriate.
- We use mode "mfs" with "nterms=1". This tells clean to account for the effects of frequency on the position of u-v data, but not to incorporate a spectral index term into the deconvolution.
- We set the script to use clean in interactive mode, meaning that the user will determine the mask and decide when to stop cleaning. This is done via the CASA viewer. See a more in depth explanation here: http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html (and has been described this morning). Key things to note for this application:
- Define a Clean Mask: You will want to define a clean mask using the square or polygon tools (click them with the button you wish to assign, then click out a roughly minimal mask that encompasses the emission from the source, then double click inside - the mask should turn white). This mask is saved during cleaning with a ".mask" extension.
- Executing Clean: You will want to use the "green circle" button to tell clean to proceed only with the specified number of iterations and then show you the residuals again to allow you to make a judgment call on whether to clean deeper. If you instead click the "blue arrow" clean will proceed non-interactively until it meets the stopping criteria specified by the number of iterations or the threshold maximum residual.
- You can recycle a mask that you like by feeding the file name to clean in the mask parameter (though note that the "os.system" call in the script will wipe the mask as written. You can change this.).
- Note that clean will by default resume imaging and deconvolution from whatever exists on disk with the provided image name. As result, if you want to restart imaging and deconvolution, you need to manually wipe the previous files from disk. This is the reason for the "os.system("rm")" call in the script. As noted, an unfortunate side effect of this is that you wipe the mask. You can change this by spelling out which files you want to delete and making sure that the mask is not one of these or by renaming the mask.
- Best practices are to place ~ 5 pixels across the synthesized beam. You may need to make a test image first or iterate your imaging to ensure that this condition holds.
- The weighting of u-v data are a free parameter that can have a substantial impact on the output image. Try alternating between "natural" and "robust" weighting and manipulating the robust parameter.
Script 2: Multifrequency Synthesis with Spectral Indices
For both ALMA and the EVLA, it can easily be the case where the intensity of the source varies substantially across the observed bandpass (spectral indices can reach 4 for ALMA and bandpasses for both telescopes can be very wide). The multifrequency synthesis mode used for continuum images can handle such emission by adding a (resolved) spectral index to the model. This mode is activated by specifying a value higher than 1 for the "nterms" expandable parameter for mode "mfs" (e.g., here we will use "nterms=2").
This script demonstrates the application of this capability and its output. Please note the important caveat that the internal amplitude calibration of the TW Hya data are not ideal, though the calibration between bands should be fine. Thus an internal application, e.g., to Band 7 should be viewed as instructive rather than yielding science quality results. You can use plotms to see that the internal calibration may be problematic (e.g., for the Tw Hydra Band 7 data, the individual spectral windows jump up and down slightly in amplitude).
A few considerations to note:
- clean accepts a list of input files. Here you can chose to combine 1, 2, or all 3 of the TW Hydra data sets. clean will image them together. Note that this is not a uniquely multifrequency application, it can also be used to combine, e.g., data from different days or observing runs.
- The output of mfs with nterms >= 2 is a bit different than for nterms = 1. You now have both an intensity image (labeled '.tt0') and a spectral index file (labeled '.alpha'). The intensity image occurs at the fiducial frequency, which can be specified in clean and does not have to be a frequency that you observed. The spectral index image describes the local alpha where intensity \propto frequency^alpha. You can view both with the viewer.
- You can specify nterms higher than 2 to account for spectral curvature beyond a mere power law. This isn't likely to be the limiting factor in the immediate future.
- Notice that MFS is willing to combine data from different bands. This is potentially dangerous if the u-v coverage among bands is very different and the spectral index as a function of position has complex behavior, but with matched u-v coverage between bands this can give you a very powerful lever arm on the resolved (or unresolved) spectral index of your source. Experiment with combining two or all three bands and have a look at the results.
- You may need to be a bit careful with stopping thresholds here. These operate on the residual at your fiducial frequency and the spectral index can be pretty steep. A perfectly reasonable stopping threshold at Band 7 may not work when you combine all three bands.
Once you are satisfied with multifrequency synthesis, move on to spectral line imaging.
Script 3: Line Imaging
Imaging a spectral line data set adds a couple of extra complications to the process. First, the third dimension needs to be specified. This can be done in units of velocity, frequency, or channels using the "mode" of the same name. You can specify the starting value, step per image plane, and number of image planes. CASA will attempt to average appropriately to meet your request, though obviously it cannot do better than the underlying data allow. Related, CASA does not know a priori what line you are imaging. You need to specify the rest frequency of the line. A few considerations along these lines:
- The script incorporates a priori knowledge of the mapping between lines and spectral windows. You would know this for your data from having written the observing script or read the proposal (or combining listobs, a resource like Splatalogue, and your knowledge of astrophysics).
- We also provide rest frequencies for the relevant lines within the script. Again, at the moment you need to know these a priori (though of course you can simply image the whole cube, particularly for NGC 3256, and work backwards from the frequencies at which you see lines to guess the line).
- As you run the interactive clean for three dimensional data sets you will notice that the clean mask is also now three dimensional. The path of least resistance here is to specify a two dimensional clean mask that applies to all planes by flipping the radio button near the top of the window to "all planes". Alternatively you can carefully construct a channel-by-channel mask. If you do this, be sure to make a copy because you probably don't want to do it twice!
Second, as we have already seen each of the science verification data sets contains a mixture of continuum and line emission. In most cases we would like to separate out the line emission for analysis. This can be done using standard image processing techniques after forming the cube, but the more robust and standard way to approach this is to carry out continuum subtraction in the original u-v data set. This is done using the uvcontsub task, which will produce a new, continuum-subtracted copy of the measurement set with the extension ".contsub". To apply this successfully, we need to tell uvcontsub what region of the spectrum we think is free of line emission and what order polynomial we would like it to fit. The script includes a call to plotms that heavily averages to produce a single spectrum useful for identifying line-free channels.
- The CASA guides mix calls to uvcontsub and uvcontsub2. This is a historical artifact, as of CASA 3.3 - which you are using - uvcontsub represents the current version of the task.
- Notice that uvcontsub is spinning out a new measurement set to hold the continuum-subtracted version of the data. You want to image this "contsub" version of the data. Note that you don't want to image the continuum produced in this way.
Other considerations for line imaging:
- In practice please notice that we are hand feeding you a lot of hard numbers here. The practical case of line imaging is likely to have a fair amount of trial and error as you find the right parameters to build your cube.
Script 4: Mosaic Imaging
The last dimension that we will add will be mosaicking. We turn on CASA's mosaicking capability by switching the parameter "imagermode" to "mosaic". Though not unique to this imaging mode, several additional consideration arise for this case:
- You can manually specify the center about which CASA will image using the "phasecenter" parameter. This can be set to either a field name (useful for mosaics and used here) or a specific RA, Dec coordinate pair.
- You can tell clean to mask the output image so that only parts of the sky covered by the primary beam are imaged. This is done via the "minpb" parameter, which specifies the minimum primary beam response necessary to be included in the output image (e.g., "minpb=0.5" would image only inside the FWHM of the primary beam).
- You can also request that the final image be corrected for the primary beam via the "pbcor" parameter. Note that this is not done by default.
Note that mosaicking can be combined with spectral line imaging (see the case of the AntennaeBand7 CASA guide) and, eventually, with higher nterms values for "mfs" (though this latter capability is still under development). Both applications can be very time consuming, making them less than ideal for a hands-on tutorial. The syntax and decisions extrapolate directly from the examples that we have stepped through.