{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github"
},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "LcHKz7mikumz"
},
"source": [
"# Synthesis Imaging\n",
"\n",
"This chapter documents CASA's refactored imager. These features are visible to the user via the **tclean** task. Image products can be visualized with the CASA Viewer, which in CASA 6 should be initialized with the task **imview**.\n",
"\n",
"The first five sections give an algorithm-centric view of the imager framework and are meant to convey the overall iterative reconstruction framework and how various algorithms and usage options fit into it. The other sections are more user-centric and focus on what one would need to know about specific imaging goals such as wideband imaging, mosaicking or details about spectral-cube definitions, etc. There is some overlap in content between sections, but this is meant to address the needs of readers who want to understand how the system works as well as those who want to learn how to approach their specific use case.\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "YXPIbeHCkum0"
},
"source": [
"## Introduction\n",
"\n",
"Image reconstruction in radio interferometry is the process of solving the linear system of equations $\\vec{V} = [A] \\vec{I}$, where $\\vec{V}$ represents visibilities calibrated for direction independent effects, $\\vec{I}$ is a list of parameters that model the sky brightness distribution (for example, a image of pixels) and $[A]$ is the measurement operator that encodes the process of how visibilities are generated when a telescope observes a sky brightness $\\vec{I}$. $[A]$ is generally given by $[S_{dd}][F]$ where $[F]$ represents a 2D Fourier transform, and $[S_{dd}]$ represents a 2D spatial frequency sampling function that can include direction-dependent instrumental effects. For a practical interferometer with a finite number of array elements, $[A]$ is non-invertible because of unsampled regions of the $uv$ plane. Therefore, this system of equations must be solved iteratively, applying constraints via various choices of image parameterizations and instrumental models.\n",
"\n",
"**Implementation ( major and minor cycles ):**\n",
"\n",
"Image reconstruction in CASA comprises an outer loop of *major cycles* and an inner loop of *minor cycles*. The major cycle implements transforms between the data and image spaces and the minor cycle operates purely in the image domain. Together, they implement an iterative weighted $\\chi^2$ minimization process that solves the measurement equation.\n",
"\n",
"\n",
"\n",
"{.image-inline width=\"635\" height=\"347\"}\n",
"\n",
">Iterative Image Reconstruction - Major and Minor Cycles\n",
" \n",
"\n",
"\n",
"\n",
"The data to image transform is called the *imaging* step in which a pseudo inverse of $[S_{dd}][F]$ is computed and applied to the visibilities. Operationally, weighted visibilities are convolutionally resampled onto a grid of spatial-frequency cells, inverse Fourier transformed, and normalized. This step is equivalent to calculating the normal equations as part of a least squares solution. The image to data transform is called the *prediction* step and it evaluates the measurement equation to convert a model of the sky brightness into a list of model visibilities that are later subtracted from the data to form residual visibilities. For both transforms, direction dependent instrumental effects can be accounted for via carefully constructed convolution functions.\n",
"\n",
"Iterations begin with an initial guess for the image model. Each major cycle consists of the prediction of model visibilities, the calculation of residual visibilities and the construction of a residual image. This residual image contains the effect of incomplete sampling of the spatial-frequency plane but is otherwise normalized to the correct sky flux units. In its simplest form, it can be written as a convolution of the true sky image with a point spread function. The job of the minor cycle is to iteratively build up a model of the true sky by separating it from the point spread function. This step is also called *deconvolution* and is equivalent to the process of solving the normal equations as part of a least squares solution. Different reconstruction algorithms can operate as minor cycle iterations, allowing for flexibility in (for example) how the sky brightness is parameterized. The imaging step can be approximate in that several direction dependent effects, especially baseline, frequency or time-dependent ones can sometimes ignored, minor cycles can be approximate in that they use only PSF patches and do not try to be accurate over the entire image, but the prediction step of the major cycle must be as accurate as possible such that model components are converted to visibilities by including all possible instrumental effects.\n",
"\n",
"**Basic Sequence of Imaging Logic:**\n",
"\n",
"```\n",
"Data : Calibrated visibilities, data weights, UV sampling function\n",
"Input : Algorithm and iteration controls (stopping threshold, loop gain,...)\n",
"Output : Model Image, Restored Image, Residual Image,...\n",
"\n",
"Initialize the model image\n",
"Compute the point spread function\n",
"Compute the initial residual image\n",
"While ( not reached global stopping criterion ) /* Major Cycle */\n",
"{\n",
" While ( not reached minor-cycle stopping criterion ) /* Minor Cycle */\n",
" {\n",
" Find the parameters of a new flux component\n",
" Update the model and residual images\n",
" }\n",
" Use current model image to predict model visibilities\n",
" Calculate residual visibilities (data - model)\n",
" Compute a new residual image from residual visibilities\n",
"}\n",
"Convolve the final model image with the fitted beam and add to the residual image\n",
"```\n",
"\n",
"**Algorithmic Options :**\n",
"\n",
"Within the CASA implementation, numerous choices are provided to enable the user to fine-tune the details of their image reconstruction. Images can be constructed as spectral cubes with multiple frequency channels or single-plane wideband continuum images. One or more sub images may be defined to cover a wide field of view without incurring the computational expense of very large images. The iterative framework described above is based on the Cotton-Schwab Clean algorithm [\\[3\\]](#Bibliography), but variants like Hogbom Clean [\\[1\\]](#Bibliography) and Clark Clean [\\[2\\]](#Bibliography) are available as subsets of this framework. The major cycle allows controls over different data weighting schemes [\\[10\\]](#Bibliography) and convolution functions that account for wide-field direction-dependent effects during imaging and prediction \\[[\\[6\\]](#Bibliography), [\\[7\\]](#Bibliography) , [\\[8\\]](#Bibliography)\\]. Deconvolution options include the use of point source vs multi-scale image models [\\[4\\]](#Bibliography) , narrow-band or wide-band models [\\[5\\]](#Bibliography), controls on iteration step size and stopping criteria, and external constraints such as interactive and non-interactive image masks. Mosaics may be made with data from multiple pointings, either with each pointing imaged and deconvolved separately before being combined in a final step, or via a joint imaging and deconvolution [\\[9\\]](#Bibliography). Options to combine single dish and interferometer data during imaging also exist. More details about these algorithms can be obtained from \\[[\\[10\\]](#Bibliography), [\\[11\\]](#Bibliography), [\\[12\\]](#Bibliography), [\\[13\\]](#Bibliography)\\]\n",
"\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "NV7ewZJ4kum4"
},
"source": [
"## Types of images\n",
"\n",
"Ways to set up images (Cube vs MFS, single field, outliers, facets, Stokes planes ) and select data\n",
"\n",
"The visibility data can be selected in many ways and imaged separately (e.g. one spectral window, one field, one channel). Data selection can also be done in the image-domain where the same data are used to create multiple image planes or multiple images (e.g. Stokes I,Q,U,V, or Taylor-polynomial coefficients or multiple-facets or outlier fields).\n",
"\n",
"Parameters for data selection and image definition together define the following options.\n",
"\n",
"Data Selection | Imaging Definition\n",
"--- | ---\n",
"Spectral Axis | Cube (multiple channels) or MFS (single wideband channel) or MT-MFS (multi-term wideband images)\n",
"Polarization axis | Stokes Planes ( I, IV, IQUV, pseudoI, RR, LL, XX, YY, etc )\n",
"Sky Coordinates | Image shape, cell size, phasecenter, with or without outlier fields\n",
"Data Selection | One pointing vs multiple pointings for a mosaic, data from multiple MeasurementSets, etc.\n",
"\n",
"For the most part, the above axes are independent of each other and logical (and useful) combinations of them are allowed. For example, spectral cubes or wideband multi-term images can have outlier fields and/or mosaics. An example of a prohibited combination is the use of facets along with mosaics or a-projection as their algorithmic requirements contradict each other.\n",
"\n",
"\n",
"**Spectral Cubes:**\n",
"\n",
"During gridding, N Data channels are binned onto M image channels using several optional interpolation schemes and doppler corrections to transform the data into the LSRK reference frame. When data from multiple channels are mapped to a single image channel, multi-frequency-synthesis gridding is performed within each image channel. More details are explained on the [Spectral Line Imaging](synthesis_imaging.ipynb#spectral-line-imaging) page. As can be seen from the diagram, parallelization for cube imaging can be naturally done by partitioning data and image planes by frequency for both major and minor cycles.\n",
"\n",
"\n",
"{.image-inline width=\"460\" height=\"257\"}\n",
"\n",
"\n",
"**Continuum Images**\n",
"\n",
"Wideband imaging involves mapping data from a wide range of frequency channels onto a single image channel.\n",
"\n",
"*Multi Frequency Synthesis (MFS) - Single Wideband Image*\n",
"\n",
"Data from all selected data channels are mapped to a single broadband uv-grid using appropriate uvw coordinates, and then imaged. This is accessed via the \\\" *specmode=\\'mfs\\'* \\\" option in the **tclean** task. Since there is only one uv grid and image, parallelization for continuum imagng is done only for the major cycle via data partitioning.\n",
"\n",
"{.image-inline width=\"429\" height=\"216\"}\n",
"\n",
"\n",
"\n",
"*Multi-Term Multi Frequency Synthesis (MTMFS) - Taylor Coefficient Images*\n",
"\n",
"An improvement to standard MFS that accounts for changes in spectral index as a function of sky position is available that uses Taylor weighted averages of data from all frequencies accumulated onto NTerms uv-grids before imaging. These Taylor-weighted residual images form the input for the minor cycle of the Multi-Term MFS deconvolution algorithm which performs a linear least squares fit (see [Deconvolution Algorithms](synthesis_imaging.ipynb#deconvolution-algorithms) section for more information) during deconvolution to obtain Taylor Coefficients per component (to represent sky spectra as polynomials in $I$ vs $\\nu$). This option is accessed via \\\" *specmode=\\'mfs\\'* and *deconvolver*=\\'mtmfs\\', *nterms=2.* \\\" For the same data size as standard MFS (*nterms=1*), Multi-Term MFS will have $N_t$ times the gridding cost and number of images stored in memory. Parallelization is again done only for the major cycle via data partitioning.\n",
"\n",
"{.image-inline width=\"447\" height=\"285\"}\n",
"\n",
"*MTMFS via Cube* \n",
"\n",
"An alternate approach to constructing continuum images is by first making an Image Cube, and then performing Taylor-weighted averages in the image domain to form the NT Taylor-Weighted images. This mode is accessed via specmode='mvc' and is meant to be combined with deconvolver='mtmfs', nterms>1. This algorithmic approach allows for per channel primary beam correction prior to deconvolution.\n",
"\n",
"\n",
"**Polarization Planes**\n",
"\n",
"Data in the correlation basis are gridded onto separate planes per correlation, imaged, and then transformed into the Stokes basis. A special case for single plane Stokes I is implemented where data from both parallel hands are gridded onto a single uv-grid (to save memory). The point spread function is always taken from the Stokes I gridded weights. Images can be made for all Stokes parameters and correlation pairs (or all combinations possible with the selected data). This is an image-partitioning, where the same data are used to construct the different imaging products. Currently, if any correlation is flagged, all correlations for that datum are considered as flagged. An exception is the \\'*pseudoI*\\' option which allows Stokes I images to include data for which either of the parallel hand data are unflagged.\n",
"\n",
"\n",
"{.image-inline width=\"515\" height=\"271\"} \n",
"\n",
"\n",
"**Multiple Fields**\n",
"\n",
"A very large field of view can sometimes be imaged as a main field plus a series of (typically) smaller outlier fields. Imaging of fields with relatively few bright outlier sources can benefit from the overal reduction in image size that this option provides. Instead of gridding the visibilities data onto a giant uv-grid, they are gridded onto multiple smaller images. Each sub-image is then deconvolved via separate minor cycles and their model images combined to predict model visibiliitles to subtract from the data in the next major cycle. The user must specify different phase reference centers for each image field.\n",
"\n",
"Different image shapes and gridding and deconvolution algorithms can be chosen for the different outlier fields. For example, one could apply single-plane wideband imaging on the main field, but employ multi-term MFS for an outlier field to account for artificial spectral index due to the wideband primary beam at its location. One can also combine MFS and Cube shapes for different outlier fields, or choose to run Multi-Scale CLEAN on the main field and Hogbom CLEAN on a bright compact outlier. \n",
"\n",
"Overlapping fields are supported when possible (i.e. when the image types are similar enough across outliers) by always picking the \\\"last\\\" instance of that source in the list of outlier images in the order specified by the user. This convention implies that sources in the overlapping area are blanked in the \\\"earlier\\\" model images, such that those sources are not subtracted during the major cycles that clean those images.\n",
"\n",
"\n",
"{.image-inline width=\"479\" height=\"249\"}\n",
"\n",
"\n",
"**Multiple Facets**\n",
"\n",
"Faceted imaging is one way of handling the w-term effect. A list of facet-centers is used to grid the data separately onto multiple adjacent sub-images. The sub images are typically simply subsets of a single large image so that the deconvolution can be performed as a joint image and a single model image is formed. The PSF to be used for deconvolution is picked from the first facet. The list of phase reference centers for all facets is automatically generated from user input of the number of facets (per side) that the image is to be divided into.\n",
"\n",
"\n",
"{.image-inline width=\"513\" height=\"272\"}\n",
"\n",
"\n",
"**Mosaics**\n",
"\n",
"Data from multiple pointings can be combined to form a single large image. The combination can be done either before/during imaging or after deconvolution and reconstruction.\n",
"\n",
"*Stitched Mosaic*\n",
"\n",
"Data from multiple pointings are imaged and deconvolved separately, with the final output images being combined using a primary beam model as a weight. This is achieved by running the imaging task (**tclean**) separately per pointing, and combining them later on using the tool **im.linearmosaic**().\n",
"\n",
"{.image-inline width=\"467\" height=\"226\"}\n",
"\n",
"\n",
"*Joint Mosaic*\n",
"\n",
"Data taken with multiple pointings (and/or phase-reference centres) can be combined during imaging by selecting data from all fields together (multiple field-ids), and specifying only one output image name and one phase-reference center. If mosaic mode is enabled (*gridder=\\'mosaic\\'* or *\\'awproject\\'*) attention is paid to the pointing centers of each data-fieldID during gridding. Primary-beam models are internally used during gridding (to effectively weight the images that each pointing would produce during a combination) and one single image is passed on to the deconvolution modules.\n",
"\n",
"\n",
"{.image-inline width=\"448\" height=\"218\"}\n",
"\n",
"\n",
"***\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "173soUgKkum6"
},
"source": [
"## Imaging Algorithms\n",
"\n",
"Imaging is the process of converting a list of calibrated visiblities into a raw or \\'dirty\\' image. There are three stages to inteferometric image-formation: weighting, convolutional resampling, and a Fourier transform.\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "7zq3XxUGtLad"
},
"source": [
"### Data Weighting\n",
"\n",
"During imaging, the visibilities can be weighted in different ways to alter the instrument\\'s natural response function in ways that make the image-reconstruction tractable.\n",
"\n",
"Data weighting during imaging allows for the improvement of the dynamic range and the ability to adjust the synthesized beam associated with the produced image. The weight given to each visibility sample can be adjusted to fit the desired output. There are several reasons to adjust the weighting, including improving sensitivity to extended sources or accounting for noise variation between samples. The user can adjust the weighting using **tclean** and changing the *weighting* parameter with seven options: \\'natural\\', \\'uniform\\', \\'briggs\\', \\'superuniform\\', \\'briggsabs\\', \\'briggsbwtaper\\', and \\'radial\\'. Optionally, a UV taper can be applied, and various parameters can be set to further adjust the weight calculations.\n",
"\n",
"\n",
"**Natural weighting**\n",
"\n",
"The natural weighting scheme gives equal weight to all samples. Since usually, lower spatial frequencies are sampled more often than the higher ones, the inner uv-plane will have a significantly higher density of samples and hence signal-to-noise than the outer uv-plane. The resulting \\\"density-upweighting\\\" of the inner uv-plane will produce the largest angular resolution and can sometimes result in undesirable structure in the PSF which reduces the accuracy of the minor cycle. However, at the location of a source, this method preserves the natural point-source sensitivity of the instrument.\n",
"\n",
"For *weighting=\\'natural\\'*, visibilities are weighted only by the data weights, which are calculated during filling and calibration and should be equal to the inverse noise variance on that visibility. Imaging weight $w_i$ of sample $\\dot\\imath$ is given by:\n",
"\n",
"$w_i = \\omega_i = \\frac{1}{{\\sigma_i}^2}$\n",
"\n",
"where the data weight $\\omega_i$ is determined from $\\sigma_i$, the rms noise on visibility $\\dot\\imath$. When data is gridded into the same uv-cell for imaging, the weights are summed, and thus a higher uv density results in higher imaging weights. No sub-parameters are linked to this mode choice. It is the default imaging weight mode, and it should produce \"optimum\" image with with the lowest noise (highest signal-to-noise ratio).\n",
"\n",
"