Continuum subtraction - eakadams/ihow-hi GitHub Wiki

This part of the tutorial starts with a calibrated dataset of just the source: sexb.ms, and is the focus for the I-HOW workshop as the earlier steps are also part of the continuum imaging tutorial (cross-calibration is in common between line and continuum imaging).

Get the tutorial data

You can find the tutorial data here. Download the sexb.ms.tar which is the calibrated data of the source only (split out from the calibrators, only kept good channels). The ms (measurement set) structure is that of a directory so the data was tarred to make it easier to up/download. Untar it via:

tar -xvf sexb.ms.tar

Note that this happens on the command line, outside of CASA. After this, all commands are CASA commands and thus you should have launched CASA.

Make a first dirty image

It's useful to invert the dataset to make a first dirty cube to check the data quality and see where the source is.

In contrast to continuum imaging, we will use specmode=cube in the CASA tclean task. This provides optional new inputs setting the parameters of the cube. For now, we will use defaults, which is imaging each channel, but it is possible to regrid data spectrally when imaging. We will specify the velocity frame as barycentric and helio/barycentric are the common frames for extragalactic work.

Set niter to zero as we are making a dirty image to start.

tclean(vis='sexb.ms',imsize=300,cell='12arcsec',specmode='cube',niter=0,restfreq='1420.405752MHz',imagename='dirty',outframe='bary')

Note that you may get errors about leap seconds being out of date. This accuracy is not necessary when imaging HI and thus can be ignored.

Display the cube in imview (or carta, if you prefer) and play through the channels. What do you notice?

There is some structure in the noise. This can indicate that there is more flagging which needs to be done, but for now we will ignore it. It is also possible this is dirty beam response from unsubtracted continuum sources. The structure is also typical for natural weighting; we will change the weighting later.

You should be able to see at least one continuum source that shows up in individual channels, as in the channel below: Empty channel from dirty cube

Note that it can be easier to see the continuum source by playing the movie as it stays in one place while the noise changes. What are the approximate coordinates of the continuum source?

You should also be able to see the HI emission from Sextans B appear and disappear while playing through channels: Channel with line emission from dirty cube

Can you identify the channels that have source emission? Take the time to do that, as that information is needed for the next step and one of the reasons for making this first dirty cube.

You can use the spectral profiler to help identify channels, drawing a box approximately around the source: Spectral profile for dirty cube

The galaxy is approximately in channels ~85-150.

Do the continuum subtraction

When doing the continuum subtraction, you want to avoid including channels that have line, as then you will oversubtract the data since the line emission will add flux in the channels were it is present, and this will impact your ability to properly recover the line flux. There are two general approaches to continuum subtraction: fitting and removing in the uv- or image- plane. In this case, we will subtract in the uv plane. A general approach is to do the subtraction first in the uv-plane and then a secondary subtraction in the image plane, if necessary, for residual continuum. This is generally only necessary when working with very high dynamic range data or when there is an extremely strong continuum source.

The general approach, in either the uv or image plane, is to fit polynomials and subtract those out. Generally, a polynomial of order 1 or less should be used; using higher order polynomials shoudl only be used when there is justification (e.g., a bright continuum source with spectral curvature).

uvcontsub(vis='sexb.ms',fitspw='0:0~85;150~205', fitorder=0)

This creates a new dataset, sexb.ms.contsub. Image this dataset to see how the continuum subtraction went:

tclean(vis='sexb.ms.contsub',imsize=300,cell='12arcsec',specmode='cube',niter=0,restfreq='1420.405752MHz',imagename='dirty_contsub',outframe='bary')

We can look at the new dirty cube and see the continuum sources have been subtracted; this has also improved the background noise/structure:

Empty channel from continuum subtracted dirty cube

We will assume the continuum subtraction is complete for now and carry on. If there is evidence that the continuum subtraction has not fully worked, one could try a higher order polynomial now, or later try a secondary image plane subtraction.