AntennaeBand7 Imaging 6.5.4: Difference between revisions

From CASA Guides
Jump to navigationJump to search
 
(73 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Checked_6.5.4}}
{{Checked_6.5.4}}
{{CARTA_6.5.4}}


==Overview==
==Overview==
Line 8: Line 6:
*'''This guide is designed for CASA 6.5.4.  If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.
*'''This guide is designed for CASA 6.5.4.  If you are using an older version of CASA please see [[AntennaeBand7]] for earlier versions of this CASAguide.
-->
-->
{{CARTA_6.5.4}}


Details of these observations are provided at [[AntennaeBand7]]. This tutorial picks up where [[AntennaeBand7_Calibration]] leaves off, with fully calibrated measurement sets of the split out science target. If you wish to skip the Calibration guide, you may obtain the calibrated data ''Antennae_Band7_CalibratedData.tgz'' from [[AntennaeBand7#Obtaining_the_Data]]. Extract it and cd to the extracted directory:
Details of these observations are provided at [[AntennaeBand7]]. This tutorial picks up where [[AntennaeBand7_Calibration]] leaves off, with fully calibrated measurement sets of the split out science target. If you wish to skip the Calibration guide, you may obtain the calibrated data ''Antennae_Band7_CalibratedData.tgz'' from [[AntennaeBand7#Obtaining_the_Data]]. Extract it and cd to the extracted directory:


<source lang="bash">
<source lang="bash">
# in bash
# In bash
tar -xvzf Antennae_Band7_CalibratedData.tgz
tar -xvzf Antennae_Band7_CalibratedData.tgz
cd Antennae_Band7_CalibratedData
cd Antennae_Band7_CalibratedData
Line 34: Line 33:
== Imaging Mosaics ==
== Imaging Mosaics ==


<div style="background-color: #E0FFFF;">
<div style="background-color: #E0FFFF; padding: 10px; font-family: 'Consolas', monospace;>
If you are unfamiliar with the concepts of basic radio imaging and mosaicking, pause here and  
If you are unfamiliar with the concepts of basic radio imaging and mosaicking, pause here and  
review, for example, [http://www.aoc.nrao.edu/events/synthesis/2022/slides/siw2022_imaging_wilner.pdf Imaging Basics] and [http://www.aoc.nrao.edu/events/synthesis/2022/slides/bsmMosaicking2022.pdf Mosaicking] lectures from a Synthesis Imaging Workshop.
review, for example, [http://www.aoc.nrao.edu/events/synthesis/2022/slides/siw2022_imaging_wilner.pdf Imaging Basics] and [http://www.aoc.nrao.edu/events/synthesis/2022/slides/bsmMosaicking2022.pdf Mosaicking] lectures from a Synthesis Imaging Workshop.
Line 48: Line 47:
== Continuum Imaging ==
== Continuum Imaging ==


==== Determine Line-Free Channels ====
[[File:Antennae_North-AMPvsCH_6.1.png|300px|thumb|right|<caption>'''Fig. 1.''' Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]
[[File:Antennae_North-AMPvsCH_6.1.png|300px|thumb|right|<caption>'''Fig. 1.''' Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100</caption>]]
[[File:Antennae_South-AMPvsCH_6.1.png|300px|thumb|right|<caption>'''Fig. 2.''' Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]
[[File:Antennae_South-AMPvsCH_6.1.png|300px|thumb|right|<caption>'''Fig. 2.''' Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100</caption>]]
[[Image:Antennae_North.Cont.Dirty.image.File.Info.png|300px|thumb|right|<caption>'''Fig. 3.''' Northern continuum mosaic dirty image file info.</caption>]]
[[Image:Antennae_North.Cont.Dirty.image.CARTA.png|300px|thumb|right|<caption>'''Fig. 4.''' Northern continuum mosaic dirty image with full CARTA GUI. A rectangular region has been drawn near (but not including) the center of emission, and the RMS of the region is displayed in the Statistics widget. </caption>]]
[[File:Antennae_North.Cont.Clean.residual.tclean.png|300px|thumb|right|<caption>'''Fig. 5.''' Northern continuum mosaic residual after 30 iterations shown in the interactive tclean GUI; the clean mask is shown by the white contour.</caption>]]


We will make 345 GHz continuum images for the two regions. We use the task {{tclean_6.5.4}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (Figure 1), and from 70 to 100 in the northern mosaic (Figure 2).   
We will make 345 GHz continuum images for the two regions. We use the task {{tclean_6.5.4}} over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (Figure 1), and from 70 to 100 in the northern mosaic (Figure 2).   
Line 58: Line 55:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
import os
os.system('rm -rf Antennae_North-AMPvsCH.png')
os.system('rm -rf Antennae_North-AMPvsCH.png')
plotms(vis='Antennae_North.cal.ms', xaxis='channel', yaxis='amp',
plotms(vis='Antennae_North.cal.ms', xaxis='channel', yaxis='amp',
Line 71: Line 69:
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.
The '''avgtime''' is set to a large value so that it averages over all the integrations, and '''avgscan''' is set to allow averaging of the different scans.


Next we create continuum images from the line-free channels.  
Next we create continuum images from the line-free channels.


==== Northern Continuum Mosaic ====
==== Northern Continuum Mosaic ====
[[Image:Antennae_North.Cont.Dirty.image.File.Info.png|300px|thumb|right|<caption>'''Fig. 3.''' Northern continuum mosaic dirty image file info.</caption>]]
[[Image:Antennae_North.Cont.Dirty.image.CARTA.png|300px|thumb|right|<caption>'''Fig. 4.''' Northern continuum mosaic dirty image with full CARTA GUI. A rectangular region has been drawn near (but not including) the center of emission, and the RMS of the region is displayed in the Statistics widget. </caption>]]
[[File:Antennae_North.Cont.Clean.residual.tclean.png|300px|thumb|right|<caption>'''Fig. 5.''' Northern continuum mosaic residual after 30 iterations shown in the interactive tclean GUI; the clean mask is shown by the white contour.</caption>]]


For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''.  
For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a '''cell''' size of 0.2" to oversample the beam by a factor of 5. The '''imsize''' needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the [[AntennaeBand7#ALMA_Data_Overview | Overview]], we can see that the Northern mosaic '''imsize''' needs to be about 1 arcmin. With 0.2" pixels, this requires '''imsize=300'''.  
Line 98: Line 100:
<source lang="python">
<source lang="python">
# In CASA
# In CASA
os.system('rm -rf Antennae_North.Cont.Dirty*')
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:
    rmtables('Antennae_North.Cont.Dirty'+ext)
 
tclean(vis='Antennae_North.cal.ms', imagename='Antennae_North.Cont.Dirty',
tclean(vis='Antennae_North.cal.ms', imagename='Antennae_North.Cont.Dirty',
       field='', phasecenter=12,
       field='', phasecenter=12,
Line 113: Line 117:


<source lang="bash">
<source lang="bash">
# in terminal
# In bash
carta --no_browser
carta --no_browser
</source>
</source>
Line 121: Line 125:
Yes, there is definitely a detection in the vicinity of the Northern nucleus. Draw a region near (but not including) the center and open the Statistics widget. The rms noise is about 0.5 mJy/beam in the dirty image (see Fig 4).
Yes, there is definitely a detection in the vicinity of the Northern nucleus. Draw a region near (but not including) the center and open the Statistics widget. The rms noise is about 0.5 mJy/beam in the dirty image (see Fig 4).


Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI. See [[TWHydraBand7_Imaging_3.4#Image_and_Self-Calibrate_the_Continuum]] for a more complete description of interactive clean and mask creation.  
Next we switch to refined values of '''cell='0.13arcsec' ''' and '''imsize=500''' based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI.


*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''
*'''niter=1000''': Maximum number of clean iterations -- '''we will stop interactively'''
Line 143: Line 147:
</source>
</source>


<div style="background-color: #E0FFFF;">
<div style="background-color: #E0FFFF; padding: 10px; font-family: 'Consolas', monospace;>
 
 
If you get an error using {{rmtables_6.5.4}} similar to "Cannot delete file <filename> because table is still open in this process," you may need to close CASA and/or CARTA to unlock the files.
If you get an error using {{rmtables_6.5.4}} similar to "Cannot delete file <filename> because table is still open in this process," you may need to close CASA and/or CARTA to unlock the files.
</div>
</div>


The residuals are "noise-like" after only ~30 iterations (see Figure 5), so hit the red X symbol in the interactive window to stop cleaning here.  
Click the green circular arrow to start a major cycle. The residuals are "noise-like" after only 1 major cycle of ~30 iterations (minor cycles) (see Figure 5), so hit the red X symbol in the interactive window to stop cleaning here.  


Note that if you run the {{tclean_6.5.4}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean_6.5.4}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean_6.5.4}} command to guard against this, but sometimes this is what you want.
Note that if you run the {{tclean_6.5.4}} task again with the same '''imagename''', without deleting the existing <imagename>.* files, {{tclean_6.5.4}} assumes that you want to continue cleaning the existing images. We put an <tt>rm</tt> command before the {{tclean_6.5.4}} command to guard against this, but sometimes this is what you want.
Line 181: Line 182:
<br clear="all">
<br clear="all">


==== Image Statistics ====
==== Continuum Image Statistics ====


[[File:Antennae_North.Cont.Clean.image.rms.polygon.png|400px|thumb|right|<caption>'''Fig. 5.''' Example polygon for rms determination using CARTA. Here we measure an rms of 0.48 mJy/beam, slightly different from what imstat reports.</caption>]]
[[File:Antennae_North.Cont.Clean.image.rms.polygon.png|400px|thumb|right|<caption>'''Fig. 5.''' Example polygon for rms determination using CARTA. Here we measure an rms of 0.48 mJy/beam, slightly different from what imstat reports.</caption>]]
Line 243: Line 244:


== CO(3-2) Imaging ==
== CO(3-2) Imaging ==
==== Choose Frame and Velocity Channels ====


[[Image:North_CO3_2_vel_6.1.png|thumb|<caption>'''Fig. 8.''' Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]
[[Image:North_CO3_2_vel_6.1.png|thumb|<caption>'''Fig. 8.''' Northern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]
[[Image:South_CO3_2_vel_6.1.png|thumb|<caption>'''Fig. 9.''' Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]
[[Image:South_CO3_2_vel_6.1.png|thumb|<caption>'''Fig. 9.''' Southern CO(3-2) uv-spectrum in LSRK velocity space.</caption>]]


Line 280: Line 282:
<br clear="all">
<br clear="all">


==== Northern Mosaic ====
==== Northern Mosaic Cube ====


Similar to continuum, it is very important that you make a clean mask. For this example we will create a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. <!--You can choose to use and edit the provided mask or create your own mask.-->
Similar to continuum, it is very important that you make a clean mask. For this example we will create a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel. <!--You can choose to use and edit the provided mask or create your own mask.-->


[[Image:North_interact_6.1.png|300px|thumb|right|<caption>'''Fig. 10.''' Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]
[[Image:North_interact_6.1.png|300px|thumb|right|<caption>'''Fig. 10.''' Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]
[[Image:Antennae_North.CO3_2Line.Clean.image.png|300px|thumb|right|<caption>'''Fig. 11.''' Viewing the cleaned cube in CARTA at the 1650 km/s channel.</caption>]]
[[Image:Antennae_North.CO3_2Line.Clean.image.png|300px|thumb|right|<caption>'''Fig. 11.''' Viewing the cleaned cube in CARTA at the 1650 km/s channel.</caption>]]


Notable parameters included in the {{tclean_6.5.4}} call are:
Notable parameters included in the {{tclean_6.5.4}} call are:
*'''specmode='cube'''', '''outframe='LSRK'''', '''restfreq='345.79599GHz''''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.
*'''specmode='cube'''', '''outframe='LSRK'''', '''restfreq='345.79599GHz''''. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.
*'''nchan=50''', '''start='1300km/s'''', '''width='10km/s'''': To produce a data cube with 50 channels, starting at 1300 km/s, and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.
*'''nchan=70''', '''start='1200km/s'''', '''width='10km/s'''': To produce a data cube with 70 channels, starting at 1200 km/s, and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.
*'''imsize=500''', '''cell='0.13arcsec'''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic.  
*'''imsize=500''', '''cell='0.13arcsec'''': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic.  
*'''weighting='briggsbwtaper'''', '''robust=0.5''': Weighting to apply to visibilities. Weighting has been changed to 'briggsbwtaper'. This is a new weighting scheme available starting in CASA 6.2. See [https://casadocs.readthedocs.io/en/stable/notebooks/synthesis_imaging.html#Imaging-Algorithms Imaging Algorithms] for more information. We use robustness parameter 0.5 (in between natural and uniform weighting).
*'''weighting='briggsbwtaper'''', '''robust=0.5''': Weighting to apply to visibilities. Weighting has been changed to 'briggsbwtaper'. This is a new weighting scheme available starting in CASA 6.2. See [https://casadocs.readthedocs.io/en/stable/notebooks/synthesis_imaging.html#Imaging-Algorithms Imaging Algorithms] for more information. We use robustness parameter 0.5 (in between natural and uniform weighting).
Line 303: Line 304:
     rmtables('Antennae_North.CO3_2Line.Clean'+ext)
     rmtables('Antennae_North.CO3_2Line.Clean'+ext)


tclean(vis='Antennae_North.cal.ms.contsub',
tclean(vis='Antennae_North.cal.ms.contsub', datacolumn='data',
       imagename='Antennae_North.CO3_2Line.Clean',
       imagename='Antennae_North.CO3_2Line.Clean',
       spw='0', field='', phasecenter=12,
       spw='0', field='', phasecenter=12,
       specmode='cube', outframe='LSRK', restfreq='345.79599GHz',
       specmode='cube', outframe='LSRK', restfreq='345.79599GHz',
       nchan=50, start='1300km/s', width='10km/s',
       nchan=70, start='1200km/s', width='10km/s',
       gridder='mosaic', mosweight=True,
       gridder='mosaic', mosweight=True,
       deconvolver='hogbom',
       deconvolver='hogbom',
Line 324: Line 325:
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact.  
Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact.  


Stop cleaning after about ~7000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level.  
Stop cleaning after ~5000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level.  


Inspect the resulting data cube in CARTA (Fig 11): 'Antennae_North.CO3_2Line.Clean.image'
Inspect the resulting data cube in CARTA (Fig 11):<br />
''Antennae_North.CO3_2Line.Clean.image''


<br clear="all">
<br clear="all">


==== Southern Mosaic ====
==== Southern Mosaic Cube ====


[[Image:South_interact.png|300px|thumb|right|<caption>'''Fig. 12.''' Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]
[[Image:South_interact.png|300px|thumb|right|<caption>'''Fig. 12.''' Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]
[[Image:Antennae_South.CO3_2Line.Clean.image.png|300px|thumb|right|<caption>'''Fig. 13.''' Viewing the cleaned cube in CARTA at the 1650 km/s channel.</caption>]]
[[Image:Antennae_South.CO3_2Line.Clean.image.png|300px|thumb|right|<caption>'''Fig. 13.''' Viewing the cleaned cube in CARTA at the 1650 km/s channel.</caption>]]


Line 343: Line 344:
     rmtables('Antennae_South.CO3_2Line.Clean'+ext)
     rmtables('Antennae_South.CO3_2Line.Clean'+ext)


tclean(vis='Antennae_South.cal.ms.contsub',
tclean(vis='Antennae_South.cal.ms.contsub', datacolumn='data',
       imagename='Antennae_South.CO3_2Line.Clean',
       imagename='Antennae_South.CO3_2Line.Clean',
       spw='0', field='', phasecenter=15,
       spw='0', field='', phasecenter=15,
       specmode='cube', outframe='LSRK', restfreq='345.79599GHz',
       specmode='cube', outframe='LSRK', restfreq='345.79599GHz',
       nchan=50, start='1300km/s', width='10km/s',
       nchan=70, start='1200km/s', width='10km/s',
       gridder='mosaic', deconvolver='hogbom',
       gridder='mosaic', mosweight=True, deconvolver='hogbom',
       imsize=750, cell='0.13arcsec', pblimit=0.2,
       imsize=750, cell='0.13arcsec', pblimit=0.2,
       restoringbeam='common',
       restoringbeam='common',
Line 357: Line 358:
</source>
</source>


Clean about 8,000 iterations before stopping. Inspect the resulting data cube in CARTA (Fig 13): 'Antennae_South.CO3_2Line.Clean.image'
Clean until the residuals become noise-like, ~17000 iterations before stopping. Inspect the resulting data cube in CARTA (Fig 13):<br />
''Antennae_South.CO3_2Line.Clean.image''
 
<br clear="all">
 
==== Cube Statistics ====


For each mosaic, in CARTA, draw regions in both a line-free channel and the channel with the strongest emission, and evaluate using the Statistics widget.
For each mosaic, in CARTA, draw regions in both a line-free channel and the channel with the strongest emission, and evaluate using the Statistics widget.
Line 367: Line 373:
<br clear="all">
<br clear="all">


== Self Calibration ==  
== Self Calibration ==
 
==== Strategy ====


Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean_6.5.4}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if '''savemodel='modelcolumn''''. This model can be used to self-calibrate the data using {{gaincal_6.5.4}}. That is why it is important to make the model as good as you can by making clean masks.       
Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When {{tclean_6.5.4}} is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if '''savemodel='modelcolumn''''. This model can be used to self-calibrate the data using {{gaincal_6.5.4}}. That is why it is important to make the model as good as you can by making clean masks.       
Line 377: Line 385:
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.
We will also use '''gaintype='T'''' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.


==== Northern Mosaic ====
==== Northern Mosaic Selfcal and Cube Image ====


[[Image:north_selfchan_6.1.png|300px|thumb|right|<caption>'''Fig. 12.''' Plot of the CO(3-2) emission from the DATA column of field 12 of the Northern mosaic.</caption>]]
[[Image:north_selfchan_6.1.png|300px|thumb|right|<caption>'''Fig. 12.''' Plot of the CO(3-2) emission from the DATA column of field 12 of the Northern mosaic.</caption>]]
[[Image:North_selfchan_model_6.5.4.png|300px|thumb|right|<caption>'''Fig. 13.''' Plot of the CO(3-2) emission from the MODEL column of field 12 of the northern mosaic.</caption>]]
[[Image:North_selfchan_model_6.5.4.png|300px|thumb|right|<caption>'''Fig. 13.''' Plot of the CO(3-2) emission from the MODEL column of field 12 of the Northern mosaic.</caption>]]


The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12''''. Below we make a uv-plot of the spectral line emission from this field to choose only the strongest channels to include in the self-calibration.  ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.''  This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean.  This plot shows the channel range of the uv data.
The strongest emission in the Northern mosaic comes from the center pointing, already identified above as '''field='12''''. Below we make a uv-plot of the spectral line emission from this field to choose only the strongest channels to include in the self-calibration.  ''It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube.''  This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean.  This plot shows the channel range of the uv data.
Line 400: Line 408:
</source>
</source>


You will notice that while the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 1 elsewhere. When {{tclean_6.5.4}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel='modelcolumn'''' in the {{tclean_6.5.4}} call, the default model was replaced ''only where {{tclean_6.5.4}} had a model to replace it with'', namely, over the channels we imaged. In the future, CASA will set a flag to let users know that these model points are not valid for the updated model. In our case, we will perform self-calibration only on those channels with significant signal in the line emission, omitting the rest of the channels.
While the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 0 elsewhere by default. We will perform self-calibration only on the channels we imaged in the first cube, with significant signal in the line emission.
 
<!-- When {{tclean_6.5.4}} initializes a model, it defaults to an amplitude of 1 and phase 0 (i.e., a point source with an amplitude of 1 in the center of the image). When we set '''savemodel='modelcolumn'''' in the {{tclean_6.5.4}} call, the default model was replaced ''only where {{tclean_6.5.4}} had a model to replace it with'', namely, over the channels we imaged. In the future, CASA will set a flag to let users know that these model points are not valid for the updated model. -->
Next remind ourselves of the timing of the various observations.


Next, we remind ourselves of the timing of the various observations. Examine the {{listobs_6.5.4}} output, ''Antennae_North.cal.listobs.txt''. Each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.
<!--
<source lang="python">
<source lang="python">
# In CASA
# In CASA
Line 410: Line 419:
</source>
</source>


Zooming in on each dataset we see that they are about 1 hour long (you can also check the {{listobs_6.5.4}} output), and that each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set '''solint='3600s'''' to get one solution per dataset.
Zooming in on each dataset we see that they are about 1 hour long. The second and third observations are very close in time, while the first and fourth are several days apart.
 
-->
[[Image:north_pcal1_phase_6.1.png|300px|thumb|right|<caption>'''Fig. 14.''' Phase-only self-calibration solutions for the Northern mosaic.</caption>]]
[[Image:north_pcal1_phase_6.1.png|300px|thumb|right|<caption>'''Fig. 14.''' Phase-only self-calibration solutions for the Northern mosaic.</caption>]]


Line 440: Line 449:
</source>
</source>


Re-image the data with the selfcal applied. Remember that {{tclean_6.5.4}} always uses the corrected data column if it exists:
Re-image the data with the selfcal applied. Remember that {{tclean_6.5.4}} uses the corrected data column by default if it exists. We will start with the same mask that we ended with before.


[[Image:North_interact2.png|300px|thumb|right|<caption>'''Fig. 15.''' Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.</caption>]]
[[Image:North_interact2.png|300px|thumb|right|<caption>'''Fig. 15.''' Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before editing the previous mask.</caption>]]


<source lang="python">
<source lang="python">
# In CASA
# In CASA
os.system('rm -rf Antennae_North.CO3_2Line.Clean.pcal1*')
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:
tclean(vis='Antennae_North.cal.ms.contsub',
    rmtables('Antennae_North.CO3_2Line.Clean.pcal1'+ext)
 
tclean(vis='Antennae_North.cal.ms.contsub', datacolumn='corrected',
       imagename='Antennae_North.CO3_2Line.Clean.pcal1',
       imagename='Antennae_North.CO3_2Line.Clean.pcal1',
       spw='0', field='', phasecenter=12,
       spw='0', field='', phasecenter=12,
       specmode='cube', outframe='LSRK', restfreq='345.79599GHz',
       specmode='cube', outframe='LSRK', restfreq='345.79599GHz',
       nchan=70, start='1200km/s', width='10km/s',
       nchan=70, start='1200km/s', width='10km/s',
       gridder='mosaic', mosweight=True, deconvolver='hogbom',
       gridder='mosaic', mosweight=True,
      deconvolver='hogbom',
       imsize=500, cell='0.13arcsec', pblimit=0.2,
       imsize=500, cell='0.13arcsec', pblimit=0.2,
       restoringbeam='common',
       restoringbeam='common',
Line 461: Line 473:
</source>
</source>


After 3000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop after 9,000 or so iterations.
After each major cycle, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop when the residuals become noise like, after ~5000 iterations.


Compare the original and self-calibrated images in CARTA to determine if there has been improvement:
Compare the original and self-calibrated images in CARTA to determine if there has been improvement:<br />
'Antennae_North.CO3_2Line.Clean.image'
''Antennae_North.CO3_2Line.Clean.image''<br />
'Antennae_North.CO3_2Line.Clean.pcal1.image'
''Antennae_North.CO3_2Line.Clean.pcal1.image''


[[Image:Antennae_North_selfcal_compare_6.5.4.png|500px|thumb|right|<caption>'''Fig. 16.''' Comparison of the 1650 km/s channel before selfcal (left) and after selfcal (right).</caption>]]
<!--
<!--
old imview stuff
old imview stuff
Line 473: Line 486:
-->
-->


Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images".  Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator.
The images may look quite similar at first. Examining the image statistics, the peak flux density should have increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms.  
To make the figure shown in Figure 16, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.
 
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel.
 
What you should notice is that the peak flux density has increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms.  


Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement.  
Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement.  


<!--
[[Image:north_ch43compare.png|600px|thumb|center|<caption>'''Fig. 16.''' Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]
[[Image:north_ch43compare.png|600px|thumb|center|<caption>'''Fig. 16.''' Comparison of channel 43 before selfcal (left) and after selfcal (right).</caption>]]


<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;">
Then in the viewer, activate the Animator Images sub-panel by clicking the check box next to "Images".  Then use the tape deck controls to cycle between the two images. To change the channel use the Channels sub-panel in the Animator.
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy_6.5.4}} during the calibration process, you will see an increase of approximately 25% in the peak flux density (in channel 43).
To make the figure shown in Figure 16, cycle to channel 43. Then you can select the "p wrench" icon and change the number of panels in x to 2. You will need to drag your viewer window rather wide to get both panels to fit well. If you want to compare other channels, you can use the tapedeck to move to the new channel of interest and see the changes in both cubes.
 
To compare the statistics for each image, click the "Next" button in the "Statistics" tab of the "Region" sub-panel.
-->
<div style="background-color: #E0FFFF; padding: 10px; font-family: 'Consolas', monospace;>
If you used '''standard='Butler-JPL-Horizons 2012'''' when running {{setjy_6.5.4}} during the calibration process, you may see an increase of approximately 20% in the peak flux density of bright channels.
</div>
</div>
<br clear="all">


==== Southern Mosaic ====
==== Southern Mosaic Selfcal and Cube Image ====


[[Image:south_selfchan_6.1.png|300px|thumb|right|<caption>'''Fig. 17.''' Plot of the CO(3-2) emission from the DATA column for Field 7 of the Southern mosaic.</caption>]]
[[Image:south_selfchan_6.1.png|300px|thumb|right|<caption>'''Fig. 17.''' Plot of the CO(3-2) emission from the DATA column for Field 7 of the Southern mosaic.</caption>]]
[[Image:South_selfchan_model_6.5.4.png|300px|thumb|right|<caption>'''Fig. 18.''' Plot of the CO(3-2) emission from the MODEL column for Field 7 of the Southern mosaic.</caption>]]


[[Image:South_selfchan_model.png|300px|thumb|right|<caption>'''Fig. 18.''' Plot of the CO(3-2) emission from the MODEL column for Field 7 of the Southern mosaic.</caption>]]
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward Field 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of Field IDs after the final calibration split, this becomes Field 7.  
 
Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward field id 11 in the [[AntennaeBand7#Science_Target_Overview | Overview]]. Adjusting for the renumbering of field ids after the final calibration split, this becomes field='7'.  


From the following plots we can assess the brightest channels to pick and see that the timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour.
From the plots of data and model amplitude, we can assess the brightest channels to selfcal and image:


<source lang="python">
<source lang="python">
Line 502: Line 516:
plotms(vis='Antennae_South.cal.ms.contsub', spw='', xaxis='channel', yaxis='amp',
plotms(vis='Antennae_South.cal.ms.contsub', spw='', xaxis='channel', yaxis='amp',
       field='7', avgtime='1e8', avgscan=True, ydatacolumn='data',
       field='7', avgtime='1e8', avgscan=True, ydatacolumn='data',
       plotfile='South_selfchan_data.png', showgui=True)
       plotfile='South_selfchan_data.png', height=800, width=1000, overwrite=True, showgui=True)
</source>
</source>


Line 509: Line 523:
plotms(vis='Antennae_South.cal.ms.contsub', spw='', xaxis='channel', yaxis='amp',
plotms(vis='Antennae_South.cal.ms.contsub', spw='', xaxis='channel', yaxis='amp',
       field='7', avgtime='1e8', avgscan=True, ydatacolumn='model',
       field='7', avgtime='1e8', avgscan=True, ydatacolumn='model',
       plotfile='South_selfchan_model.png', showgui=True)
       plotfile='South_selfchan_model.png', height=800, width=1000, overwrite=True, showgui=True)
</source>
</source>


Examine the {{listobs_6.5.4}} output, ''Antennae_South.cal.listobs.txt''. The timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour.
<!--
<source lang="python">
<source lang="python">
# In CASA
# In CASA
Line 517: Line 533:
       avgchannel='167', avgscan=True, coloraxis='scan', ydatacolumn='data', showgui=True)
       avgchannel='167', avgscan=True, coloraxis='scan', ydatacolumn='data', showgui=True)
</source>
</source>
-->
[[Image:south_pcal1_phase_6.1.png|300px|thumb|right|<caption>'''Fig. 19.''' Phase-only self-calibration solutions for the Southern mosaic.</caption>]]


[[Image:south_pcal1_phase_6.1.png|300px|thumb|right|<caption>'''Fig. 19.''' Phase-only self-calibration solutions for the Southern mosaic.</caption>]]
Solve for the self-calibration phase corrections:


<source lang="python">
<source lang="python">
Line 527: Line 545:
         calmode='p', minsnr=2)
         calmode='p', minsnr=2)
</source>
</source>
Plot the selfcal solutions:


<source lang="python">
<source lang="python">
Line 534: Line 554:
         iteraxis='antenna', gridrows=5, gridcols=3, plotrange=[0,0,-80,80],
         iteraxis='antenna', gridrows=5, gridcols=3, plotrange=[0,0,-80,80],
         plotfile='south_pcal1_phase.png', showgui=True)
         plotfile='south_pcal1_phase.png', showgui=True)
</source>


</source>
Apply the solutions:


<source lang="python">
<source lang="python">
Line 544: Line 565:


[[Image:South_interact2.png|300px|thumb|right|<caption>'''Fig. 20.''' Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]
[[Image:South_interact2.png|300px|thumb|right|<caption>'''Fig. 20.''' Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.</caption>]]
Clean a new cube using the newly corrected data. We will start with the South mosaic mask from before selfcal, and don't forget to select All Channels if modifying the mask:


<source lang="python">
<source lang="python">
# In CASA
# In CASA
os.system('rm -rf Antennae_South.CO3_2Line.Clean.pcal1*')
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:
tclean(vis='Antennae_South.cal.ms.contsub',
    rmtables('Antennae_South.CO3_2Line.Clean.pcal1'+ext)
 
tclean(vis='Antennae_South.cal.ms.contsub', datacolumn='corrected',
       imagename='Antennae_South.CO3_2Line.Clean.pcal1',
       imagename='Antennae_South.CO3_2Line.Clean.pcal1',
       spw='0', field='', phasecenter=15,
       spw='0', field='', phasecenter=15,
Line 562: Line 587:
</source>
</source>


After 4000 iterations or so, inspect each channel to see if there is more emission that needs to be included in the mask. Stop after 25,000 or so iterations.
After each major cycle, inspect each channel to see if there is more emission that needs to be included in the mask. Stop when the residuals become noise-like, after ~20000 iterations.


As for the Southern mosaic, you can compare the before and after self-cal images in CARTA (look, for example, at channel 31):
Compare the before and after selfcal images in CARTA, and examine the rms and peak flux density of a couple bright channels:<br />
'Antennae_South.CO3_2Line.Clean.image',
''Antennae_South.CO3_2Line.Clean.image''<br />
'Antennae_South.CO3_2Line.Clean.pcal1.image'
''Antennae_South.CO3_2Line.Clean.pcal1.image''


<!--
<!--
Line 575: Line 600:
-->
-->


[[Image:South_ch31compare.png|600px|thumb|center|<caption>'''Fig. 21.''' Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]
[[Image:Antennae_South_selfcal_compare_6.5.4.png|500px|thumb|right|<caption>'''Fig. 21.''' Comparison of the 1500 km/s channel before selfcal (left) and after selfcal (right).</caption>]]


<div class="noprint" style="float:none; border:0px solid blue;background-color:#F6CEF5;padding:2px;">
<!--
If you used '''standard='Butler-JPL-Horizons 2012' ''' when running {{setjy_6.5.4}} during the calibration process, you will see an increase of approximately 24% in the peak flux density (in channel 31).
[[Image:South_ch31compare.png|600px|thumb|right|<caption>'''Fig. 21.''' Comparison of channel 31 before selfcal (left) and after selfcal (right).</caption>]]
-->
<div style="background-color: #E0FFFF; padding: 10px; font-family: 'Consolas', monospace;>
If you used '''standard='Butler-JPL-Horizons 2012'''' when running {{setjy_6.5.4}} during the calibration process, you may see an increase of 20% or greater in the peak flux density of bright channels.
</div>
</div>
<br clear="all">


== Image Analysis ==
== Image Analysis ==
Line 585: Line 614:
==== Moment Maps ====
==== Moment Maps ====


[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.contours.png|400px|thumb|right|<caption>'''Fig. 22.''' Northern mosaic 1650 km/s channel overlaid with 3*sigma = 12.0 mJy contours.</caption>]]
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.contours.png|400px|thumb|right|<caption>'''Fig. 23.''' Southern mosaic 1440 km/s channel overlaid with 3*sigma = 10.5 mJy contours.</caption>]]


[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom0_6.1.png|200px|thumb|right|<caption>'''Fig. 22.''' The CO(3-2) integrated intensity map (moment 0)  of the Northern mosaic.</caption>]]
Next we will make moment maps for the CO(3-2) emission.
<pre>
Moment 0 = integrated intensity
Moment 1 = intensity weighted velocity field
Moment 2 = intensity weighted velocity dispersion
</pre>


Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to overly the cubes with 3-sigma contours, sigma corresponding to the line-free rms (North ~ 4.0 mJy/beam, South ~ 3.5 mJy/beam).<br /> Open the cubes in CARTA:<br />
''Antennae_North.CO3_2Line.Clean.pcal1.image''<br />
''Antennae_South.CO3_2Line.Clean.pcal1.image''


[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord_6.1.png|200px|thumb|right|<caption>'''Fig. 23.''' The CO(3-2) velocity field (moment 1) of the Northern mosaic.</caption>]]
Open the Contour tool, choose a cube from the "Data source" drop-down, and enter the value of 3*sigma for that cube into the "Levels" box. Click Apply. You can also change the color and thickness of contours in the Styling tab. Now page through the channels to see which contain obvious contours. For North, we find a channel range for significant emission of 35~60. For South, we find a channel range for significant emission of 13~62.


 
For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord_6.1.png|200px|thumb|right|<caption>'''Fig. 24.''' The CO(3-2) velocity dispersion (moment 2) of the Northern mosaic.</caption>]]
 
 
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom0_6.1.png|200px|thumb|right|<caption>'''Fig. 25.''' The CO(3-2) integrated intensity map (moment 0) of the Southern mosaic.</caption>]]
 
 
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord_6.1.png|200px|thumb|right|<caption>'''Fig. 26.''' The CO(3-2) velocity field (moment 1) of the Southern mosaic.</caption>]]
 
 
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord_6.1.png|200px|thumb|right|<caption>'''Fig. 27.''' The CO(3-2) velocity dispersion (moment 2) of the Southern mosaic.</caption>]]
 
 
Next we will make moment maps for the CO(3-2) emission: Moment 0 is the integrated intensity; Moment 1 is the intensity weighted velocity field; and Moment 2 is the intensity weighted velocity dispersion.
 
Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to open the cube in the viewer overlaid with 3-sigma contours, with sigma corresponding to the line-free rms.  


<source lang="python">
<source lang="python">
# In CASA
# In CASA
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',
rmtables('Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')
      'range': [-0.04,0.4]},
 
      contour={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image',
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image',  
      'levels': [0.004],'unit': 5})
          moments=[0], chans='35~60',
          outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')
</source>
</source>


We find a channel range for significant emission of 33~63.
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well (North ~ 14 mJy/beam, South ~ 4 mJy/beam). We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments_6.5.4}} appends the appropriate file name suffix to the value of '''outfile'''.


<source lang="python">
<source lang="python">
# In CASA
# In CASA
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',
for ext in ['.weighted_coord','.weighted_dispersion_coord']:
      'range': [-0.04,0.4]},
    rmtables('Antennae_North.CO3_2Line.Clean.pcal1.image.mom'+ext)
      contour={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image',
 
      'levels': [0.0035],'unit': 5})
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image',
          moments=[1,2], chans='35~60',
          mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.014*3',
          outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')
</source>
</source>


We find a channel range for significant emission of  12~64.
Open your North moment maps in CARTA and export to .png (Figure 24):<br />
''Antennae_North.CO3_2Line.Clean.pcal1.image.mom0''<br />
''Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord''<br />
''Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord''<br />


For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.
[[Image:Antennae_North.CO3_2Line.Clean.pcal1.image.moments.png|700px|thumb|center|<caption>'''Fig. 24.''' Northern mosaic moments 0, 1, and 2.</caption>]]


<source lang="python">
<source lang="python">
# In CASA
# In CASA
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image',
rmtables('Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')
          moments=[0],chans='33~63',
          outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')
</source>


<source lang="python">
# In CASA
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',
           moments=[0], chans='12~64',  
           moments=[0], chans='13~62',  
           outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')
           outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')
</source>
</source>
For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well. We do this with the '''mask''' parameter in the commands below. When making multiple moments, {{immoments_6.5.4}} appends the appropriate file name suffix to the value of '''outfile'''.


<source lang="python">
<source lang="python">
# In CASA
# In CASA
immoments('Antennae_North.CO3_2Line.Clean.pcal1.image',
for ext in ['.weighted_coord','.weighted_dispersion_coord']:
          moments=[1,2], chans='33~63',  
    rmtables('Antennae_South.CO3_2Line.Clean.pcal1.image.mom'+ext)
          mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.018*3',
          outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')
</source>


<source lang="python">
# In CASA
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',  
immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',  
           moments=[1,2], chans='12~64',
           moments=[1,2], chans='13~62',
           mask=' Antennae_South.CO3_2Line.Clean.pcal1.image>0.009*3',
           mask='Antennae_South.CO3_2Line.Clean.pcal1.image>0.004*3',
           outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')
           outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')
</source>
</source>


Next we can create the six moment maps
Open your South moment maps in CARTA and export to .png (Figure 25):<br />
(Figures 23, 24, 25, 26, and 27)
''Antennae_South.CO3_2Line.Clean.pcal1.image.mom0''<br />
from these images using '''imview'''.
''Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord''<br />
 
''Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord''
<source lang="python">
# In CASA
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',
                'colorwedge':True,'scaling': -0.5},
        zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.png')
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',
                'colorwedge':True},
        zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')
 
os.system('rm -f Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')
imview(raster={'file': 'Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',
                'colorwedge':True},
        zoom=1,out='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')
 
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',
                'colorwedge':True,'scaling': -0.5},
        zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.png')
os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',
                'colorwedge':True},
        zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.png')


os.system('rm -f Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')
[[Image:Antennae_South.CO3_2Line.Clean.pcal1.image.moments.png|700px|thumb|center|<caption>'''Fig. 25.''' Southern mosaic moments 0, 1, and 2.</caption>]]
imview(raster={'file': 'Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',
                'colorwedge':True},
        zoom=1,out='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.png')
</source>


==== Exporting Images to Fits ====
==== Exporting Images to Fits ====
Line 706: Line 695:
# In CASA
# In CASA
exportfits(imagename='Antennae_North.Cont.Clean.image',
exportfits(imagename='Antennae_North.Cont.Clean.image',
     fitsimage='Antennae_North.Cont.Clean.image.fits')
     fitsimage='Antennae_North.Cont.Clean.image.fits', overwrite=True)
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits')
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits', overwrite=True)
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits')
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits', overwrite=True)
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits', overwrite=True)
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits', overwrite=True)
</source>
</source>


Line 720: Line 709:
# In CASA
# In CASA
exportfits(imagename='Antennae_South.Cont.Clean.image',
exportfits(imagename='Antennae_South.Cont.Clean.image',
     fitsimage='Antennae_South.Cont.Clean.image.fits')
     fitsimage='Antennae_South.Cont.Clean.image.fits', overwrite=True)
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits')
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits', overwrite=True)
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits')
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits', overwrite=True)
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits')
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits', overwrite=True)
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits')
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits', overwrite=True)
</source>
</source>


Line 735: Line 724:
==Comparison with previous SMA CO(3-2) data==
==Comparison with previous SMA CO(3-2) data==


We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). Figure 28 shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{viewer}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.
We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). Figure 28 shows a comparison plot between the moment 0 maps of ALMA and SMA data using the {{imview_6.5.4}}. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.





Latest revision as of 19:29, 29 February 2024

Last checked on CASA Version 6.5.4

Overview

This guide features CARTA, the “Cube Analysis and Rendering Tool for Astronomy,” which is the new NRAO visualization tool for images and cubes. The CASA viewer (imview) has not been maintained for a few years and will be removed from future versions of CASA. We strongly recommend using CARTA, as it provides a much more efficient, stable, and feature rich user experience. A comparison of the CASA viewer and CARTA, as well as instructions on how to use CARTA at NRAO, is provided in the CARTA section of the CASA docs.

Details of these observations are provided at AntennaeBand7. This tutorial picks up where AntennaeBand7_Calibration leaves off, with fully calibrated measurement sets of the split out science target. If you wish to skip the Calibration guide, you may obtain the calibrated data Antennae_Band7_CalibratedData.tgz from AntennaeBand7#Obtaining_the_Data. Extract it and cd to the extracted directory:

# In bash
tar -xvzf Antennae_Band7_CalibratedData.tgz
cd Antennae_Band7_CalibratedData

Confirm your version of CASA

This guide has been written for CASA release 6.5.4-9. Please confirm your version before proceeding.

# In CASA
import casalith
version = casalith.version_string()
print ("You are using {}".format(version))
if (version < '6.5.4'):
    print ("YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE.")
    print ("PLEASE UPDATE IT BEFORE PROCEEDING.")
else:
    print ("Your version of CASA is appropriate for this guide.")

Imaging Mosaics

If you are unfamiliar with the concepts of basic radio imaging and mosaicking, pause here and review, for example, Imaging Basics and Mosaicking lectures from a Synthesis Imaging Workshop.

Mosaics like other kinds of images are created in the CASA task tclean. To invoke mosaic mode, you simply set the parameter gridder='mosaic'. This is a joint deconvolution algorithm that works in the uv-plane. A convolution of the primary beam patterns for each pointing in the mosaic is created, known as the "primary beam response function." The corresponding image of the mosaic PB response function will be called <imagename>.pb.

Additionally, for mosaics it is essential to pick the center of the region to be imaged explicitly using the phasecenter parameter. Otherwise it will default to the first pointing included in the field parameter -- since this is often at one corner of the mosaic, the image will not be centered. For the Northern mosaic, the center pointing corresponds to field 12. Note that during the final split in the calibration section that selected only the Antennae fields, the field IDs were renumbered, so that the original centers (shown in the Overview) have changed: field 14 becomes 12 for the Northern mosaic and field 18 becomes 15 for the Southern mosaic. You can also set an explicit coordinate (see the tclean help for syntax).

Continuum Imaging

Determine Line-Free Channels

Fig. 1. Northern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 70 to 100
Fig. 2. Southern mosaic: Amplitude vs. channel. The CO(3-2) line is seen from 50 to 100

We will make 345 GHz continuum images for the two regions. We use the task tclean over the channels that are free of the line emission; we avoid the edge channels which tend to be noisier due to bandpass rolloff effects. The line-free channels are found by plotting the average spectrum (all fields). We find the CO(3-2) line from channels 50 to 100 in the southern mosaic (Figure 1), and from 70 to 100 in the northern mosaic (Figure 2).

# In CASA
import os
os.system('rm -rf Antennae_North-AMPvsCH.png')
plotms(vis='Antennae_North.cal.ms', xaxis='channel', yaxis='amp',
      avgtime='1e8', avgscan=True, plotfile='Antennae_North-AMPvsCH.png', showgui=True)
# In CASA
os.system('rm -rf Antennae_South-AMPvsCH.png')
plotms(vis='Antennae_South.cal.ms', xaxis='channel', yaxis='amp',
      avgtime='1e8', avgscan=True, plotfile='Antennae_South-AMPvsCH.png', showgui=True)

The avgtime is set to a large value so that it averages over all the integrations, and avgscan is set to allow averaging of the different scans.

Next we create continuum images from the line-free channels.

Northern Continuum Mosaic

Fig. 3. Northern continuum mosaic dirty image file info.
Fig. 4. Northern continuum mosaic dirty image with full CARTA GUI. A rectangular region has been drawn near (but not including) the center of emission, and the RMS of the region is displayed in the Statistics widget.
Fig. 5. Northern continuum mosaic residual after 30 iterations shown in the interactive tclean GUI; the clean mask is shown by the white contour.

For illustrative purposes we first make a dirty image to see if there is emission and what the exact beam size is. It should be on the order of 1" but this will vary a bit according to the uv-coverage in the actual data. We will start with a cell size of 0.2" to oversample the beam by a factor of 5. The imsize needs to be large enough given the cell size to comfortably encompass the mosaic. From the mosaic footprints shown in the Overview, we can see that the Northern mosaic imsize needs to be about 1 arcmin. With 0.2" pixels, this requires imsize=300.

Other essential tclean parameters for this case include:

  • vis='Antennae_North.cal.ms' : The calibrated dataset on the science target. tclean will always use the CORRECTED DATA column (if it exists).
  • imagename='Antennae_North.Cont.Dirty' : The base name of the output images:
    • <imagename>.image # the final restored image
    • <imagename>.pb # the primary beam response
    • <imagename>.image.pbcor # the primary beam-corrected image (if pbcor=True)
    • <imagename>.weight # the primary beam coverage (gridder=’mosaic’ or 'awproject' only)
    • <imagename>.model # the model image
    • <imagename>.residual # the residual image
    • <imagename>.psf # the synthesized (dirty) beam
  • spw='0:1~50;120~164' : To specify only the line-free channels of spectral window 0.
  • specmode='mfs' : Multi-Frequency Synthesis: The default mode, which produces one image from all the specified data combined. This will grid each channel independently before imaging. For wide bandwidths this will give a far superior result compared to averaging the channels and then imaging.
  • restfreq='345.79599GHz' : The rest frequency of CO(3-2) can be found with splatalogue.
  • niter=0: Maximum number of tclean iterations. (niter=0 will do no cleaning)

In CASA 5.4 and later, tclean calls with gridder=mosaic have an additional parameter mosweight with a default of True. When mosweight=True, the gridder weights each field in the mosaic independently. The mosweight parameter is particularly important for mosaics with non-uniform sensitivity, with rectangular shapes, or when using more uniform values of robust Briggs weighting.

Starting in CASA 6.2, the beam-fitting algorithm has been updated.

# In CASA
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:
    rmtables('Antennae_North.Cont.Dirty'+ext)

tclean(vis='Antennae_North.cal.ms', imagename='Antennae_North.Cont.Dirty',
      field='', phasecenter=12,
      specmode='mfs',
      deconvolver='hogbom',
      restfreq='345.79599GHz',
      spw='0:1~50;120~164',
      gridder='mosaic', mosweight=True,
      imsize=300, cell='0.2arcsec',
      interactive=False, niter=0)

After tclean has finished, you should now open the image in CARTA. If using NRAO machines, you can open a new terminal tab, cd to the working directory, then type:

# In bash
carta --no_browser

Copy the output URL into a browser to view your CARTA session. Select Antennae_North.Cont.Dirty.image. Before clicking Load, you will see File Information displayed. The restoring beam size is about 1.23" x 0.72", with a position angle (P.A.) of 85.4 degrees. Once you load the image, you can see this information again by opening the Header dialog and selecting the File Information tab (see Fig 3).

Yes, there is definitely a detection in the vicinity of the Northern nucleus. Draw a region near (but not including) the center and open the Statistics widget. The rms noise is about 0.5 mJy/beam in the dirty image (see Fig 4).

Next we switch to refined values of cell='0.13arcsec' and imsize=500 based on the observed beam size. We also switch to interactive mode so that you can create a clean mask using the polygon tool (note you need to double click inside the polygon region to activate the mask). We have included an example mask to use in Antennae_Band7_CalibratedData.tgz. If you would like to use your own mask, make sure to removed the mask file before running the command below. Otherwise, you can edit the mask within the clean GUI.

  • niter=1000: Maximum number of clean iterations -- we will stop interactively
  • threshold='0.4mJy' : Stop cleaning if the maximum residual is below this value (the dirty rms noise)
  • interactive=True: Clean will be periodically interrupted to show the residual clean image. Interactive clean mask can be made. If no mask is created, no cleaning is done.
# In CASA
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:
    rmtables('Antennae_North.Cont.Clean'+ext)

tclean(vis='Antennae_North.cal.ms', imagename='Antennae_North.Cont.Clean',
     field='', phasecenter=12,
     deconvolver='hogbom',
     specmode='mfs', restfreq='345.79599GHz',
     spw='0:1~50;120~164',
     gridder='mosaic', mosweight=True,
     imsize=500, cell='0.13arcsec',
     interactive=True, 
     niter=1000, threshold='0.4mJy')

If you get an error using rmtables similar to "Cannot delete file <filename> because table is still open in this process," you may need to close CASA and/or CARTA to unlock the files.

Click the green circular arrow to start a major cycle. The residuals are "noise-like" after only 1 major cycle of ~30 iterations (minor cycles) (see Figure 5), so hit the red X symbol in the interactive window to stop cleaning here.

Note that if you run the tclean task again with the same imagename, without deleting the existing <imagename>.* files, tclean assumes that you want to continue cleaning the existing images. We put an rm command before the tclean command to guard against this, but sometimes this is what you want.

Southern Continuum Mosaic

Fig. 6. Southern continuum mosaic residual after 32 iterations shown in the interactive tclean GUI; the clean mask is shown by the white contour.

For the southern mosaic we modify the phasecenter, mosaic imsize, and the line-free channels (spw) to be consistent for this mosaic. We also bypass the dirty image step we did above for the Northern mosaic. As above, the mosaic size can be judged from the Overview. We expect the beam to be about the same and use the same cell size. Again, you can use the provided mask or make your own.

# In CASA
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:
    rmtables('Antennae_South.Cont.Clean'+ext)

tclean(vis='Antennae_South.cal.ms', imagename='Antennae_South.Cont.Clean',
      field='', phasecenter=15,
      specmode='mfs', restfreq='345.79599GHz',
      spw='0:1~30;120~164',
      gridder='mosaic', mosweight=True, deconvolver='hogbom',
      imsize=750, cell='0.13arcsec',
      interactive=True, 
      niter=1000, threshold='0.4mJy')

The beam size is reported in the logger as 1.14"x0.66" with P.A.=61.5 deg, which is a little better than the North beam due to better uv-coverage.

Click the green arrow to run one major cycle. We hit the stopping threshold after ~32 iterations (minor cycles). The residuals now look noise-like and we can stop cleaning (see Figure 6). Hit the red X to close the tclean GUI.


Continuum Image Statistics

Fig. 5. Example polygon for rms determination using CARTA. Here we measure an rms of 0.48 mJy/beam, slightly different from what imstat reports.
Fig. 6. 345 GHz continuum images of the Northern and Southern mosaics, exported from CARTA, with multi-panel view and raster scaling matching.

You can determine statistics for the images using the task imstat:

# In CASA
imstat('Antennae_North.Cont.Clean.image')
imstat('Antennae_South.Cont.Clean.image')

From this we find that for the Northern continuum image the peak (max) is 3.82 mJy/beam and the rms (sigma) is 0.49 mJy/beam. For the Southern continuum we find a peak (max) of 4.77 mJy/beam and an rms (sigma) of 0.47 mJy/beam.

However, the calculation of the rms comes with a couple of caveats. First, the mosaic primary beam response rolls off toward the edges of the mosaic, as do correspondingly the flux density and rms. Thus if you don't restrict the measurement to areas of full sensitivity, the apparent rms is skewed downward. Second, since there is real emission in the image, the rms will be skewed upward (with the error increasing with brighter emission). Both can be solved by picking boxes that exclude the edges of the mosaic and the real emission. It is often easier to use CARTA to display the image and then interactively use the region tools to get the statistics.

Open 'Antennae_North.Cont.Clean.image' in CARTA. Draw a region that avoids the edges and emission (see Figure 5), and view the Statistics widget. You may measure an rms that differs by a few percent from the value reported by imstat. Repeat this for 'Antennae_South.Cont.Clean.image'. Again, you may measure an rms slightly different than what we got from using imstat with no constraints.

How does this compare to theory? You can find out using the ALMA sensitivity calculator. The continuum bandwidth of the Northern mosaic is about 1 GHz and about 0.85 GHz for the Southern mosaic. The number of antennas is about 12 and the time on a single pointing is about 300s. This yields an expected rms of about 1 mJy/beam. However, this needs to be decreased by about a factor of 2.5 near the center of the mosaic due to the hexagonal Nyquist sampling of the mosaic (radial spacing~0.37*HPBW) for a theoretical rms of about 0.4 mJy/beam, in good agreement with observation.

Finally, use CARTA to export .png images of both the North and South mosaics. You can view the images side by side by enabling multi-panel view in the image viewer, and you may wish to enable "Raster scaling matching."



Continuum subtraction

In these data, the continuum emission is too weak to contaminate the line emission (i.e. the peak continuum emission is less than the rms noise in the spectral line channels). Nevertheless, for illustrative purposes we demonstrate how to subtract the continuum emission in the uv-domain using the task uvcontsub.

# In CASA
uvcontsub(vis='Antennae_North.cal.ms', outputvis='Antennae_North.cal.ms.contsub', fitspec='0:1~50;120~164', fitorder=1)
# In CASA
uvcontsub(vis='Antennae_South.cal.ms', outputvis='Antennae_South.cal.ms.contsub', fitspec='0:1~30;120~164', fitorder=1)

Here, fitspec specifies the line-free channels to fit. Higher fit order than 1 are not recommended. If you do not have line-free channels on both sides of the line fitorder=0 is recommended.


CO(3-2) Imaging

Choose Frame and Velocity Channels

Fig. 8. Northern CO(3-2) uv-spectrum in LSRK velocity space.
Fig. 9. Southern CO(3-2) uv-spectrum in LSRK velocity space.

Now we are ready to make cubes of the line emission. The imaging parameters are similar to the continuum except for those dealing with the spectral setup: specmode, start, width, nchan, restfreq, and outframe parameters. As noted above, setting specmode='mfs' gives an output image with only one channel, and is used for continuum imaging. specmode='cube' creates output data cubes with one or more channels.

Data are taken using constant frequency channels. For spectral line analysis it's often more useful to have constant velocity channels, and this is also the best way to make images of multiple lines with the exact same channelization for later comparison. For specmode='cube', the desired start and width also need to be given in velocity units for the desired output frame.

It is important to note that ALMA does not do on-line Doppler Tracking and the native frame of the data is TOPO. If you do not specify outframe the output cube will also be in TOPO, which is not very useful for scientific analysis. The Doppler Shift is taken out during the regridding to the desired outframe in tclean or alternatively it can be done separately by the cvel task which would need to be run before tclean.

To see what velocity parameters you want to set in tclean, it is useful to make a plot in plotms in the desired output frame. Note these plots take a little longer because of the frame shift. In order to compare with recent SMA data, we chose LSRK, but it should be noted that many papers of this source are in the BARY frame.

# In CASA
os.system('rm -rf North_CO3_2_vel.png')
plotms(vis='Antennae_North.cal.ms.contsub', xaxis='velocity', yaxis='amp',
       avgtime='1e8', avgscan=True, transform=True, freqframe='LSRK',
       restfreq='345.79599GHz', plotfile='North_CO3_2_vel.png', showgui=True)
# In CASA
os.system('rm -rf South_CO3_2_vel.png')
plotms(vis='Antennae_South.cal.ms.contsub', xaxis='velocity', yaxis='amp',
      avgtime='1e8', avgscan=True, transform=True, freqframe='LSRK',
      restfreq='345.79599GHz', plotfile='South_CO3_2_vel.png', showgui=True)


Northern Mosaic Cube

Similar to continuum, it is very important that you make a clean mask. For this example we will create a single clean mask that encompasses the line emission in every channel and apply it to all channels. This is much better than no clean mask, though not quite as good as making an individual mask for each channel.

Fig. 10. Interactive cleaning of northern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.
Fig. 11. Viewing the cleaned cube in CARTA at the 1650 km/s channel.

Notable parameters included in the tclean call are:

  • specmode='cube', outframe='LSRK', restfreq='345.79599GHz'. We use 'cube' mode to create an output data cube. We set the velocity information in the Local Standard of Rest frame (kinematic definition), and use the rest frequency of the CO(3-2) line.
  • nchan=70, start='1200km/s', width='10km/s': To produce a data cube with 70 channels, starting at 1200 km/s, and with velocity widths of 10 km/s. That will include all the CO(3-2) emission in both mosaics.
  • imsize=500, cell='0.13arcsec': An image size of 65 arcsec, with pixels of 0.13 arcsec (about one-fifth the minor axis of the synthesized beam). We make the imsize larger than the mosaic to increase the dirty beam image size, as the emission is quite extended along the mosaic.
  • weighting='briggsbwtaper', robust=0.5: Weighting to apply to visibilities. Weighting has been changed to 'briggsbwtaper'. This is a new weighting scheme available starting in CASA 6.2. See Imaging Algorithms for more information. We use robustness parameter 0.5 (in between natural and uniform weighting).
  • niter=20000: Maximum number of clean iterations. With complex emission structure like that found in the Antennae CO data, we will need a large number of iterations to clean the emission. Note that you can increase the number of iterations allowed on-the-fly in the interactive tclean window.
  • threshold='5.0mJy': Stop cleaning if the maximum residual is below this value.

The threshold is set to roughly the rms of a single line-free channel for each dataset.

  • savemodel='modelcolumn': This saves the clean model to the ms file. We will need this for self-calibration later.
# In CASA
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:
    rmtables('Antennae_North.CO3_2Line.Clean'+ext)

tclean(vis='Antennae_North.cal.ms.contsub', datacolumn='data',
      imagename='Antennae_North.CO3_2Line.Clean',
      spw='0', field='', phasecenter=12,
      specmode='cube', outframe='LSRK', restfreq='345.79599GHz',
      nchan=70, start='1200km/s', width='10km/s',
      gridder='mosaic', mosweight=True,
      deconvolver='hogbom',
      imsize=500, cell='0.13arcsec', pblimit=0.2,
      restoringbeam='common',
      interactive=True,
      weighting='briggsbwtaper', robust=0.5,
      niter=20000, threshold='5.0mJy',
      savemodel='modelcolumn')

Figure 10 shows what the final clean box should look like. Cycle through the channels until you reach ~1650 km/s, where you can more easily see where to draw the clean box around the CO emission. Be sure to check the circle next to 'All Channels' when making your clean mask. Now clean using the green circle arrow. You can watch the progress in the logger. When the first ~650 iterations are done, the viewer will show the residual map for each channel. Cycle through the channels and see whether you are still happy with the clean box in each channel with significant signal. The "Erase" button can help you fix mistakes. If necessary, adjust. It is often useful to adjust the colorscale with the "plus" (crossing arrows) icon. To make it go a bit faster, you can increase iteration interactively to 200 or 300, but don't overdo it.

These data are pretty severely dynamic range limited, in part due to the sparse uv coverage. In other words, the noise in bright channels is set by a maximum signal-to-noise. This effectively prevents us from stopping clean based on an rms based threshold because the effective rms changes as a function of the brightest signal in each channel. Thus, in this case we need to stop clean interactively. Below an approximate number of iterations is given to help you decide when to quit. The threshold that is set in the CO(3-2) clean commands are about equal to the noise in a line-free channel and is only there to prevent clean running forever if you fail to stop it. You are not intended to clean to this threshold.

Also, we are going to self-calibrate the data so it's best to be conservative here - it can be difficult in images like these to discern real features from artifacts. If in doubt, don't include it in the clean mask. Keep cleaning and see if the feature becomes weaker. You cannot lose real emission by not masking it, but you can create a brighter feature by masking an artifact.

Stop cleaning after ~5000 iterations (Red X), when the artifacts start to look as bright as the residual. Note again that we are not cleaning to the theoretical noise level.

Inspect the resulting data cube in CARTA (Fig 11):
Antennae_North.CO3_2Line.Clean.image


Southern Mosaic Cube

Fig. 12. Interactive cleaning of southern mosaic. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before drawing mask.
Fig. 13. Viewing the cleaned cube in CARTA at the 1650 km/s channel.

Repeat the process for Southern mosaic.

# In CASA
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:
    rmtables('Antennae_South.CO3_2Line.Clean'+ext)

tclean(vis='Antennae_South.cal.ms.contsub', datacolumn='data',
      imagename='Antennae_South.CO3_2Line.Clean',
      spw='0', field='', phasecenter=15,
      specmode='cube', outframe='LSRK', restfreq='345.79599GHz',
      nchan=70, start='1200km/s', width='10km/s',
      gridder='mosaic', mosweight=True, deconvolver='hogbom',
      imsize=750, cell='0.13arcsec', pblimit=0.2,
      restoringbeam='common',
      interactive=True,
      weighting='briggsbwtaper', robust=0.5,
      niter=20000, threshold='5.0mJy',
      savemodel='modelcolumn')

Clean until the residuals become noise-like, ~17000 iterations before stopping. Inspect the resulting data cube in CARTA (Fig 13):
Antennae_South.CO3_2Line.Clean.image


Cube Statistics

For each mosaic, in CARTA, draw regions in both a line-free channel and the channel with the strongest emission, and evaluate using the Statistics widget.

The line-free channel rms for the northern and southern mosaics are about 4.0 mJy/beam and 3.5 mJy/beam, respectively. However, in a bright channel, this degrades to about 18 mJy/beam and 9 mJy/beam, respectively. This is the aforementioned dynamic range limit.

Using the ALMA sensitivity calculator, a bandwidth of 10 km/s, dual polarization, 12 antennas, and the time on a single pointing of about 300s yields an rms of about 9.0 mJy/beam. As described above, the Nyquist sampled hexagonal mosaic improves this by a factor of about 2.5, for an expected rms noise of about 3.6 mJy. In line-free channels, our image is close to this theoretical rms.


Self Calibration

Strategy

Next we attempt to self-calibrate the uv-data. The process of self-calibration tries to adjust the data to better match the model image that you give it. When tclean is run, it saves a uv-model of the resulting image in the MODEL column of the measurement set if savemodel='modelcolumn'. This model can be used to self-calibrate the data using gaincal. That is why it is important to make the model as good as you can by making clean masks.

Mosaics can be tricky to self-calibrate. The reason is that typically only a few of the pointings may have strong emission. The stronger the signal, the stronger the signal-to-noise will be for a given self-calibration solution interval (solint). This means that typically only a few fields are strong enough for self-calibration, though it can still bring about overall improvement to apply these solutions to all fields. The fine tuning of each field in the mosaic over small solutions intervals is often impossible. Indeed fine-tuning only a few fields in the mosaic on small time scales can result in a mosaic with dramatically different noise levels as a function of position. Below, we will simply attempt to self-calibrate on the strongest field in the mosaic, obtaining one average solution per original input dataset.

Here, the continuum is far too weak so we will use the CO(3-2) line emission. To increase signal-to-noise it is often helpful to limit solutions to the range of channels containing the strongest line emission.

We will also use gaintype='T' to tell CASA to average the polarizations before deriving solutions which gains us a sqrt(2) in sensitivity.

Northern Mosaic Selfcal and Cube Image

Fig. 12. Plot of the CO(3-2) emission from the DATA column of field 12 of the Northern mosaic.
Fig. 13. Plot of the CO(3-2) emission from the MODEL column of field 12 of the Northern mosaic.

The strongest emission in the Northern mosaic comes from the center pointing, already identified above as field='12'. Below we make a uv-plot of the spectral line emission from this field to choose only the strongest channels to include in the self-calibration. It is essential that the self-calibration channel range be chosen based on the UV data and not on the image cube. This is because the channels in the image cube were modified by the velocity/channel specifications in the first invocation of clean. This plot shows the channel range of the uv data.

# In CASA
plotms(vis='Antennae_North.cal.ms.contsub', spw='', xaxis='channel', yaxis='amp', field='12',
       avgtime='1e8', avgscan=True, ydatacolumn='data', plotfile='North_selfchan_data.png',
       height=800, width=1000, overwrite=True, showgui=True)

We also want to check the channel amplitudes in the model column of the measurement set. The depth of the initial clean will determine what model channels have emission. (A very shallow clean could potentially produce a model with emission over a small range of channels.) Self calibration will attempt to make the data look like the model. Therefore, it is important that we select a channel range where the model is realistic.

# In CASA
plotms(vis='Antennae_North.cal.ms.contsub', spw='', xaxis='channel', yaxis='amp', field='12',
       avgtime='1e8', avgscan=True, ydatacolumn='model', plotfile='North_selfchan_model.png',
       height=800, width=1000, overwrite=True, showgui=True)

While the model looks reasonable across the channels where we imaged the data, the model amplitudes are set to 0 elsewhere by default. We will perform self-calibration only on the channels we imaged in the first cube, with significant signal in the line emission.

Next, we remind ourselves of the timing of the various observations. Examine the listobs output, Antennae_North.cal.listobs.txt. Each dataset has 2 or 3 observations of field 12. Each time, it's observed for about 25 seconds. We set solint='3600s' to get one solution per dataset.

Fig. 14. Phase-only self-calibration solutions for the Northern mosaic.
# In CASA
gaincal(vis='Antennae_North.cal.ms.contsub', caltable='north_self_1.pcal',
        solint='3600s', combine='scan', gaintype='T', field='12',
        refant='DV09', spw='0:82~89', minblperant=4,
        calmode='p', minsnr=2)

Plot the calibration solutions. Note that when iteraxis is set, plotms appends the axes being iterated over to the output filename specified in plotfile; this can make for rather unwieldy filenames but is useful for ALMA pipeline purposes.

# In CASA
plotms(vis='north_self_1.pcal', xaxis='time', yaxis='phase',
        spw='', field='', antenna='',
        iteraxis='antenna', gridrows=5, gridcols=3, plotrange=[0,0,-80,80],
        plotfile='north_pcal1_phase.png', showgui=True)

Apply the solutions to all fields and channels with applycal, which will overwrite the corrected data column:

# In CASA
applycal(vis='Antennae_North.cal.ms.contsub', field='',
        gaintable=['north_self_1.pcal'], calwt=False)

Re-image the data with the selfcal applied. Remember that tclean uses the corrected data column by default if it exists. We will start with the same mask that we ended with before.

Fig. 15. Interactive cleaning of Northern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "all channels" before editing the previous mask.
# In CASA
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:
    rmtables('Antennae_North.CO3_2Line.Clean.pcal1'+ext)

tclean(vis='Antennae_North.cal.ms.contsub', datacolumn='corrected',
      imagename='Antennae_North.CO3_2Line.Clean.pcal1',
      spw='0', field='', phasecenter=12,
      specmode='cube', outframe='LSRK', restfreq='345.79599GHz',
      nchan=70, start='1200km/s', width='10km/s',
      gridder='mosaic', mosweight=True,
      deconvolver='hogbom',
      imsize=500, cell='0.13arcsec', pblimit=0.2,
      restoringbeam='common',
      interactive=True, mask='Antennae_North.CO3_2Line.Clean.mask',
      weighting='briggsbwtaper', robust=0.5,
      niter=20000, threshold='5.0mJy',
      savemodel='modelcolumn')

After each major cycle, inspect each channel to see if there is more emission that needs to be included in the mask. Remember to select the "all channels" toggle. Stop when the residuals become noise like, after ~5000 iterations.

Compare the original and self-calibrated images in CARTA to determine if there has been improvement:
Antennae_North.CO3_2Line.Clean.image
Antennae_North.CO3_2Line.Clean.pcal1.image

Fig. 16. Comparison of the 1650 km/s channel before selfcal (left) and after selfcal (right).

The images may look quite similar at first. Examining the image statistics, the peak flux density should have increased substantially while the rms noise is about the same. This is reasonable for this self-calibration case because we have mostly adjusted relative position offsets between the datasets and not taken out any short-term phase variations which would reduce the rms.

Note that attempts to push the selfcal to shorter solint (for example to each scan of field=12) did not yield additional improvement.

If you used standard='Butler-JPL-Horizons 2012' when running setjy during the calibration process, you may see an increase of approximately 20% in the peak flux density of bright channels.


Southern Mosaic Selfcal and Cube Image

Fig. 17. Plot of the CO(3-2) emission from the DATA column for Field 7 of the Southern mosaic.
Fig. 18. Plot of the CO(3-2) emission from the MODEL column for Field 7 of the Southern mosaic.

Now repeat the self-calibration process for the Southern mosaic. It is a bit tougher in this case to pick the best field. The most compact bright emission is toward Field 11 in the Overview. Adjusting for the renumbering of Field IDs after the final calibration split, this becomes Field 7.

From the plots of data and model amplitude, we can assess the brightest channels to selfcal and image:

# In CASA
plotms(vis='Antennae_South.cal.ms.contsub', spw='', xaxis='channel', yaxis='amp',
       field='7', avgtime='1e8', avgscan=True, ydatacolumn='data',
       plotfile='South_selfchan_data.png', height=800, width=1000, overwrite=True, showgui=True)
# In CASA
plotms(vis='Antennae_South.cal.ms.contsub', spw='', xaxis='channel', yaxis='amp',
       field='7', avgtime='1e8', avgscan=True, ydatacolumn='model',
       plotfile='South_selfchan_model.png', height=800, width=1000, overwrite=True, showgui=True)

Examine the listobs output, Antennae_South.cal.listobs.txt. The timing in the 6 Southern datasets is similar to the North, with each lasting about 1 hour.

Fig. 19. Phase-only self-calibration solutions for the Southern mosaic.

Solve for the self-calibration phase corrections:

# In CASA
gaincal(vis='Antennae_South.cal.ms.contsub', caltable='south_self_1.pcal',
        solint='3600s', combine='scan', gaintype='T', field='7',
        refant='DV09', spw='0:70~85', minblperant=4,
        calmode='p', minsnr=2)

Plot the selfcal solutions:

# In CASA
plotms(vis='south_self_1.pcal', xaxis='time', yaxis='phase',
        spw='', field='', antenna='',
        iteraxis='antenna', gridrows=5, gridcols=3, plotrange=[0,0,-80,80],
        plotfile='south_pcal1_phase.png', showgui=True)

Apply the solutions:

# In CASA
applycal(vis='Antennae_South.cal.ms.contsub', field='',
        gaintable=['south_self_1.pcal'], calwt=False)
Fig. 20. Interactive cleaning of Southern mosaic after self-cal. The clean mask is shown in white. In this example we used the same mask for all channels by selecting "All Channels" before drawing mask.

Clean a new cube using the newly corrected data. We will start with the South mosaic mask from before selfcal, and don't forget to select All Channels if modifying the mask:

# In CASA
for ext in ['.image','.model','.image.pbcor','.psf','.residual','.pb','.sumwt','.weight']:
    rmtables('Antennae_South.CO3_2Line.Clean.pcal1'+ext)

tclean(vis='Antennae_South.cal.ms.contsub', datacolumn='corrected',
      imagename='Antennae_South.CO3_2Line.Clean.pcal1',
      spw='0', field='', phasecenter=15,
      specmode='cube', outframe='LSRK', restfreq='345.79599GHz',
      nchan=70, start='1200km/s', width='10km/s',
      gridder='mosaic', mosweight=True, deconvolver='hogbom',
      imsize=750, cell='0.13arcsec', pblimit=0.2,
      restoringbeam='common',
      interactive=True, mask='Antennae_South.CO3_2Line.Clean.mask',
      weighting='briggsbwtaper', robust=0.5,
      niter=40000, threshold='5.0mJy',
      savemodel='modelcolumn')

After each major cycle, inspect each channel to see if there is more emission that needs to be included in the mask. Stop when the residuals become noise-like, after ~20000 iterations.

Compare the before and after selfcal images in CARTA, and examine the rms and peak flux density of a couple bright channels:
Antennae_South.CO3_2Line.Clean.image
Antennae_South.CO3_2Line.Clean.pcal1.image


Fig. 21. Comparison of the 1500 km/s channel before selfcal (left) and after selfcal (right).

If you used standard='Butler-JPL-Horizons 2012' when running setjy during the calibration process, you may see an increase of 20% or greater in the peak flux density of bright channels.


Image Analysis

Moment Maps

Fig. 22. Northern mosaic 1650 km/s channel overlaid with 3*sigma = 12.0 mJy contours.
Fig. 23. Southern mosaic 1440 km/s channel overlaid with 3*sigma = 10.5 mJy contours.

Next we will make moment maps for the CO(3-2) emission.

Moment 0 = integrated intensity
Moment 1 = intensity weighted velocity field
Moment 2 = intensity weighted velocity dispersion

Above we determined the rms noise levels for both the North and South mosaics in both a line-free and a line-bright channel. We want to limit the channel range of the moment calculations to those channels with significant emission. One good way to do this is to overly the cubes with 3-sigma contours, sigma corresponding to the line-free rms (North ~ 4.0 mJy/beam, South ~ 3.5 mJy/beam).
Open the cubes in CARTA:
Antennae_North.CO3_2Line.Clean.pcal1.image
Antennae_South.CO3_2Line.Clean.pcal1.image

Open the Contour tool, choose a cube from the "Data source" drop-down, and enter the value of 3*sigma for that cube into the "Levels" box. Click Apply. You can also change the color and thickness of contours in the Styling tab. Now page through the channels to see which contain obvious contours. For North, we find a channel range for significant emission of 35~60. For South, we find a channel range for significant emission of 13~62.

For moment 0 (integrated intensity) maps you do not typically want to set a flux threshold because this will tend to noise bias your integrated intensity.

# In CASA
rmtables('Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')

immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', 
          moments=[0], chans='35~60',
          outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0')

For higher order moments it is very important to set a conservative flux threshold. Typically something like 3sigma, using sigma from a bright line channel works well (North ~ 14 mJy/beam, South ~ 4 mJy/beam). We do this with the mask parameter in the commands below. When making multiple moments, immoments appends the appropriate file name suffix to the value of outfile.

# In CASA
for ext in ['.weighted_coord','.weighted_dispersion_coord']:
    rmtables('Antennae_North.CO3_2Line.Clean.pcal1.image.mom'+ext)

immoments('Antennae_North.CO3_2Line.Clean.pcal1.image', 
          moments=[1,2], chans='35~60', 
          mask='Antennae_North.CO3_2Line.Clean.pcal1.image>0.014*3',
          outfile='Antennae_North.CO3_2Line.Clean.pcal1.image.mom')

Open your North moment maps in CARTA and export to .png (Figure 24):
Antennae_North.CO3_2Line.Clean.pcal1.image.mom0
Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord
Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord

Fig. 24. Northern mosaic moments 0, 1, and 2.
# In CASA
rmtables('Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')

immoments('Antennae_South.CO3_2Line.Clean.pcal1.image',
          moments=[0], chans='13~62', 
          outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0')
# In CASA
for ext in ['.weighted_coord','.weighted_dispersion_coord']:
    rmtables('Antennae_South.CO3_2Line.Clean.pcal1.image.mom'+ext)

immoments('Antennae_South.CO3_2Line.Clean.pcal1.image', 
          moments=[1,2], chans='13~62',
          mask='Antennae_South.CO3_2Line.Clean.pcal1.image>0.004*3',
          outfile='Antennae_South.CO3_2Line.Clean.pcal1.image.mom')

Open your South moment maps in CARTA and export to .png (Figure 25):
Antennae_South.CO3_2Line.Clean.pcal1.image.mom0
Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord
Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord

Fig. 25. Southern mosaic moments 0, 1, and 2.

Exporting Images to Fits

If you want to analyze the data using another software package it is easy to convert from CASA format to FITS.

# In CASA
exportfits(imagename='Antennae_North.Cont.Clean.image',
     fitsimage='Antennae_North.Cont.Clean.image.fits', overwrite=True)
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image',
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.fits', overwrite=True)
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0',
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom0.fits', overwrite=True)
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits', overwrite=True)
exportfits(imagename='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',
     fitsimage='Antennae_North.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits', overwrite=True)
# In CASA
exportfits(imagename='Antennae_South.Cont.Clean.image',
     fitsimage='Antennae_South.Cont.Clean.image.fits', overwrite=True)
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image',
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.fits', overwrite=True)
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0',
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom0.fits', overwrite=True)
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord',
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_coord.fits', overwrite=True)
exportfits(imagename='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord',
     fitsimage='Antennae_South.CO3_2Line.Clean.pcal1.image.mom.weighted_dispersion_coord.fits', overwrite=True)

Although "FITS format" is supposed to be a standard, in fact most packages expect slightly different things from a FITS image. If you are having difficulty, try setting velocity=True and/or dropstokes=True.

Comparison with previous SMA CO(3-2) data

We compare with SMA CO(3-2) data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65). Figure 28 shows a comparison plot between the moment 0 maps of ALMA and SMA data using the imview. The fluxes, peak locations, and large scale structure are consistent. Both southern and northern components have been combined.


Fig. 28. The CO(3-2) total intensity map (moment 0) comparison with SMA data. Colour image is ALMA data, combining southern and northern mosaics. Contours show SMA data (Ueda, Iono, Petitpas et al. 2012, ApJ, 745, 65).

Last checked on CASA Version 6.5.4