Create a Clean Mask from Continuum Image or Moment Cube
If the morphology of your source is complicated, it can often be more efficient and reproducible to create a CLEAN mask from the data itself. This page outlines how to do this for continuum data (from the dirty image) and for spectral line data (from the moment 0 map of the dirty line cube).
Another useful resource is https://casaguides.nrao.edu/index.php/Masking_images_for_analysis
Make a Dirty image
First make a spectral line and/or continuum "dirty map" by calling CLEAN with niter=0. This is the starting point for CLEAN.
Creating a Mask from Continuum Data
Supposing you have a dirty image called "calibrated_final_cont_dirty.image" and would like to create a CLEAN mask such that areas with intensities greater than 0.75 mJy/bm are CLEANed, you do the following:
ia.open('calibrated_final_cont_dirty.image') ia.calcmask('calibrated_final_cont_dirty.image > 7.5e-4',name='cont_dirty0p75mjy') ia.done() inp makemask mode='copy' inpimage='calibrated_final_cont_dirty.image' inpmask='calibrated_final_cont_dirty.image:cont_dirty0p75mjy' output='contDirtyMask0p75mjy' overwrite=True inp go
The choice of this threshold is critical --- you should choose it conservatively (on the high side) such that you are confident all emission contained is real
The output mask contDirtyMask0p75mjy in the above example is then suitable for use as input to CLEAN (via the "mask=" keyword).
Creating a Mask from Line Data
Suppose you have a dirty line cube with a very complex morphology and wish to create a mask for CLEANing. One approach is to take the channel average (moment zero) of the dirty line cube and threshold it as for the continuum map. Again, The choice of this threshold is critical --- you should choose it conservatively (on the high side) such that you are confident all emission contained is real. The following syntax illustrates the procedure. Note the slight difference in the "makemask" syntax (expand mode vs copy mode, since we need to expand the mask to cover all channels).
# calculate moment 0 map to get a rough mask for CLEAN- immoments(imagename='source_calibrated_line_dirty.image',outfile='dirty_cube_mom0',includepix=[0,1000],moments=0) # by inspecting the result, I find mom0 Background mean ~0.35 Jy/bm, with a dispersion of 0.05 Jy/bm # threshold it at 0.5 Jy/bm- ia.open('dirty_cube_mom0') ia.calcmask(mask='dirty_cube_mom0 > 0.5',name='mom0_0p5') ia.done() # expand that into a cube image, which is what CLEAN() # wants as input for a mask. inp makemask mode='expand' inpimage='source_calibrated_line_dirty.image' inpmask='dirty_cube_mom0:mom0_0p5' output='cubeMask0p5' overwrite=True inp go
The output "cubeMask0p5" is suitable for use in CLEAN via the "mask=" keyword.