WorkshopSelfcal (Caltech): Difference between revisions
No edit summary |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
'''This page steps through self-calibration of ALMA Science Verification data.''' | '''This page steps through self-calibration of ALMA Science Verification data.''' | ||
Acknowledgments: Wiki, tutorial and python scripts created by '''Adam Leroy''', and ''slightly'' modified from the [https://science.nrao.edu/facilities/alma/naasc-workshops/almadata ALMA data reduction workshop in CV, Dec 2011]) to suit the CASA Caltech workshop. | |||
The goal of this session is to improve the image quality by carrying out self-calibration on ALMA Science Verification data. This page describes the data and introduces the scripts to do so. It is not a full-fledged CASA guide, only background for the hands on portion of the workshop. | |||
== Overview == | == Overview == | ||
Line 7: | Line 9: | ||
=== Data Description === | === Data Description === | ||
You will use the '''calibrated''' NGC 3256 Band 3 or TW Hydra Band 7 Science Verification data: | You will use the '''calibrated''' NGC 3256 Band 3 or TW Hydra Band 7 Science Verification data. To copy the necessary data to your local directory, do the following: | ||
<source lang="bash"> | |||
cd /scr[2]/casa/ | |||
tar -xvf /data/casa/alma/tar/TWHYA_BAND7_CalibratedData.tgz | |||
</source> | |||
If curious, the calibration steps that produced the datasets you will be using can be found here (and most likely you already went through one of these tutorials in a previous session): | If curious, the calibration steps that produced the datasets you will be using can be found here (and most likely you already went through one of these tutorials in a previous session): | ||
Line 19: | Line 24: | ||
Both contain several lines, including CO emission (1-0 for NGC 3256 and 3-2 for TW Hydra), and continuum emission. We will begin by imaging the continuum emission and using the resulting model to self calibrate the data. We will then see how to apply that self-calibration to improve the line emission images. | Both contain several lines, including CO emission (1-0 for NGC 3256 and 3-2 for TW Hydra), and continuum emission. We will begin by imaging the continuum emission and using the resulting model to self calibrate the data. We will then see how to apply that self-calibration to improve the line emission images. | ||
=== Basic Selfcal Approach === | |||
Assuming that you are comfortable with imaging, we suggest to grab the script above each section below, and use it to image NGC 3256 or TW Hydra (just uncomment/comment the relevant portions to apply the script to either data set). On each section, the script takes you through one iteration of self-calibration but the approach can be iterative, improving the model of the source as the corrected data become more and more accurate. The basic steps are: | |||
# Use '''gaincal''' to derive the complex gain corrections to each antenna that best match the data to the model. | |||
# When satisfied with these corrections, apply them to the data to create a new corrected data set. | |||
# Image those data. | |||
# Re-iterate, i.e. go back to step 1. | |||
Once you are comfortable with the procedure, try iterating and perhaps adding an amplitude calibration to the selfcal. Your degrees of freedom in this process are the solution interval and how you otherwise combine the data (averaging polarizations, spectral windows or channels, using a specific field in a mosaic). Try experimenting with these settings to see how your results are affected. Your basic diagnostic is the plotting of solutions using '''plotcal''' but the amount of noise and the structure of the residuals in the final image can also be useful indicators. | |||
== Continuum Self Calibration == | == Continuum Self Calibration == | ||
[[File: | Create a working folder: | ||
<source lang="bash"> | |||
mkdir continuum_selfcal | |||
cd continuum_selfcal/ | |||
</source> | |||
Configure the following script to step you through a first phase self-calibration of either the TW Hydra Band 7 or NGC 3256 Band 3 data. Adjust the comments to use the data set that you like. | |||
[[File:Basic_selfcal_Caltech.py]] | |||
The script will create a first, basic image following the same procedure that you used to image in the previous sessions. You will then self-calibrate to create a better image. Some comments to bear in mind: | |||
* Remember that each CASA Measurement Set has three columns: data, corrected, and model. Conceptually ''data'' are the raw u-v data, ''corrected'' data are the data corrected by some complex gain solution, and ''model'' represents the model visibility that should | * Remember that each CASA Measurement Set has three columns: data, corrected, and model. Conceptually ''data'' are the raw u-v data, ''corrected'' data are the data corrected by some complex gain solution, and ''model'' represents the model visibility that should matched the data in the absence of noise, antenna-dependent complex gain terms, or other corruptions. A ''data'' column is required for every measurement set, ''corrected'' data appear as a result of applying a calibration via '''applycal''' (or copying the data column in a few cases), and ''model'' data are either read in or initialized via '''setjy''' or copied back into the measurement set during deconvolution by '''clean''' with the calready option turned on. | ||
* You fill the model column with '''clean'''. This is done during the deconvolution, so you want to clean down to the point where you believe that the model you have built is still real but no further. '''gaincal''' will try derive solutions to match your data to whatever model you have in. So be sure that the model is real! (This is a potential danger of self-calibration.) | * You fill the model column with '''clean'''. This is done during the deconvolution, so you want to clean down to the point where you believe that the model you have built is still real but no further. '''gaincal''' will try derive solutions to match your data to whatever model you have in. So be sure that the model is real! (This is a potential danger of self-calibration.) | ||
Line 51: | Line 69: | ||
== Continuum-to-Line Self Calibration == | == Continuum-to-Line Self Calibration == | ||
[[File: | [[File:Line_cont_selfcal_Caltech.py]] | ||
Self-calibration can also be used to improve your spectral line imaging. You can do this by self-calibrating the line data set directly or by using deriving corrections for the continuum emission and then applying them to the data before imaging the line data. The script here shows an example of the procedure to apply a continuum-based self-calibration to line data, which are then separated out and imaged. It builds on the previous (" | Self-calibration can also be used to improve your spectral line imaging. You can do this by self-calibrating the line data set directly or by using deriving corrections for the continuum emission and then applying them to the data before imaging the line data. The script here shows an example of the procedure to apply a continuum-based self-calibration to line data, which are then separated out and imaged. It builds on the previous ("Basic_selfcal_Caltech.py") script, you need the calibration table from that script in hand so step through that one first. A few notes: | ||
* The calibration tables know about spectral windows by their number. This means that you could potentially get yourself into trouble by splitting out a subset of the spectral windows (thus changing the definition of spw 0). You might be able to get away with this depending on how you set things up but it's safest to apply the calibration table to a data set with the same set of spectral windows as were used to generate the table. | * The calibration tables know about spectral windows by their number. This means that you could potentially get yourself into trouble by splitting out a subset of the spectral windows (thus changing the definition of spw 0). You might be able to get away with this depending on how you set things up but it's safest to apply the calibration table to a data set with the same set of spectral windows as were used to generate the table. | ||
[[File: | [[File:Basic_line_selfcal_Caltech.py]] | ||
The alternative approach uses the spectral line itself to derive a calibration solution. The script above steps through this procedure using the brightest 5 channels around the CO line in NGC 3256. It does not treat things in a full spectral line way, instead focusing on this "slice" of line emission (with no continuum subtraction). To get a spectral line cube at the end you would need to add in the additional steps of continuum subtraction and use mode "velocity", "channel", or "frequency". Feel free to experiment with this. | The alternative approach uses the spectral line itself to derive a calibration solution. The script above steps through this procedure using the brightest 5 channels around the CO line in NGC 3256. It does not treat things in a full spectral line way, instead focusing on this "slice" of line emission (with no continuum subtraction). To get a spectral line cube at the end you would need to add in the additional steps of continuum subtraction and use mode "velocity", "channel", or "frequency". Feel free to experiment with this. |
Latest revision as of 07:38, 18 January 2012
This page steps through self-calibration of ALMA Science Verification data.
Acknowledgments: Wiki, tutorial and python scripts created by Adam Leroy, and slightly modified from the ALMA data reduction workshop in CV, Dec 2011) to suit the CASA Caltech workshop.
The goal of this session is to improve the image quality by carrying out self-calibration on ALMA Science Verification data. This page describes the data and introduces the scripts to do so. It is not a full-fledged CASA guide, only background for the hands on portion of the workshop.
Overview
Data Description
You will use the calibrated NGC 3256 Band 3 or TW Hydra Band 7 Science Verification data. To copy the necessary data to your local directory, do the following:
cd /scr[2]/casa/
tar -xvf /data/casa/alma/tar/TWHYA_BAND7_CalibratedData.tgz
If curious, the calibration steps that produced the datasets you will be using can be found here (and most likely you already went through one of these tutorials in a previous session):
Both contain several lines, including CO emission (1-0 for NGC 3256 and 3-2 for TW Hydra), and continuum emission. We will begin by imaging the continuum emission and using the resulting model to self calibrate the data. We will then see how to apply that self-calibration to improve the line emission images.
Basic Selfcal Approach
Assuming that you are comfortable with imaging, we suggest to grab the script above each section below, and use it to image NGC 3256 or TW Hydra (just uncomment/comment the relevant portions to apply the script to either data set). On each section, the script takes you through one iteration of self-calibration but the approach can be iterative, improving the model of the source as the corrected data become more and more accurate. The basic steps are:
- Use gaincal to derive the complex gain corrections to each antenna that best match the data to the model.
- When satisfied with these corrections, apply them to the data to create a new corrected data set.
- Image those data.
- Re-iterate, i.e. go back to step 1.
Once you are comfortable with the procedure, try iterating and perhaps adding an amplitude calibration to the selfcal. Your degrees of freedom in this process are the solution interval and how you otherwise combine the data (averaging polarizations, spectral windows or channels, using a specific field in a mosaic). Try experimenting with these settings to see how your results are affected. Your basic diagnostic is the plotting of solutions using plotcal but the amount of noise and the structure of the residuals in the final image can also be useful indicators.
Continuum Self Calibration
Create a working folder:
mkdir continuum_selfcal
cd continuum_selfcal/
Configure the following script to step you through a first phase self-calibration of either the TW Hydra Band 7 or NGC 3256 Band 3 data. Adjust the comments to use the data set that you like.
The script will create a first, basic image following the same procedure that you used to image in the previous sessions. You will then self-calibrate to create a better image. Some comments to bear in mind:
- Remember that each CASA Measurement Set has three columns: data, corrected, and model. Conceptually data are the raw u-v data, corrected data are the data corrected by some complex gain solution, and model represents the model visibility that should matched the data in the absence of noise, antenna-dependent complex gain terms, or other corruptions. A data column is required for every measurement set, corrected data appear as a result of applying a calibration via applycal (or copying the data column in a few cases), and model data are either read in or initialized via setjy or copied back into the measurement set during deconvolution by clean with the calready option turned on.
- You fill the model column with clean. This is done during the deconvolution, so you want to clean down to the point where you believe that the model you have built is still real but no further. gaincal will try derive solutions to match your data to whatever model you have in. So be sure that the model is real! (This is a potential danger of self-calibration.)
- Some additional viewer functionality may be useful here:
- One useful, but not perfect, diagnostic of your image quality is the RMS noise in the image. The viewer lets you find this easily. Grab one of the region defining tools that you use for making clean boxes (the rectangle is easiest) and drag out a portion of the image that contains no signal but is big enough to yield good statistics. After you have highlighted that region double click inside the region and have a look at the terminal. You should see a variety of statistics for the region, including the RMS deviation and a robust (median-based) analog. After you have made a self-calibrated image, you can repeat the measurement and compare the noise in the images. The ratio of peak intensity to RMS scatter off the source is often referred to as the "dynamic range" of the image.
- Once you have both a self-calibrated image and your original image it is interesting to compare them. To display them side by side open both as raster images with the viewer. Then click the 'Display Panel' pull-down and 'Panel Options'. Set number of panels in x to be two. Then click the radio button near the bottom of the viewer to 'blink' (rather than normal). You now see both at once.
- To set the two images on the same color scale click the wrench-shaped button and go to "Basic Settings". You can manually specify the min and the max intensity to be displayed in here. Note the tabs along the top that let you switch between images. In this way you can force the two images to shared color stretch and table to more fairly compare them.
- Keep a close eye on the terminal output during the gaincal call. You want to avoid having a lot of solutions fail (ideally you don't want any to fail). The main remediable reason that they will fail will be that you are not averaging enough data together to get a good solution (recall the S/N discussion during the lecture). Your easiest remedy here will be to increase the solution interval specified via the "solint" keyword. You can also consider averaging together polarizations by setting the "gaintype" keyword to "T" or allow averaging to cross spectral window or scan boundaries using the "combine=spw" or "combine=scan" parameters.
- plotcal gives you a more direct way to examine the self-calibration solution. Although slow, plotcal gives you a lot of options in how to display the data. "iteration" tells plotcal what parameter to use to trigger a new panel. So "iteration='spw'" means one spw in each panel. You could instead iterate over antenna. Whatever you are not iterating over (but has not been selected) gets tossed together into the panel. "subplot=431" tells it to make 4 rows and 3 columns. Use help to find more.
- Have a look at the amount of scatter in the phase solutions, the rapidity of their systematic variations, their overall amplitude, and the agreement among different ways of slicing the data. A lot of scatter may mean an unstable solution. Rapid but smooth variation may highlight the need for the shortest possible solution interval. High overall amplitudes in the corrections imply that the additional calibration really was necessary. And agreement among, e.g., different spectral windows, indicates that you might able to further average the data when deriving the solutions.
- If you're speeding along, we've included the workflow to perform a second iteration of self calibration (customized to NGC 3256) that corrects for amplitude variations. The syntax for gaincal and applycal can be a bit subtle here. The key fact to remember is that you have one "corrected" data column and applycal will overwrite that column.
- The gaincal call here applies the previous self-calibration on the fly. Then to apply the full, combined effect of both self calibrations you need to feed both tables in to applycal.
Continuum-to-Line Self Calibration
File:Line cont selfcal Caltech.py
Self-calibration can also be used to improve your spectral line imaging. You can do this by self-calibrating the line data set directly or by using deriving corrections for the continuum emission and then applying them to the data before imaging the line data. The script here shows an example of the procedure to apply a continuum-based self-calibration to line data, which are then separated out and imaged. It builds on the previous ("Basic_selfcal_Caltech.py") script, you need the calibration table from that script in hand so step through that one first. A few notes:
- The calibration tables know about spectral windows by their number. This means that you could potentially get yourself into trouble by splitting out a subset of the spectral windows (thus changing the definition of spw 0). You might be able to get away with this depending on how you set things up but it's safest to apply the calibration table to a data set with the same set of spectral windows as were used to generate the table.
File:Basic line selfcal Caltech.py
The alternative approach uses the spectral line itself to derive a calibration solution. The script above steps through this procedure using the brightest 5 channels around the CO line in NGC 3256. It does not treat things in a full spectral line way, instead focusing on this "slice" of line emission (with no continuum subtraction). To get a spectral line cube at the end you would need to add in the additional steps of continuum subtraction and use mode "velocity", "channel", or "frequency". Feel free to experiment with this.