ALMA Memo 620

# Self-calibration and improving image fidelity for ALMA and other radio
interferometers

A. M. S. Richards1, E. Moravec2,3, S. Etoka1, E. B. Fomalont4,
A. F. Pérez-Sánchez5, M. C. Toribio6 and R. A. Laing7
1 JBCA, Department of Physics and Astronomy, University of Manchester, UK
2 Czech ARC Node, Astronomical Institute of the Czech Academy of Sciences,
Czech Republic
3 Green Bank Observatory, West Virginia, USA
4 NRAO, Edgemont Road, Charlottesville, VA 22903, USA
5 Leiden Observatory, Leiden University, PO Box 9513, 2300 RA Leiden, The
Netherlands.
6 Department of Space, Earth and Environment, Chalmers University of
Technology,
Onsala Space Observatory, 439 92 Onsala, Sweden
7 SKA Organization, Jodrell Bank, Cheshire, SK11 9DL, UK

###### Abstract

This manual is intended to help ALMA and other interferometer users improve
images by recognising limitations and how to overcome them and deciding when
and how to use self-calibration. The images provided by the ALMA Science
Archive are calibrated using standard observing and data processing routines,
including a quality assurance process to make sure that the observations meet
the proposer’s science requirements. This may not represent the full potential
of the data, since any interferometry observation can be imaged with a range
of resolutions and surface brightness sensitivity. The separation between
phase calibration source and target usually limits the target dynamic range to
a few hundred (or 50–100 for challenging conditions) but if the noise in the
target field has not reached the thermal limit, improvements may be possible
using self-calibration. This often requires judgements based on the target
properties and is not yet automated for all situations. This manual provides
background on the instrumental and atmospheric causes of visibility phase and
amplitude errors, their effects on imaging and how to improve the signal to
noise ratio and image fidelity by self-calibration. We introduce the
conditions for self-calibration to be useful and how to estimate calibration
parameter values for a range of observing modes (continuum, spectral line
etc.). We also summarise more general error recognition and other techniques
to tackle imaging problems. The examples are drawn from ALMA interferometric
data processed using CASA, but the principles are generally applicable to most
similar cm to sub-mm imaging.

###### Contents

  1. 1 Introduction
    1. 1.1 Aims and outline of this manual
    2. 1.2 Interferometric calibration
    3. 1.3 The effects of phase errors on image fidelity
    4. 1.4 Conventions and terminology
  2. 2 Origins and effects of interferometric errors
    1. 2.1 Phase errors
      1. 2.1.1 Tropospheric phase errors
      2. 2.1.2 Ionospheric errors
      3. 2.1.3 Thermal noise
      4. 2.1.4 Antenna position errors
    2. 2.2 Amplitude errors
      1. 2.2.1 Flux density scale
    3. 2.3 Closure relations and the minimum number of antennas for solutions
  3. 3 Effects of errors after phase referencing
    1. 3.1 Illustrating phase and amplitude errors and their correction
    2. 3.2 Quantifying target residual phase errors after phase referencing
    3. 3.3 Dynamic range
    4. 3.4 Flux scale errors
    5. 3.5 Image resolution and position accuracy
      1. 3.5.1 Noise and resolution
      2. 3.5.2 Relative position accuracy
      3. 3.5.3 Astrometric accuracy
  4. 4 Practical self-calibration
    1. 4.1 Quick-start overview
    2. 4.2 How to tell if a data set is worth self-calibrating
      1. 4.2.1 Measuring the signal to noise ratio
      2. 4.2.2 Conditions for self-calibration
    3. 4.3 Making a preparatory image and model
      1. 4.3.1 Imaging for self-calibration
      2. 4.3.2 Inserting the model for self-calibration in the MS
    4. 4.4 Deriving the self-calibration solution table (gaincal)
      1. 4.4.1 Choice of reference antenna
      2. 4.4.2 Phase self-calibration and choosing the solution interval
    5. 4.5 Amplitude self-calibration
      1. 4.5.1 Multi-frequency synthesis for amplitude self-calibration
    6. 4.6 Judging the quality of solution tables, failed solutions and flagging
      1. 4.6.1 Assessing phase solutions
      2. 4.6.2 Assessing amplitude solutions
      3. 4.6.3 Flagging
    7. 4.7 Applying the calibration (applycal)
      1. 4.7.1 Weights
    8. 4.8 Modified workflows
    9. 4.9 When to stop self-calibrating
  5. 5 Special Circumstances
    1. 5.1 Transferring solutions between spectral windows/across frequency differences
      1. 5.1.1 Transferring solutions between MS
      2. 5.1.2 Use of Diff Gain Cal
    2. 5.2 Spectral line self-calibration
      1. 5.2.1 Aligning data in rest frame of target
      2. 5.2.2 Line self-calibration and the presence of continuum emission
    3. 5.3 Extending self-calibration from a time selection to all target data
    4. 5.4 Resolved phase calibrator
    5. 5.5 Observations without phase referencing or problem phase calibrators
      1. 5.5.1 First round of self-calibration without phase referencing
      2. 5.5.2 Developing the image and model structure
      3. 5.5.3 Implications of no phase-referencing
    6. 5.6 Primary beam correction, heterogeneous arrays and smearing
    7. 5.7 Mosaics
    8. 5.8 Wide-field (anisoplanatic) calibration
    9. 5.9 Polarisation
    10. 5.10 Low S/N and calibration problems
      1. 5.10.1 Calibration parameters to make the best of low S/N data
      2. 5.10.2 More averaging
      3. 5.10.3 Solving for phase or rate by gradient or spline fitting
    11. 5.11 Combining interferometric observations
      1. 5.11.1 Same configuration, different executions or spectral scans
      2. 5.11.2 Combining array configurations
    12. 5.12 Extended emission, Solar System Ephemeris Objects and the Sun
    13. 5.13 Baseline-dependent calibration
  6. 6 Imaging problems and diagnostics
    1. 6.1 Stripes and other structured artefacts
    2. 6.2 Optimise imaging
    3. 6.3 Missing spacings
    4. 6.4 Confusion
    5. 6.5 Noisy images and non-noisy blurring
    6. 6.6 Errors during observations or previous calibration
      1. 6.6.1 Delay and phase errors and the effects of antenna position uncertainty
      2. 6.6.2 Noise/artefacts due to phase-reference and other problems
    7. 6.7 Amplitude errors due to $T_{\mathrm{sys}}$, antenna pointing or tracking errors
    8. 6.8 Target Variability
  7. A Abbreviations and symbols
  8. B Online resources
    1. B.1 Schools and workshops
    2. B.2 CASA Guides
    3. B.3 CASA Documentation
    4. B.4 Sensitivity calculators
    5. B.5 Other resources
  9. C Guidance for self-calibration parameters in gaincal and applycal
    1. C.1 gaincal
    2. C.2 applycal
  10. D Example script fragments
    1. D.1 Aligning multiple data sets and other position changes
    2. D.2 Deriving flux scale from $T_{\mathrm{sys}}$ and adjustments to visibilities in gencal
    3. D.3 Flux scale correction for very bright continuum sources
    4. D.4 Measuring image noise (imstat)
    5. D.5 Using AIPS images as models
  11. E ALMA smearing limits

##  1 Introduction

###  1.1 Aims and outline of this manual

Self-calibration involves correcting the visibility phases and amplitudes of a
source by comparing the visibility data with a model of the source itself
(usually derived in previous imaging of that source), which is used to
estimate the corrections needed to make the data resemble the model more
closely. The term is usually used to describe improving the imaging fidelity
of science targets.

Phase referencing is the technique of deriving phase and amplitude solutions
for a source with an accurate position and well-known (usually point-like)
structure, within a small angular separation (typicially a few degrees) from
the target, observed every few minutes alternately with the target. These
solutions are then applied to the target, which assumes that the same
atmospheric and instrumental errors affect the phase calibration source and
the target, so the same corrections work for both (regardless of the source
structure). In reality, the difference in time and angular separation between
the phase calibrator and the target means that the atmosphere, and possibly
other causes of error, are somewhat different and the target data are not
perfectly corrected by phase calibrator solutions. If the target S/N (signal
to noise) is high enough then more accurate corrections can be derived using
self-calibration. This often takes a number of cycles of imaging and
calibration to improve the model and hence the corrections if the target has a
complex structure.

The aim of this manual is to relate practical self-calibration to more formal
explanations of the origins and correction of interferometric errors, e.g.
Thompson et al. (2017). As such, we provide references rather than rigorous
derivations. The relationships developed here are not rigid recipes but are
intended to guide setting parameter values for self-calibration, or for
explaining the techniques in writing up results. Self-calibration is well
explained in Ch. 10 (Cornwell & Fomalont) of the proceedings of the NRAO/NMIMT
Synthesis Imaging summer school 1998 ([SI99] et al. (1999), hereafter SI99),
and in a lecture from the 2017 school (Brogan et al. 2018) on advanced
calibration; the challenge here is to update/expand the parts relevant to
self-calibration. This manual uses ALMA examples, which are relevant other
arrays, albeit more so for other mm-wave arrays and cm-wave arrays like the
VLA in extended configurations. The principles are similar even for low-
frequency, wide-field dipole arrays or space VLBI but the additional
considerations for such extreme situations are not covered, nor are
terrestrial applications such as Geodesy.

This Section provides context, summarises why phase (self-)calibration in
particular is important and explains some basic jargon. Section 2 describes
the causes of errors in radio interferometry, especially relevant to (sub-)mm
observations, and quantifies their effects. Section 3 concentrates on cause
and effect of the residual errors affecting a target after phase-reference and
other calibration has been applied. These Sections provide the background to
understand how self-calibration works, but the concepts are best understood
through experience so you can start with Section 4 which provides a quick-
start guide for continuum self-calibration followed by expressions and
examples (in CASA) to help decide when to self-calibrate, how to derive
suitable parameter values (such as solution interval), how to assess/improve
the quality of the results and when to stop. Section 5 covers a wide range of
situations such as spectral line self-calibration and Section 6 illustrates
image errors and how to tell if self-calibration might reduce these. The
Appendices provide links to other resources and some examples of CASA task
settings and code fragments.

###  1.2 Interferometric calibration

Correlated radio interferometry data are recorded for each sample as complex
visibilities, $V$, given by

$V={\mathbf{J}}_{ij}V_{0}e^{i\phi}$ (1)

where $V_{0}$ and $\phi$ are the ‘true’ amplitude and phase of each visibility
(per baseline between antennas $i$ and $j$, unit time, spectral channel and
polarisation product). These contain atmospheric and instrumental errors
collectively grouped as ${\mathbf{J}}_{ij}$. Antenna-based errors are formed
by taking the outer product of the response from antenna $i$ and the conjugate
of the response from antenna $j$, so for these terms ${\mathbf{J}}_{ij}$ is
shorthand for ${\mathbf{J}}_{i}\otimes{\mathbf{J^{*}}}_{j}$.

Interferometric calibration is described formally by solving appropriate terms
in the Measurement Equation as developed in Sault et al. (1996), see also e.g.
SI99 Ch. 32 (Sault & Cornwell) and Thompson et al. (2017) Ch. 4. The most
relevant terms for self-calibration are:

$\displaystyle\boldsymbol{V}\\!_{ij,\nu}(u,v)$ $\displaystyle=$
$\displaystyle\int\\!\mathbf{E}_{ij}\mathbf{T}_{ij}\mathbf{P}_{ij}\boldsymbol{I}_{\nu}(l,m)e^{-2{\pi}i(u_{ij}l+v_{ij}m)}dldm$
(2) $\displaystyle\times\>\mathbf{B}_{ij}\mathbf{G}_{ij}\mathbf{M}_{ij}$

$\boldsymbol{V}\\!_{ij,\nu}$ represents the complex visibility on a baseline
between antennas $i$ and $j$, at frequency $\nu$, in the $uv$ plane.

The right hand side represents the Fourier transform of the brightness
distribution $\boldsymbol{I}_{\nu}$ in the sky ($lm$) plane, multiplied by
errors. The field of view of a single pointing of an array is determined by
the resolution, termed the primary beam, of the individual antennas (assuming
they are all the same size). The effective primary beam (PB) is usually taken
as the extent of the response down to some fraction such as 0.5 or 0.2
sensitivity, see ALMA-TH ch 3. The first row of terms are known as direction-
dependent errors as the PB response may differ with angle or distance from the
pointing centre. The next row represents multiplicative errors which are
(usually) independent of the position of the source within the PB. These
errors collectively contribute to ${\mathbf{J}}_{ij}$ in Eq. 1; there are many
more but the individual terms shown here are those most relevant to self-
calibration:

  * •

Antenna-based

    * $\mathbf{E}$

‘Electric’ Antenna voltage pattern including primary beam and related effects.

    * $\mathbf{P}$

Parallactic angle rotation (i.e. the change in the orientation of the feeds
with respect to the sky as an alt-az telescope tracks a target).

    * $\mathbf{T}$

‘Tropospheric’ and other atmospheric effects on the gain manifested as time-
dependent scaling of amplitudes and drifts of phases.

    * $\mathbf{B}$

Bandpass response affecting amplitude and phase.

    * $\mathbf{G}$

Gain distortions including scaling due to instrumental effects (e.g. in signal
transmission).

  * •

Baseline-based

    * $\mathbf{M}$

Multiplicative, baseline errors e.g. introduced in the correlator, associated
with specific baselines but not all baselines to the antennas involved. These
can affect phase and amplitude as a function of time and/or frequency and are
sometimes known as non-closing errors (Sec. 5.13). Similar bandpass-related
terms are known as $\mathbf{M}^{\mathrm{f}}$.

This omits polarisation-related effects which are normally corrected before
self-calibration. $\mathbf{E}$ and $\mathbf{P}$ are not normally changed by
self-calibration either, but the PB correction must be applied (only) at the
end of self-calibration (Sec. 4.3.1). See Secs. 4 and 4.4 for more explanation
and specifics of the implementation in CASA, including Appendix C.1 for the
use of gaincal ’T’ and ’G’ parameters which are used to denote corrections
derived for the receiver polarisations (e.g. X, Y) averaged and separately,
respectively, regardless of origin.

A basic guide to parameter settings for ALMA is provided by the CASA
introduction to self-calibration, along with a recent NRAO Summer School
lecture, Brogan et al. (2018) and material for schools “Self-calibration and
advanced imaging (Bologna 2017)” and “I-TRAIN 6: Improving image fidelity
through self-calibration” which also provide links to the VY CMa data and
scripts used for examples in this manual (see Appendix B.1). More scripts to
use for practice or as templates are available in other the CASA Guides and
other online guides and resources, given in Appendix B.

Most examples are designed for ALMA data wherein the sky and other causes of
signal distortion are the same across the field of view of each antenna
(isoplanaticism), so the direction-dependent aspects of the terms given in Eq.
2 can be ignored. This is not the case for wide fields at frequencies below a
few GHz. Specific problems also arise for ALMA (or any) observations of the
Sun and other bright, beam-filling objects. These issues are touched on in
Secs. 5.8 and 5.12; you should consult specialised (e.g. LOFAR or Solar)
guides for more information, see Appendix B.2.

###  1.3 The effects of phase errors on image fidelity

Figure 1: NGC 3256 (from CASA Guide): Images left to right (note different
flux scales): After applying phase calibrator solutions, phase errors dominate
giving anti-symmetric errors with positive artefacts opposite negative
artefacts). After phase self-calibration, the artefacts are at a reduced
level, dominated by amplitude errors, producing the symmetric artefacts seen.
After phase and amplitude self-calibration, small anti-symmetric artefacts
remain.

Phase errors generally have the most severe effects for ALMA data. Using a
simple point source observed at the pointing centre as an example, its
visibility amplitude $V_{0}$ should be constant and the same on all baselines
and the phase $\phi$ should be flat at zero (see Eq. 1). If the phase has a
Gaussian error distribution with rms variation of $\phi_{\mathrm{rms}}$ (in
radians) over the interval used for imaging then the image amplitude is given
by

$\langle V\rangle=V_{0}\langle
e^{i\phi_{\mathrm{obs}}}\rangle=V_{0}e^{-\phi^{2}_{\mathrm{rms}}/2}$ (3)

where angle brackets represent the expectation value, see e.g. Thompson et al.
(2017) Ch. 7.2.8 for a derivation. Thus a random phase error of
$\phi_{\mathrm{rms}}=10^{\circ}$ = 0.1745 rad gives $\langle
V\rangle=0.98V_{0}$, i.e. a 2% loss of coherence and reduction in amplitude
(often referred to as decorrelation); however a $65^{\circ}$ phase error will
reduce the peak by almost 50%. The power has to go somewhere, therefore the
off-source noise can be noticeably increased by severe decorrelation.

The complex visibility function of Eq. 1 can be expressed as
$V=V_{0}(\cos\phi+i\sin\phi)$. The Fourier transform of the imaginary part,
the sine function (corresponding to phase), is anti-symmetric delta functions,
alternately positive and negative (see SI99, Ch. 15 (Ekers) fig. 15.1). This
implies that phase errors produce anti-symmetric image errors, see Fig. 1.
Analogously, amplitude errors produce symmetric image errors.

###  1.4 Conventions and terminology

We introduce briefly the structure and terminology used for ALMA observations
used in the manual. Please see the ALMA Technical Handbook for the current
cycle (currently 9), [ALMA-TH], Cortes (2022), hereafter ALMA-TH for all
details of ALMA observing and an overview of instrumentally-derived
corrections and phase referencing. A spectral window (spw) is a spectral
region selected for observation; up to 4 can be observed at once at the full
spw width of 2 GHz. In dual polarisation a full-width spw can be correlated
using Time Domain Multiplexing (TDM) into 128 $\times$ 15.625 MHz channels.
Alternatively, 2 GHz or narrower spw can be correlated using Frequency Domain
Multiplexing (FDM) into up to 4096 channels, usually averaged by factors of at
least 2 (or 4, 8, …). The number of channels (pre-averaging) is halved for
full polarisation observations. The first and last 1/32 channels are typically
trimmed.

An ALMA Execution Block (EB) is a self-contained set of observations of one or
more targets and calibrators, which may be repeated multiple times. A spectral
scan consists of two or more EBs identical except for offsets in frequency to
produce wider spectral coverage.

We often refer to a field rather than a source, because in imaging and
calibration all detectable emission in the field of view should be included,
not just the source at the telescope pointing centre. The relevant field of
view is usually taken as the half-power point of the PB (FWHM, full width half
maximum) but may be much larger if there are any sources bright enough to
produce sidelobes at, say, 10% or even 1% sensitivity (such as the parent
planet in observations of a moon). For many ALMA observations, especially with
the main array of 12-m dishes, there is nothing else detectable but for
observations which are sensitive to low surface brightness emission (e.g.
using the ACA, Atacama Compact Array, also with a wider field of view from 7-m
dishes) there is often much extended emission when looking at nearby galaxies
or star-forming regions.

The shortest data averaging time, i.e. the duration of a single visibility (as
defined in Eqs. 2, 1) is the integration, typically $\sim$6 sec for calibrated
12-m array ALMA data (2 sec on long baselines) and $\sim$10 sec for the ACA. A
scan is the length of time spent continuously on a particular source e.g. the
target. Typically there are source changes every few minutes, e.g. in phase
referencing there will be a series of scans of 2 : 5 : 2 mins on the phase
calibrator : target : phase calibrator (etc.) which should always start and
finish with the phase calibrator. At sub-mm frequencies and/or on long
baselines the scans are shorter. Occasionally, a very long ‘stare’ on a single
field (such as for rapidly variable sources or for tests of phase stability
etc. as in Maud et al. 2016) may be divided into scans without a source
change.

Visibility data is customarily plotted on the $uv$ plane, and, for example,
$uv$ distance means distance in the visibility plane, i.e. projected baseline
length in wavelength units. A set of visibility data has at least two
‘centre’s: the pointing centre, which is where the telescopes pointed, which
cannot (for dishes like ALMA) be changed retrospectively, and the phase
centre, where perfectly-calibrated emission from a specific celestial
direction would be exactly in phase. By default these are the same but the
phase centre can be changed by rotating the visibility phases (adding the
required phase offsets) to anywhere within the field of view, for example to
correct for a small offset between two observations to be combined.

The receiver system is sensitive to two polarisations, X and Y in the case of
ALMA. These are combined in the correlator to make parallel hand correlations
XX and YY (occasionally just one correlation) and, optionally, the cross hands
XY and YX (in which case the maximum number of channels per spw is halved to
2048). Self-calibration is normally performed using the total intensity
(XX+YY) image model, deriving antenna-based phase corrections for X and Y
(these can be averaged, for weak sources or amplitude self-calibration, see
Secs. 4.5, 5.9 and 5.10.2).

Historically, the term ‘gain’ referred to the increase in antenna power
recorded on-source. It is now often used to refer to correction factors
derived for the visibilities, i.e. a gain table, which can contain phase
and/or amplitude calibration (as in the formalism in Eq. 2).

All examples in this manual refer to CASA111https://casa.nrao.edu/, in which,
in calibration, the complex visibilities are divided by the complex factors
recorded in the gain tables: visibility amplitudes are divided by the
corrections, and the phase corrections are subtracted from the visibility
phases. Thus, an anomalously low visibility amplitude should correspond to a
low value for the derived correction (this is the opposite of the AIPS
convention). Imaging examples refer to tclean and it is assumed that you have
some familiarity with CASA and calibrating and imaging mm- or cm-wave
interferometry data; see a basic CASA Guide (links in Appendix B.2) first if
necessary.

Abbreviations and acronyms are listed in Appendix A. Subscript
${\mathrm{rms}}$ generally denotes an observed error e.g. in phase,
$\phi_{\mathrm{rms}}$, whilst $\epsilon$ generally indicates a predicted or
modelled contribution to the total error e.g. $\phi_{\epsilon,\mathrm{trop}}$.

##  2 Origins and effects of interferometric errors

Interferometric calibration is derived and applied at several stages, see
ALMA-TH for more details of the standard processes for ALMA:

  1. 1.

Calibration during observations: Some calibration is calculated from known or
approximated properties of the array or atmosphere in ‘real time’ and applied
during observations, such as updates to pointing offsets.

  2. 2.

Calibration before/during correlation: This includes the bulk delay correction
for the effect of atmospheric refraction which reduces the magnitude of post-
correlator phase corrections per solution interval, ideally $<|2\pi|$. ALMA
uses known observing parameters (array geometry, elevation, frequency etc.) to
make an approximate prediction.

  3. 3.

Corrections derived from instrumental measurements, applied after correlation:
Other measurements made during observations are recorded and used to derive
corrections during later processing e.g. in the pipeline. The system
temperature ($T_{\mathrm{sys}}$, Eq. 7) is measured every few minutes. For the
12-m array, the precipitable water vapour (PWV) column above each antenna is
measured every few seconds using water vapour radiometry (WVR) at 183 GHz, and
used to estimate the atmospheric refraction at the observing frequency. A
look-up table of known antenna position corrections is provided. Antenna
positions and the flux densities of standard calibrators are measured using
separate observations and provided in the recorded data, but may occasionally
be updated later.

  4. 4.

Calibration derived from astronomical calibration sources: QSO or other
sources are used for bandpass, flux scale, phase reference and sometimes other
calibration e.g. polarisation. These are observed at the phase centre and have
good models – typically point sources of specified flux density, or with a
model provided such as derived from from an ephemeris for Solar system
objects. The data are calibrated by comparison with the source model, a
process analogous to self-calibration but using an a-priori model instead of
imaging during calibration (but see Sec. 5.5 for when this is not adequate).
These stages are performed using standard calibration (QA2) scripts and/or the
ALMA Pipeline; most other observatories have analogous procedures.

  5. 5.

Self-calibration: This term is normally used to describe further calibration
of science targets, after applying the corrections derived from other
measurements and sources as above and is usually carried out by the proposer’s
or archive user’s team.

ALMA correlates data directly as it is observed and calibrations 1. and 2. are
applied by ALMA before the data is recorded, i.e. they are irreversible. Later
corrections can be made for small residual errors but not severe errors which
change rapidly (e.g. phase error $\gg\pi$ radians) within the shortest
solution interval feasible for later calibration. This is in contrast to some
VLBI where data are recorded at each telescope and parameters can be corrected
before correction, including adjusting the apparent phase centre (as long as
it remains within the PB); this is not the case for ALMA. Calibrations 3., 4.,
5. can be adjusted and re-applied multiple times if necessary.

Self-calibration primarily corrects residual time-dependent phase and
amplitude errors remaining after calibrations 3. and 4., such as by the
pipeline or manual QA2. The dominant cause of errors in ALMA observations is
usually the troposphere, especially on longer baselines and/or at higher
frequencies, or in less good weather. Other atmospheric effects can become
noticeable when seeking high dynamic range/high sensitivity images and antenna
position and pointing errors can be mitigated. These effects are described
below.

Figure 2: Cartoon (inspired by SI99 Ch. 28 Carilli, Carlstrom & Holdaway) of a
distant mm-wave wavefront originating above the Earth’s atmosphere.
Tropospheric water vapour, with structure on multiple scales, refracts the
rays, the main effect being a delay (so rays which were in phase become out of
phase) with a much smaller bending effect. Dry air also exerts some refraction
which has more impact on larger scales. Antennas 1 and 2 are so close together
that the refraction above them is almost identical. Comparing their location
to antennas 3 and 4, there are appreciable differences due to both vertical
and horizontal water vapour content fluctuations but with some large scale
similarities. Finally, for antenna 5, which is much more distant than the
vertical depth of the troposphere, there is no appreciable correlation of
atmospheric conditions with respect to the other antennas.

###  2.1 Phase errors

This section provides the background to the origin of phase errors (their
practical consequences and quantification are covered in 3.2). These include
general atmospheric effects; ALMA avoids observing in high winds, rain and
snow, which are fortunately rare but have a severe effect. For other arrays,
clouds have a small effect at frequencies $\nu\lessapprox$15 GHz but snow on
the telescope or water/ice on the sub-reflector or receiver cover causes
aberration and absorption. Strong, and especially gusty, winds degrade the
pointing accuracy as well as causing rapid atmospheric fluctuations. The main
effects are dealt with in more detail in the following subsections.

####  2.1.1 Tropospheric phase errors

The troposphere extends to 10–15 km above sea level, taken as having a typical
height of 5 km above Chajnantur. Tropospheric phase errors are mainly due to
refraction by water vapour although the structure of dry air important on
scales longer than a few km. Figure 2 is a cartoon illustrating how the
tropospheric water vapour distribution becomes significantly less correlated
the longer the baseline. This is quantified as explained in SI99 Ch. 28
(Carilli, Carlstrom & Holdaway) and summarised by Brogan et al. (2018) sec.
3.1. The typical wind speed above ALMA is 5–10 m s-1, or 18–36 km hr-1.

The refractive index of water is constant over almost all the ALMA bands
(“non-dispersive”), giving a linear relationship between the phase error and
frequency

$\phi_{\epsilon,\mathrm{trop}}\propto\nu w/T_{\mathrm{atm}}$ (4)

for a given PWV column $w$ and atmospheric temperature $T_{\mathrm{atm}}$,
both of which are measured. The use of WVR-derived corrections relies on this.
The water vapour content and thus refraction varies with time and the
magnitude of the resulting phase errors scales with increasing baseline length
and increasing frequency. For typical ALMA conditions, the phase error is
given by

$\phi_{\epsilon,\mathrm{trop}}=KB^{\alpha_{\mathrm{K}}}/\lambda$ (5)

The wavelength $\lambda$ is in mm and the baseline length is $B$ km. $K$ is
the Kolmogorov coefficient for tropospheric turbulence (in the same units as
$\phi_{\epsilon,\mathrm{trop}}$, here, degrees). $\alpha_{\mathrm{K}}$ is
predicted to be 5/6 for $B<1$ km (where the antenna separation is less than
the depth of the tropospheric layer (baselines 1-3, 1-4, 2-3, 2-4 in Fig. 2)
or 1/3 for $1<B<10$ km (all baselines to antenna 5), falling towards zero on
very long baselines if the atmosphere behaves independently above each
telescope. $K$ was expected to be 100 for raw ALMA data. Tests at mm-
wavelengths on baselines of a few km, under conditions of a few mm PWV, show
that $K\lesssim 50$ can be attained when WVR or other good phase corrections
are possible.

An ALMA study (Maud et al. 2016) shows that in these observations the rate of
increase of phase errors is, as predicted, much less steep for baselines
longer than a few km, see Fig. 3. The phase rms is roughly halved by applying
WVR corrections. The phase rms is given in terms of the path length
fluctuation $\phi_{\mathrm{rms\mu}}$ in micron, at wavelength $\lambda$ in mm,
and assuming that $\phi_{\epsilon,\mathrm{trop}}$ dominates, this is related
to the observed phase rms in degrees $\phi_{\mathrm{rms}}$ by

$\phi_{\mathrm{rms}}=360^{\circ}\times\phi_{\mathrm{rms\mu}}\times
10^{-6}/(\lambda\times 10^{-3}).$ (6)

Thus, from Fig. 3, typical raw phase errors are 50 – few 100 degrees and
residual phase errors after phase referencing and applying the WVR correction
are a few tens degrees at $\lambda$ 1 mm.

Figure 3: Temporal phase variation due to atmospheric variations as a function
of baseline length, adapted from ALMA Memo 606 (Maud et al. 2016) fig 1. A QSO
was observed at PWV $\sim$0.6 mm. The phase rms before and after applying WVR
corrections is shown in blue (upper circles) and red (lower circles),
respectively. The dark grey and yellow lines are the inferred improvements in
phase rms from referencing to a phase calibrator source within 3∘ on
timescales of 2 min and 20 sec, respectively. The band numbers listed on the
right mark the phase rms values in $\mu$m required for 30∘ phase rms in each
frequency range, see Eq. 6 for conversion to phase in degrees.

A few frequency ranges in ALMA bands may show non-linearity of delay with
frequency due to strong telluric lines. The accuracy of corrections derived
from WVR measurements is affected by clouds (i.e. water droplets, not vapour),
see Maud et al. (2017) and Remcloud in Appendix B.5. At the other extreme, if
the PWV is very low, dry air turbulence is dominant, especially on scales over
a few km.

####  2.1.2 Ionospheric errors

The ionosphere extends outwards from about 50 km above sea level, as the
atmosphere becomes increasingly ionised. At a given location and observing
angle, the ionospheric refraction is directly proportional to the TEC (total
free electron content along the ionospheric path in $10^{16}$ electrons m-2).
Refraction of radio waves by free electrons is proportional to $\nu^{-2}$ and
is often assumed to be negligible at wavelengths shorter than a few cm.
However, investigations for VERA (Jung et al. 2011; Nagayama et al. 2020)
showed that – especially around dawn and dusk – the difference between the
electron density (measured as $\Delta\mathrm{TEC}$) above well-separated
antennas can be enough to cause very significant delays at 22 GHz. An example
in Jung et al. (2011) fig. 3 shows that at 22 GHz, for $\Delta\mathrm{TEC}=3$
the residual phase error is up to $\sim 60^{\circ}$ so
$\phi_{\mathrm{rms}\mu}\approx 2200\mu$m (Eq. 6). Scaling
$\phi_{\mathrm{rms}\mu}$ from 22 GHz to 100 GHz by $\nu^{-2}$ the delay would
be 0.1 mm at 100 GHz, corresponding to 12∘ phase error. The combined effect of
ionospheric delay ($\propto\nu^{-2}$) and refractive delay Eq. 6 (phase error
$\propto\nu$) gives a scaling effect on phase $\propto 1/\nu$ for different
observing frequencies under the same observing conditions.

Whilst at present (June 2021) the total TEC across South America at the
latitude of ALMA is 30–40 TEC so the difference over the longest ALMA
baselines of 16 km, during a few minutes scan, is $\Delta\mathrm{TEC}\sim 0.1$
(i.e. negligible differential ionospheric refraction at mm wavelengths), TEC
values can exceed 140 during Solar maxima or storms. If this gives a five-fold
increase in $\Delta\mathrm{TEC}$, this would still only be a phase error
$\sim$$2^{\circ}$ on a 16 km baseline for ALMA at Band 3, but would become
noticeable if longer baselines are added and for VLBI. Whilst these effects
are small enough to be solved by self-calibration, this will be an issue for
astrometric measurements and also if band-to-band calibration (Asaki et al.
2020b, a) is used, since standard transfer techniques assume that phase errors
scale as $\phi_{\epsilon,\mathrm{trop}}\propto\nu$, without a contribution
scaled as $\phi_{\epsilon,\mathrm{ion}}\propto 1/\nu$. It is also worth noting
that some targets are viewed through enough ionised media, such as the centre
of the Galaxy towards Sgr A*, to cause strong refraction even at a few mm
wavelength.

####  2.1.3 Thermal noise

The thermal noise arising from the receiver and other instrumental systems,
atmospheric emission and other heat sources is characterised as
$T_{\mathrm{sys}}$.

$T_{\mathrm{sys}}=\frac{1+g}{\eta e^{\tau_{0}\sec
z}}\left(T_{\mathrm{Rx}}+\eta
T_{\mathrm{sky}}+(1-\eta)T_{\mathrm{amb}}\right).$ (7)

$g=1$ for double sideband receivers (ALMA bands 9 and 10) and 0 otherwise,
$\eta$ is the effective antenna efficiency (see ALMA-TH for ALMA values).
$\tau_{0}$ is the zenith opacity and $z$ is the zenith angle.
$T_{\mathrm{Rx}}$, $T_{\mathrm{sky}}$ and $T_{\mathrm{amb}}$ are the receiver
system temperature, the sky signal and background and local (e.g. ground)
contributions to temperature (see ALMA-TH for more precise details of these
terms). These relationships are used to predict the image noise rms
($\sigma_{\mathrm{rms}}$) for a given observation (see Eq. 22) and by the ALMA
and other sensitivity calculators, see Appendix B.4.

The minimum phase error resulting from noise can be estimated based on
Richards (1997) (derived using Thompson et al. 2017) as
$\phi_{\mathrm{rms}}=\sigma_{\mathrm{rms}}/P$ where $\sigma_{\mathrm{rms}}$
and $P$ are the image noise and peak, i.e. the phase noise in radians is given
by 1/(S/N).

####  2.1.4 Antenna position errors

Hunter et al. (2016) summarises the factors affecting the accuracy of ALMA
antenna position measurements; since 2016 many of the improvements suggested
have been implemented. If data are taken soon after an antenna relocation,
position updates are supplied within a few days, also see Sec. 2.1.4 for
observational symptions and implementing updates.

What is of concern, especially in early data, is unknown antenna geographical
position errors. If an inaccurate antenna position is used during
observations, the online corrections for geometric delay (the difference in
signal path for pairs of antennas) will be slightly wrong, causing a phase
slope as a function of frequency or delay error. The geometric delay is zero
for a point source at the zenith (see SI99, Ch. 2 (Thompson) for a fuller
explanation). As the Earth rotates, for an E–W baseline, the antennas will
point at 4∘ to the zenith after 1 minute. An antenna position error of
$\sigma_{\mathrm{antpos}}$ (in mm) will produce an error in the geometric
delay correction of $\sigma_{\mathrm{antpos}}\times\sin(4^{\circ})\times 1000$
$\mu$m min-1, or $\sim$70 $\mu$m min-1 for $\sigma_{\mathrm{antpos}}=1$ mm.
Using Eq. 6, for $\lambda$ in mm, the phase error of data from that antenna is
given by

$\sigma_{\phi\mathrm{rate,antpos}}=360\times\left(\sigma_{\mathrm{antpos}}\times\sin(4^{\circ})\times
1000\right)\times 10^{-6}/(\lambda\times 10^{-3})$ (8)

giving a phase error of $\sigma_{\phi\mathrm{rate,antpos}}\sim$25∘ min-1 at
$\lambda=$ 1mm. This is a ‘worst case’ as the rate of change of the delay
error is lower in other directions and the actual determination of antenna
positions is a much more complicated process (Hunter et al. 2016). Errors tend
to be larger for antennas with only longer baselines.

There is an associated phase error of $\phi_{\epsilon,\mathrm{antpos}}$ in the
transfer of corrections to the target:

$\phi_{\epsilon,\mathrm{antpos}}\approx 2\pi\Delta_{\mathrm{pcal-
tar}}\frac{\sigma_{\mathrm{antpos}}}{\lambda}$ (9)

$\sigma_{\mathrm{antpos}}$ and $\lambda$ are in the same units. For recent
observations using a phase calibrator – target angular separation of
$\Delta_{\mathrm{pcal-tar}}=3^{\circ}$ (for example), a typical antenna
position error $\sigma_{\mathrm{antpos}}=0.1$mm at $\lambda=1$ mm produces a
phase error $\phi_{\epsilon,\mathrm{antpos}}$ of only $\sim 2^{\circ}$. It is,
however, harder to establish the positions of distant antennas contributing
only long baselines. The same $\Delta_{\mathrm{pcal-tar}}$ and
$\sigma_{\mathrm{antpos}}=2$ mm, but at $\lambda=0.8$ mm, gives
$\phi_{\epsilon,\mathrm{antpos}}\sim 50^{\circ}$ which is enough to cause
$>30\%$ decorrelation and, more seriously, to shift the position of the target
in the image plane. This can cause severe distortions for sources with a
complex structure but for a source with one, central unresolved peak, phase
self-calibration will compensate for small position errors. Like
$\phi_{\epsilon,\mathrm{trop}}$, $\phi_{\epsilon,\mathrm{antpos}}\propto\nu$.

###  2.2 Amplitude errors

Water vapour and other tropospheric molecules such as ozone cause amplitude
errors directly as they both absorb and emit in ALMA bands (as well as
corrupting the phase by refracting the incoming radiation). You can use the
ALMA Atmospheric Model (see Appendix B.5 to check if your observations are
particularly badly affected, or overplot the transmission in plotms. The
effects of this on the visibility amplitudes vary on timescales of minutes
(rather than seconds, as for phase). ALMA’s $T_{\mathrm{sys}}$ measurements
allow correction for absorption and emission including gain-elevation effects
and also compensate for any differences between antennas or signal paths.
These corrections are made per scan or every few scans and the residual time-
dependent errors are usually only a few percent.

Other contributions to amplitude errors include pointing errors, Sec. 6.7.
Nonetheless, after applying $T_{\mathrm{sys}}$ corrections, the main
contribution to time-dependent amplitude errors is usually decorrelation due
to phase errors, as shown in Eq. 3. The lowest possible level of uncertainty
is the thermal noise, Sec. 2.1.3.

####  2.2.1 Flux density scale

We use ‘amplitude errors’ to refer to fluctuations during an observation, in
time or across frequencies (other than target variability/spectral index),
distinct from the overall flux scale. The overall flux scale usually remains
constant (per spw) during a single EB, or even a series of observations made
in the same mode with no instrumental changes.

Immediately after correlation, ALMA visibility amplitudes are in units of
(correlated signal/system noise), ALMA-TH Ch. 10. Other interferometers use
different scalings but in any case a scaling factor is needed to convert the
flux scale to Jy or other physical units. The flux scale can be derived from
$T_{\mathrm{sys}}$ (Appendix D.2) but is normally derived using an
astrophysical standard, used to calculate the flux density of other
calibrators including the phase calibrator. Amplitude solutions are derived
for the calibrators and then task fluxscale is used to produce a scaled
amplitude correction table for the phase calibrator. The derivation usually
assumes point sources, hence the target flux density is not determined at this
point. Instead, the scaled amplitude corrections derived from the phase
calibrator can be applied directly to the target and phase reference. (see
Fig. 4 bottom right, where the orange circles and (darker) squares show phase
calibrator visibilities before applying the flux scale; the darkest, brown
diamonds are on a scale 30$\times$ higher, after flux scaling). Alternatively,
setjy can be used to set the derived phase calibrator flux density and then a
fresh amplitude calibration table is derived and applied.

Normally the flux scale can be assumed to be accurate during self-calibration
(within uncertainties, ALMA-TH Ch. 10 for ALMA) but if a continuum source
contributes a significant fraction of $T_{\mathrm{sys}}$ (which is several
tens K at the lowest bands to a few hundred at the highest, see ALMA-TH), you
may need to correct for its contribution to $T_{\mathrm{sys}}$, see Appendix
D.3. You may also need to check that the corrections have been derived from
$T_{\mathrm{sys}}$ accurately in the case of bright spectral lines, see
Appendix B.5. If the target was not phase-referenced, see Sec. 5.5.

###  2.3 Closure relations and the minimum number of antennas for solutions

Although CASA and other modern packages do not use closure expressions
directly to self-calibrate, the principles underlie the methods and provide an
intuitive understanding of why there are 3 and 4 degrees of freedom for phase
and amplitude, respectively. Take antennas 1, 2, 3 where the observed phase on
the baseline between the first two antennas, including the antenna-based
errors, is $\phi 12+(\phi_{\epsilon 1}-\phi_{\epsilon 2})$, etc.. Jennison
(1958) realised that if you combine the phases for 3 baselines between 3
antennas as

$[\phi 12+(\phi_{\epsilon 1}-\phi_{\epsilon 2})]+[\phi 23+(\phi_{\epsilon
2}-\phi_{\epsilon 3})]+[\phi 31+(\phi_{\epsilon 3}-\phi_{\epsilon 1})]=\phi
12+\phi 23+\phi 31$ (10)

the phase errors sum to zero.

Similarly, as amplitude errors are multiplicative, the relationship for
baselines between 4 antennas is:

$\frac{[A12A_{\epsilon 1}A_{\epsilon 2}]\times[A34A_{\epsilon 3}A_{\epsilon
4}]}{[A23A_{\epsilon 2}A_{\epsilon 3}]\times[A41A_{\epsilon 4}A_{\epsilon
1}]}=\frac{A12\times A34}{A23\times A41}$ (11)

Thus there are 3 degrees of freedom for phase solutions and 4 for amplitude
and in order to obtain unambiguous calibration you need a minimum of 2
baselines per antenna for phase and 3 for amplitude, i.e. a minimum of 3 and 4
antennas with all good baselines, respectively. In reality, on the one hand a
higher number is desirable to ensure good solutions and on the other, for a
source with very simple structure, self-calibration can be performed with
fewer, even on a single baseline for a point source.

##  3 Effects of errors after phase referencing

Self-calibration starts after applying corrections derived from other sources
or instrumental measurements. For ALMA, this includes corrections derived from
$T_{\mathrm{sys}}$, WVR, antenna positions and bandpass calibration, and any
polarisation calibration, ALMA-TH. Bad data in the calibration sources should
have been flagged and relevant flags extended to the target. For convenience
we refer to data with these corrections as ‘raw’, prior to applying time-
dependent corrections derived from the phase calibrator and the flux scale,
which should also be done before target self-calibration. Section 6 describes
more general error recognition.

We start by assuming that these prior corrections are as good as possible.
After applying phase calibrator solutions, the remaining errors affecting the
target visibilities are mainly due to the troposphere (as described in Sec.
2), specifically, atmospheric differences in time and in direction between the
phase calibrator and the target scans. This means that the target signal
amplitude suffers slightly different sky absorption and emission and the phase
suffers slightly different refraction. Self-calibration provides corrections
for such residuals to a greater or lesser extent depending on the S/N and
possibly other factors like $uv$ coverage so this may not be perfect. Antenna
position and pointing errors also contribute, and may affect the starting
model, see Secs. 2.1.4 and 6.7.

###  3.1 Illustrating phase and amplitude errors and their correction

We use ALMA VY CMa Band 7 science verification
data222https://almascience.org/almadata/sciver/VYCMaBand7/ to illustrate
residual errors and how to correct them using self-calibration. The data are
summarised in Table 1, see Richards et al. (2014) for more details. Only one
(out of 3) execution blocks are used here, so the image sensitivity is worse
than that obtained from the whole data set (Richards et al. 2014) and
initially we consider a single spectral window. All corrections apart from
phase referencing have already been applied. The observations were made with
alternating phase calibrator and target scans, starting and finishing on the
phase calibrator, with a cycle time $\sim$7 min.

Target Phase-cal | $\Delta_{\mathrm{pcal}}$ | Cycle | $\Delta t$ | $N$ | $B_{\mathrm{min}},B_{\mathrm{max}}$ | $N_{\mathrm{pol}}$ | $\nu_{\mathrm{cen}}$ | spw | chan | $\Delta{\nu}$
---|---|---|---|---|---|---|---|---|---|---
| -tar | (min) |  | (km) |  | (GHz) | (MHz) | (GHz)
VY CMa J0648-3044 | $\approx 2^{\circ}$ | 1.5:5 | 30 | 20 | 0.014, 2.7 | 2 | 325 | 1875 | 0.488 | 1
Table 1: Data used for examples, taken from uid___A002_X6cdf83_X1488, VY CMa
Band 7 SV data 2013. $\Delta_{\mathrm{pcal-tar}}$ is the phase calibrator-
target angular separation, observed alternately in the cycle time (where
$\tau_{\mathrm{scan}}$ is the target scan length, 5 min) for a total time
$\Delta t$ on target. $N$ and $B_{\mathrm{min}},B_{\mathrm{max}}$ are the
number of antennas and the minimum, maximum baselines used. $N_{\mathrm{pol}}$
is the number of receiver polarisations (X and Y). $\nu_{\mathrm{cen}}$ is the
central frequency of the spw used here and spw and chan are the total spw and
individual channel widths. $\Delta{\nu}$ is the line-free continuum bandwidth.

Note that some figures show visibility data on a single baseline compared with
solutions derived per-antenna, as part of calibration fitting to data from all
antennas, hence there is not an exact correspondance between data and
solutions. Moreover, the plots have been assembled to highlight relevant
features – not for exact science.

In Fig. 4 the phase calibrator and target scans are shown in red and in green,
respectively. Plots of visibilities have a grey background and plots of
solutions have a white background. The phase calibrator is point-like with an
accurate position so its model has zero phase and a constant amplitude
($\sim$$0.44$ Jy). DA41 and DV24 are approximately 0.2 and 1.4 km,
respectively, from the reference antenna. Fig. 4 top left shows the raw phase
for a single baseline, single spw, single polarisation. Fig. 4 bottom left
shows phase solutions for the two antennas for the phase calibrator per-
integration (small dots) and per-scan (large dots). The per-integration
solutions are applied to the phase calibrator visibilities, leading to
corrected phases which are very close to zero (see Fig. 4 top right). Any
remaining offsets are due to the noise limit of the data and, possibly, small,
baseline-dependent errors.

Figure 4: Illustrations of the use of the phase calibrator to correct the
target visibilities. In discussions we ignore the final two very short scans.
Top left: Raw visibility phases per integration, for target (continuum) and
phase calibrator, in red (dark) and green (light), respectively. Bottom left:
Phase calibrator phase solutions for X polarisation, derived per-integration
(int) and per-scan (inf) (small and large circles), for two antennas, DA41 and
DV24 (dark and light blue). Top right: Phase calibrator phases corrected per
integration, target phases corrected per scan with interpolated phase
calibrator solutions. Bottom right: Phase calibrator visibility amplitudes
(both correlations) before and after applying phase and amplitude solutions.
Raw data, unaveraged and averaged per scan are shown by small and large orange
circles, respectively. Corrected data averaged by scan after applying per-
integration phase solutions are shown by darker orange squares. The darkest,
brown diamonds show data with the flux scale and amplitude solutions also
applied and are plotted at 1/30 of the actual flux densities, around 0.44 Jy.

We can estimate the effect of phase errors as a function of time from the raw
phase calibrator data (this is easier than from the target data themselves, as
the target may be weak and may have real phase variations due to structure,
and the basis of phase referencing is that similar errors affect both
calibrator and target). Fig. 4 top left, shows that within a phase calibrator
scan the typical raw phase change is $50^{\circ}$. Eq. 3 predicts that this
leads to a reduction of amplitude to $68$% of the true value. Fig. 4 bottom
right shows that the raw amplitudes (orange circles) are indeed only
$\sim$$70$% of the corrected values (orange squares). That is, the phase
errors cause $\sim$$30$% decorrelation. Applying the phase calibrator per-
integration phase solutions prior to averaging the visibility amplitudes per-
scan improves the coherence by the expected amount.

The raw, unaveraged phase calibrator visibility amplitudes (small circles)
have about 20% random scatter per polarisation and a similar systematic
variation between scans over the whole 45 min of observation (in contrast to
the rapid raw phase changes). Thus, once phase solutions have been applied,
the remaining scatter within a scan is noise-like and the solutions for
amplitude calibration can usually be a scan length or longer, since
calibration cannot remove noise. Applying the amplitude solutions flattens the
differences between visibility amplitudes per-scan (diamonds). The final phase
calibrator amplitude corrections (diamonds) have also been scaled so that,
when applied, they not only remove small fluctuations between scans but also
contain a constant factor to convert the target visibilities to the physical
flux scale (Sec. 2.2.1).

Fig. 4 bottom left shows phase calibrator solutions averaged per scan (large
dots) with lines indicating the interpolation across the target scans. This
can correct atmospheric effects on the timescale of a scan cycle ($\sim$7 min)
but not errors within a scan. Fig. 4 top right shows that the target phase
deviations within each scan are only slightly reduced to $50-100^{\circ}$. The
remaining overall phase slope and other deviations are probably due to the
target offset from the pointing centre and its structure.

###  3.2 Quantifying target residual phase errors after phase referencing

In order to understand how to correct residual errors, this section provides
rough estimates of their origins, timescales and magnitudes. Note that
quantifying phase errors per antenna is a convenient concept, but in practice
visibilities are formed per-baseline. Calibration algorithms compare the
Fourier transform of the model image with the visibilities. The discrepancies
are decomposed using a least squares (or other) minimisation process to find
the per-antenna corrections needed to bring the observed visibilities closer
to the model. Thus, when comparing the observed data per-baseline phases and
amplitudes (raw or corrected) with per-antenna solutions, as in Fig. 4,
remember that the correspondance is not exact, especially as the visibilities
for a resolved or off-centre source will also show patters due to the source
structure.

The expressions and typical values derived for errors and the required
corrections given here assume that all the antennas in an array have errors of
similar magnitude which may not be the case if some antennas contribute mostly
to short baselines and others mostly to long, or if antennas have
intrinsically different sensitivities (see Sec. 4.7.1). To start with, we
assume that the frequency dependence of errors is negligible within an
observation, and the phase errors described are mainly tropospheric. The
contributions here are listed in approximate order of increasing seriousness
for these observations – this order could be different e.g. in spectral
regions where atmospheric noise is high. Items 1., 2,. and 3.–5. relate to
Secs. 2.1.3, 2.1.4 and 2.1.1 (occasionally 2.1.2), respectively.

  1. 1.

Noise errors The errors specifically connected to phase referencing can in
principle be corrected, given high enough target S/N. Thermal noise cannot be
removed by self-calibration or anything else although sophisticated modelling
algorithms may be used in specific cases to assign a significant probability
to visibility or image features below the usual detection threshold (e.g.
Nakazato et al. 2020). Here, the phase calibrator is $\sim 440$ mJy and for a
single polarisation, single spw centred on the observing frequency of 325 GHz,
in a single 90 s scan, the sensitivity calculator predicts 4.5 mJy rms noise,
so the phase error due to thermal noise, given in radians by 1/(S/N), is
slightly less than $1^{\circ}$. In transferring solutions from this phase
calibrator it is negligible compared with calibration errors. More usually,
the noise in a final image may be significant in position accuracy for faint
components, see Sec. 3.5

  2. 2.

Antenna position errors: For a phase reference source with a good position, a
smooth slope of phase over many scans suggests an antenna position error (this
would show a sinusoidal pattern over 24 hr). Fig. 4 top left shows a total
phase change of $\sim-$150∘ in 48 min, or an average of magnitude $\sim$3∘
min-1 (with greater excursions between scans). Using Eq. 8, $\sim$3∘ min-1 at
$\lambda 0.9$ mm corresponds to an antenna position error
$\sigma_{\mathrm{antpos}}\sim$ 0.2 mm. This is a very crude estimate but is
typical for ALMA observations at that time (Hunter et al. 2016). The delay
error associated with an antenna position error, and thus the correction, is
direction-dependent, and so from Eq. 9 this would lead to an error in
transferring solutions to the target of $\phi_{\epsilon,\mathrm{antpos}}\sim
2.8^{\circ}$.

  3. 3.

Short-timescale errors:  Fig. 4 top left shows small but systematic phase
deviations within a phase calibrator scan, in this instance $\delta\phi\sim
20^{\circ}$ in 0.75 min. In the worst case, superimposed on a steep residual
transfer error, their effect per 5-min target scan will be
$\phi_{\epsilon,\mathrm{short}}\sim\delta\phi\times\sqrt{(}5/0.75)\sim
50^{\circ}$.

  4. 4.

Phase errors due to phase calibrator – target time difference: The offsets, in
both time and angular separation, between phase calibrator and target,
contribute to the residual phase errors in the target visibilities. An
averaged correction from the bracketing phase calibrator scans is applied to
every target scan and the scan cycle is 7 min. We can use the phase reference
visibility phase to estimate the phase rate. The average slope (assumed to be
due to antenna position errors) in Fig. 4 top left is $\sim-20^{\circ}$ per
7-min cycle, plus additional scan-to-scan raw phase-changes of magnitude
$\sim$28∘, giving $d\phi_{\mathrm{atm/min}}\sim 4^{\circ}$ min-1. The
corrections will thus have an inaccuracy due to the offset in time leaving a
residual error per target scan of
$\phi_{\epsilon,\mathrm{time}}=d\phi_{\mathrm{atm/min}}\times(7/2)\approx
14^{\circ}$. The factor of 2 is is allowing for the maximum discrepancy when
interpolating linearly the per-scan averages of the phase reference solutions
across the target scans.

  5. 5.

Phase errors due to phase calibrator – target angular separation:  Following
this, the change in phase per unit time seen as the telescope tracks sidereal
targets can be regarded as equivalent to the phase change between different
source directions on the sky, by converting angular separation to minutes of
time, equivalent to Right Ascension. 1∘ angular separation is 4 min of R.A.
$\times$ cos(Declination). In these data VY CMa and its phase calibrator have
an angular separation of $\Delta_{\mathrm{pcal-tar}}\approx 2^{\circ}$. At the
target Declination of $-26^{\circ}$ the angular separation is equivalent to
$(\Delta_{\mathrm{pcal-tar}}\times 4\times\cos(-26))\sim 7$ minutes. This
leads to a likely discrepancy of
$\phi_{\epsilon,\mathrm{angsep}}=d\phi_{\mathrm{atm/min}}\times 7\approx
28^{\circ}$ between the phase corrections calculated in the phase calibrator
direction and the corrections needed for the target.

  6. 6.

Accumulated errors after phase referencing The combined error affecting target
data due to the separation between phase calibrator and target is

$\phi_{\epsilon,\mathrm{transfer}}=\sqrt{\phi_{\epsilon,\mathrm{time}}^{2}+\phi_{\epsilon,\mathrm{angsep}}^{2}+\phi_{\epsilon,\mathrm{antpos}}^{2}}$
(12)

Using the values derived above for $\phi_{\epsilon,\mathrm{antpos}}\sim
2.8^{\circ}$, $\phi_{\epsilon,\mathrm{time}}\sim 14^{\circ}$ and
$\phi_{\epsilon,\mathrm{angsep}}\sim 28^{\circ}$ gives
$\phi_{\epsilon,\mathrm{transfer}}\sim 31^{\circ}$.

Adding in the systematic short-time-scale error
$\phi_{\epsilon,\mathrm{short}}\sim 50^{\circ}$ leaves a total target phase
error per antenna of

$\phi_{\epsilon,\mathrm{target,ant}}=\sqrt{\phi_{\epsilon,\mathrm{time}}^{2}+\phi_{\epsilon,\mathrm{angsep}}^{2}+\phi_{\epsilon,\mathrm{antpos}}^{2}+\phi_{\epsilon,\mathrm{short}}^{2}}$
(13)

so here, $\phi_{\epsilon,\mathrm{target,ant}}\sim 60^{\circ}$.

Fig. 3 shows phase errors as a function of baseline length, 1.6 km in this VY
CMa example. Crudely approximating the target phase errors for antennas
contributing to this range by taking half
$\phi_{\epsilon,\mathrm{target,ant}}$ as $\phi_{\mathrm{rms}}\sim 30^{\circ}$,
then using Eq. 6, at $\lambda=0.9$ mm this is equivalent to
$\phi_{\mathrm{rms},\mu}\sim 75$ $\mu$m. Fig. 3 shows that this falls between
the grey and yellow lines for the expected target phase rms for 1.6 km
baselines after applying PWV and phase calibrator corrections on 2 min and 20
sec timescales, respectively. The VY CMa observations were comparable to the
test, but with a smaller target–phase calibrator angular separation and a
longer cycle time than that for the predicted gray line. The PWV was
significantly lower, 0.3 mm, contributing to the better performance seen in
the VY CMa data.

  7. 7.

Phase errors on many baselines:  These estimates and expressions are
imprecise, not least because generalising from one scan, one baseline is only
roughly representative, and because the effects of short time-scale jitter on
images are more visible on sources with complex structure. However, assuming
that the estimates are typical, for an observation with $N$ antennas the
overall effect is reduced insofar as each baseline samples a different
combination of atmospheric conditions as illustrated in Fig. 2. Different
baselines, even of a similar length, will sample different conditions and
position angles, so even if the magnitude of the effect is similar the sign
and value will change, see SI99 Ch. 5 (Fomalont & Perley) for a general
discussion. The phase errors for an array of many antennas can be given by:

$\phi_{\epsilon,\mathrm{target}}=\frac{\phi_{\epsilon,\mathrm{target,ant}}}{\sqrt{(N_{\mathrm{indep}})}\sqrt{M}}$
(14)

$M$ is the number of periods of distinct atmospheric conditions sampled and
the change in phase slope from scan to scan in Fig. 4 top left suggests that
we can take this as the number of full scan cycles, 6. This implies a wind
speed of $\gtrsim$2.7 km (the maximum baseline) in 7 min, or $\gtrsim$6 m s-1,
which is a typical wind speed at ALMA (Sec. 2.1.1). If the atmosphere above
each antenna is independent, such as for VLBI arrays, the number of
independent antennas $N_{\mathrm{indep}}=(N-3)$ (see explanation of Eq. 23 in
Sec. 4.4.2). For the VY CMa example here there will be less difference between
the atmosphere above individual antennas during each scan and Fig. 3 suggests
that the atmospheric effects above every antenna are not independent. The
errors on the longest baselines and the short-term scatters within each scan
may, however, be somewhat independent, and we adopt $N_{\mathrm{indep}}=2$.
This leads to $\phi_{\epsilon,\mathrm{target}}\sim 20^{\circ}\sim 0.35$ rad,
leading to a prediction of $\sim 6\%$ decorrelation (Eq. 3) for the image made
after applying phase calibrator solutions only. This has a 179 mJy beam-1
peak. Comparing this with the final VY CMa peak of 199 mJy with the actual
initial decorrelation is $\sim$10%. This is slightly worse than predicted due
to over-simplification in the expressions used and variations in observing
conditions, and also because the dynamic range of the first target image is
limited by the phase calibrator dynamic range, Sec. 3.3.

The contributions to phase errors are summarised in Table 2, numbered as in
the above points.

Phase noise | $\phi_{\epsilon,\mathrm{antpos}}$ | $\phi_{\epsilon,\mathrm{short}}$ | $\phi_{\epsilon,\mathrm{time}}$ | $\phi_{\epsilon,\mathrm{angsep}}$ | $\phi_{\epsilon,\mathrm{transfer}}$ | $\phi_{\epsilon,\mathrm{target,ant}}$ | $\phi_{\epsilon,\mathrm{target,array}}$
---|---|---|---|---|---|---|---
1. | 2. | 3. | 4. | 5. | 6. | 6. | 7.
$<$1 | 2.8∘ | 50∘ | 14∘ | 28∘ | 31∘ | 60∘ | 20∘
Table 2: The various contributions to target phase errors arising from the
transfer of solutions from the phase calibrator, in the example of one
execution of an observation in one spw, dual polarisation, at 325 GHz, as
described in Sec. 3.1. The terms are described in Sec. 3.2. 1. is the error
due to thermal noise within each scan on the 440 mJy phase calibrator. 2. is
due to antenna position errors and 3. is due to the short-timescale phase
errors within a phase calibrator scan. 4.–5. arise from the angular and time
separations between target and phase calibrator. 6. relates to the sums in
quadrature of the per-antenna errors due to the separation from the phase
calibrator and additional short-term errors and 7. is the error when
considering all 20 antennas used in the array.

Image-plane errors and their causes, whether or not they can be corrected by
self-calibration, are summarised in Sec. 6.

###  3.3 Dynamic range

We take a point source, flux density $P$, at the phase centre and give errors
in radians in this section to simplify expressions (more fully explained in
SI99, Ch. 13 Perley). For a single scan, an error of
$\phi_{\epsilon,\mathrm{baseline}}$ on a single E-W baseline, length $u_{0}$,
gives rise to a periodic, antisymmetric image artefact of amplitude
$P2\phi_{\epsilon,\mathrm{baseline}}$ and period $1/u_{0}$. Analogous
reasoning for an amplitude error of fractional magnitude
$A_{\epsilon,\mathrm{baseline}}$ shows that this leads to a symmetric image
artefact, see Section 1.3. If the observation comprises $M$ scans, then the
effect of the errors is reduced by $\sqrt{M}$.

If such an error dominates over thermal noise and other contributions to the
image rms, the dynamic range $D$ for the image made from all $N$ antennas is
limited to

$\displaystyle D_{\mathrm{baseline}\phi}$ $\displaystyle=$
$\displaystyle\frac{\sqrt{M}N(N-1)}{\sqrt{2}\,\phi_{\epsilon,\mathrm{baseline}}}\approx\frac{\sqrt{M}N^{2}}{\sqrt{2}\,\phi_{\epsilon,\mathrm{baseline}}}$
(15) $\displaystyle D_{\mathrm{baseline}A}$ $\displaystyle=$
$\displaystyle\frac{\sqrt{M}N(N-1)}{\sqrt{2}\,A_{\epsilon,\mathrm{baseline}}}\approx\frac{\sqrt{M}N^{2}}{\sqrt{2}\,A_{\epsilon,\mathrm{baseline}}}$

for large N, for phase ($D_{\mathrm{baseline}\phi}$) and amplitude
($D_{\mathrm{baseline}A}$) errors, respectively. Thus, a $10^{\circ}$ (0.175
rad) phase error produces the same dynamic range limitation as a 20% amplitude
error. In most ALMA data after phase referencing the amplitude errors are
lower than this whilst the phase errors can be much higher as summarised in
Table 2. For 20 antennas, a $10^{\circ}$ phase error on a single baseline
restricts $D_{\mathrm{baseline}}\sim 1600\sqrt{M}$.

More commonly all baselines to one antenna are affected by a similar error.
Considering the phase-error case, this reduces the dynamic range by a factor
of $\sqrt{N}$; if all antennas (and thus all baselines) are affected there is
a reduction by another factor of $\sqrt{N}$:

$\displaystyle D_{\mathrm{antenna}\phi}$ $\displaystyle\approx$
$\displaystyle\frac{\sqrt{M}\sqrt{N}N}{\sqrt{2}\phi_{\mathrm{antenna}}}$ (16)
$\displaystyle D_{\operatorname{all-antenna}\phi}$ $\displaystyle\approx$
$\displaystyle\frac{\sqrt{M}N}{\sqrt{2}\phi_{\operatorname{all-antenna}}}$

For a $10^{\circ}$ error affecting one of 20 antennas this corresponds to
$D_{\mathrm{antenna}}\sim 360\sqrt{M}$ or, for all antennas,
$D_{\operatorname{all-antenna}}\sim 80\sqrt{M}$.

If all the baselines have a different, random error, the dynamic range is

$D_{\operatorname{all-
baseline}\phi}\approx\frac{\sqrt{M}N}{\phi_{\operatorname{all-baseline}}}$
(17)

For a $10^{\circ}$ error affecting all 190 baselines from 20 antennas,
$D_{\operatorname{all-baseline}\phi}\sim 115\sqrt{M}$. Sparse $uv$ coverage
can further limit the dynamic range, affecting VLBI images, very high spectral
resolution long-baseline ALMA data etc. due to deconvolution errors. However
close the phase calibrator is, the target dynamic range will be no better than
that for the phase calibrator, so if a higher S/N is anticipated for the
target, self-calibration will be needed.

Conversely, even for a very bright target, with 43 antennas of ALMA, a phase
error of 2.5∘ gives a dynamic range $\sim 1000$. Whilst over a whole
observation, with a typical continuum $\sigma_{\mathrm{rms}}$ 0.01 mJy, this
only implies a peak of 10 mJy, achieving such a small phase error requires
adequate S/N per solution interval per antenna, as explained in Sec. 5.13. In
practice, it is hard to exceed a dynamic range of a few 1000 for ALMA,
requiring an excellent target model, bandpass calibration and antenna position
accuracy. If there is extended emission not fully sampled, or other issues,
the dynamic range may be only a few 100 even taking account of situations as
in Sec. 5. In any case, you cannot reduce the intrinsic thermal noise
(although this may be lower than predicted, under better observing
conditions). For more discussion of dynamic range, see SI99 Ch. 13 (Perley)
section 3.

###  3.4 Flux scale errors

Section 1.3 introduced decorrelation of amplitudes due to phase errors.
Residual errors of a few–10% typically remain after applying
$T_{\mathrm{sys}}$ corrections (Sec. 2.2), ALMA-TH). Here, amplitude errors
refers to time-varying relative errors and inconsistencies between antennas,
not in the overall flux scale (Sec. 2.2.1). Amplitude self-calibration cannot
correct the overall flux scale (unless you have an a-priori model for the
target) but it can reduce artefacts by making the amplitudes self-consistent
(Sec. 5.11).

Special problems arise from sources which contribute a sizeable fraction of
$T_{\mathrm{sys}}$ (which is tens – hundreds Jy in lower – higher frequency
bands, see ALMA-TH and links in Appendix D.3 and also Appendix B.5 for issues
with very bright spectral lines.

If a check source was observed, then comparing its imaged flux density with
that deduced from the visibilities using fluxscale gives an estimate of
decorrelation after applying phase calibrator solutions (allowing for the
difference in angular separation from the phase calibrator).

###  3.5 Image resolution and position accuracy

The accuracy of phase calibration determines the distribution of flux in an
image and thus not only the general morphology but also the accuracy of
measurements of the image. This section discusses uncertainties arising from
residual errors after calibration, but not those inherent in sparse visibility
plane coverage or the accuracy of models. Model goodness of fit, whether in
the sky plane or the visibility plane (e.g. Martí-Vidal et al. 2014, Rivi et
al. 2019), may be dominated by a genuine discrepancy between the sky
distribution and the model such that the $\chi^{2}$ value might be worse for
well-calibrated data where deviations are more apparent.

####  3.5.1 Noise and resolution

As observations generally involve random errors on multiple antennas over a
long enough time for the atmosphere to vary, the image is smeared by jitters
in multiple directions (analogous to optical ‘seeing’ errors).

In a typical ALMA observation, following SI99 Ch. 28 (Carilli, Carlstrom &
Holdaway) eq 28.8, the phase error as given by Eq. 5 can be used to give the
baseline length $B_{1/2}$ where the visibility curve is reduced to half power,
and thus the corresponding phase error:

$\displaystyle B_{1/2}$ $\displaystyle=$
$\displaystyle(69\lambda/K)^{1/\alpha_{\mathrm{K}}}$ (18)
$\displaystyle\phi_{\epsilon 1/2}$ $\displaystyle=$ $\displaystyle
KB_{1/2}^{\alpha_{\mathrm{K}}}/\lambda$

This is the seeing limit, for a given set of conditions, such that on longer
baselines the effective resolution will be worse than that predicted. The
synthesised beam width is taken as
$\theta_{\mathrm{B}}\sim\lambda/B_{\mathrm{max}}$ where $B_{\mathrm{max}}$ is
the maximum baseline. For example, at $\lambda$=1.3 mm with an effective
$K=50^{\circ}$ (thus also taking $\phi_{\epsilon 1/2}$ in degrees), for
$\alpha_{\mathrm{K}}=1/3$, then $B_{1/2}\sim 2$ km. As explained in Sec.
2.1.1, you may need to iterate with different values of $\alpha_{\mathrm{K}}$
if $B_{1/2}$ appears to be $<$1 or $>$10 km. Thus, residual phase errors
$\phi_{\epsilon}>65^{\circ}$ will noticeably degrade the resolution (as well
as redistributing the flux, as noted using Eq. 3).

####  3.5.2 Relative position accuracy

Stochastic (noise-based) position errors are derived from the noise in the
image used for measurement and cover the relative uncertainty between sources
in an image due to phase noise (Sec. 2.1.3). Condon (1997) and Richards et al.
(1999) describe the effects of phase errors on the accuracy of determining
source parameters by fitting 2-D Gaussian components to an interferometric
image (assuming that the emission is smaller than a few synthesised beams and
intrinsically well-described by a 2-D Gaussian). The errors returned by tasks
such as imfit should be considered as guidance since the uncertainty is
affected not only by random noise but by deconvolution errors, non-Gaussian
source structure, nearby sources and, in such situations, by the size of the
mask used for the fit. The relative position error is given by

$\sigma_{\mathrm{posfit}}=C\times\frac{\theta_{\mathrm{B}}}{(\mathrm{S/N})}$
(19)

where $C=0.5$ is the theoretical value for a well-filled array and high phase
stability, but can be 1 or even more for sparse visibility plane coverage such
as VLBI. ALMA-TH gives $C=1/0.9$ for ALMA, to allow for decorrelation, with a
limit of 0.05$\theta_{\mathrm{B}}$, appropriate for a target after phase-
referencing. However, if self-calibration allows S/N of a hundred or better,
the relative position of bright, compact peaks can be found to an accuracy of
a few percent of the restoring beam size, although residual calibration and
deconvolution errors set an eventual limit. The uncertainty in the width of
the component is $\sqrt{2}\sigma_{\mathrm{posfit}}$.

The same reasoning can also be used to estimate the uncertainty in a width
measured between $3\sigma_{\mathrm{rms}}$ contour boundaries, as
$\sqrt{2}\times C,\theta_{\mathrm{B}}/3$.

Uniform weighting e.g. a low value of robust in tclean, does not necessarily
improve position accuracy despite a smaller synthesised beam. It may increase
the beam sidelobes and rms noise near bright peaks. This means that although
$\theta_{\mathrm{B}}$ is smaller, the S/N is also reduced and the chance of
clean artefacts is greater.

####  3.5.3 Astrometric accuracy

The apparent position of a target is determined by the accuracy with which the
phase corrections are transferred from the phase calibrator (i.e. the effects
of the time and angular separation offsets and any antenna position errors),
as well as the accuracy of the phase calibrator position (which is usually
better than 1 mas for calibrators with VLBI positions). _The astrometric
position should be measured from an image made after applying phase calibrator
solutions only_ , so the phase error is based on Eq. 12. Self-calibration
using such an image model will retain the position but cannot improve it.

For short observations (such that the atmosphere does not change noticeably)
with a very compact array, the signal entering all antennas experiences the
same atmospheric refraction (antennas 1,2 in Fig. 2), a bulk shift of apparent
position is possible, see SI99, Ch. 15 (Ekers), eqs. 15-4 and 15-5. Such a
situation is unlikely for ALMA except possibly for the ACA, but is more likely
for compact, low-frequency telescopes and provides an introduction to the
origin of position errors:

$\sigma_{\mathrm{pos,compact}}=\theta_{\mathrm{B}}\times\phi_{\epsilon,\mathrm{transfer}}\times\pi/180$
(20)

(including $\phi_{\epsilon,\mathrm{transfer}}$ conversion to radians). Thus, a
$60^{\circ}$ phase error could cause a displacement of about
$\theta_{\mathrm{B}}$. If the observation is longer, the noise-error will be
randomised and, as with longer baselines, the atmospheric turbulence
dominates, causing the smearing in all directions previously described.

In the more usual case of a longer observation with a more extended array, the
mean phase error is half of the difference between successive phase calibrator
scan solutions $\phi_{\epsilon,\mathrm{transfer}}$ (assuming the actual phase
slope is linear), reduced by the number of independent measurements. Using Eq.
20, the target absolute position error is

$\sigma_{\mathrm{posTarget}}=\theta_{\mathrm{B}}\times\frac{\phi_{\epsilon,\mathrm{transfer}}\times\pi/180.}{2\sqrt{(N_{\mathrm{indep}})}\sqrt{M}}$
(21)

Noise-related errors are reduced for many antennas if the atmosphere is
independent above each antenna or group of antennas. $N_{\mathrm{indep}}$ can
be $N-3$ for VLBI arrays and as explained in Sec. 3.2 for Eq. 14; for these VY
CMa observations we take $N_{\mathrm{indep}}=2$ and the number of independent
time intervals $M=6$.

If the phase calibrator position uncertainty is significant, it must be added
in quadrature to $\sigma_{\mathrm{posTarget}}$. For weak targets and short
enough observations, the noise errors can be significant, so
$\sigma_{\mathrm{posfit}}$ should be added in quadrature to
$\sigma_{\mathrm{posTarget}}$ (as in Eq 13). In the VY CMa example this is not
needed. Using $\phi_{\epsilon,\mathrm{transfer}}=31^{\circ}$ and
$\theta_{\mathrm{B}}$=200 mas gives $\sigma_{\mathrm{posTarget}}\sim 31$ mas.

If the phase calibrator has low S/N such that its observed position error (see
Eq. 19) is significant in comparison with other errors this should also be
included. If the target has S/N much better than the phase reference source,
you can improve astrometric accuracy by swapping the roles (“reverse phase-
referencing”). First, complete normal self-calibration to get a good image
model (see Sec. 5.5 if the phase calibrator is too weak to use at all). Then,
take the target and phase calibrator data before applying the phase calibrator
solutions to either, and use the target model to derive phase and amplitude
solutions for the target as if it was a phase calibrator, and apply final per-
scan corrections to the phase calibrator as if it was a target. Comparison of
the resulting apparent and catalogued positions of the phase calibrator
provides the offset to be applied to the apparent target position to derive
its astrometric position.

Dual-polarisation receiver systems on alt-az telescopes rotate during
observations and thus the separate polarisations undergo phase rotation of the
parallactic angle (as well as the amplitude effects, Sec. 5.9). The
parallactic angle rotation is given by eq. 3 of Cotton (2012) and the
difference for two antennas on a baseline is, very roughly, similar to their
longitude separation $\delta L$ (and thus the hour angle difference for a
target). This can lead to position errors for arrays observing in circular
polarisation when comparing separate LL and RR positions for circularly
polarised sources, such as masers. For example, e-MERLIN has maximum baselines
spanning $\delta L\sim 4^{\circ}$ and synthesized beam $\theta_{\mathrm{B}}$
12–200 mas at $\lambda$ 1.3–21 cm. The offset per polarisation is of order
$\theta_{\mathrm{B}}$$\times$$\delta L/\pi$ e.g. $\\!4/180\theta_{\mathrm{B}}$
(of opposite sign for each hand). This is significant if it is comparable to
the noise-based position error, i.e. if the S/N $\gtrapprox\delta L/\pi$. The
effect will give a spurious position offset, which can be cured by repeating
the appropriate applycal applying the parallactic angle correction prior to
imaging. This is less of an issue for ALMA as not only are its baselines
shorter but it observes in linear polarisation and separate XX and YY maps are
very rarely made. In total intensity the effect averages out and for
polarisation observations the parallactic angle correction is customarily
applied.

Comparing apparent and catalogue positions for the check source (if any) gives
a separate estimate of astrometric accuracy, allowing for differences in S/N
and angular separation from the phase calibrator. ALMA-TH 10.5.2 outlines the
ALMA strategy if high accuracy is needed.

##  4 Practical self-calibration

This section provides an overview, starting with a walk-through of the main
steps for typical straightforward self-calibration in Sec. 4.1. The subsequent
sections provide guidance for the main decisions: whether self-calibration is
possible in Sec. 4.2; making the model image in Sec. 4.3; parameter settings
in the first rounds of phase and amplitude self-calibration in Secs. 4.4 and
4.5. Sec. 4.6 illustrates how to tell whether the solutions are good and Sec.
4.7 covers applying the solutions. How to modify the workflow is introduced in
Sec. 4.8 and Sec. 4.9 provides criteria for when the self-calibration is as
good as possible. Examples are taken from the VY CMa Science Verification data
introduced in Sec. 3 using continuum channels. For additional issues when
using a spectral line for self-calibration or other special circumstances, see
the next Section 5 and for more practical examples, see the links in
Appendices B.1 and B.2 or the descriptions in Brogan et al. (2018) sec. 2.4
covering ALMA continuum, spectral line and mosaic.

Sec. 4.1 builds up corrections incrementally, so the previous solution tables
are applied when deriving the next round of calibration. This makes it easy to
check the tables have improved (e.g. the second round of phase solutions
should show small deviations compared with the first), and if there are
initially large errors, applying longer-timescale corrections for this can
improve the stability of incremental shorter-scale solutions. On the other
hand, if the first model is not accurate and/or too short a solution interval
is used, bad solutions can lead to artefacts ‘baked in’ to the image and
subsequent models, and if many rounds of calibration are used, accumulating a
long list of tables is prone to human error.

An alternative strategy, of improving the model in each round but generating
each phase calibration table without applying any previous self-calibration
solutions is used in the NRAO template imaging script, see Appendix B.5. This
avoids carrying forward calibration errors due to bad data or an inadequate
model, but if large corrections are needed there may be more failed solutions
and it is harder to spot bad solutions. However, for full polarisation, this
strategy can make it easier to ensure that the final solutions applied use a
consistent reference antenna. This strategy is outlined in Sec. 4.8 and a
hybrid approach can be used (with careful book-keeping). In either strategy,
the best previous phase corrections are applied when deriving amplitude
solutions.

###  4.1 Quick-start overview

This section summarises how to self-calibrate using a typical continuum target
in phase-referenced ALMA data in a single configuration and band, with all
standard calibration applied. If your target is so extended that there is
missing flux on short baselines see Sec. 5.11.2; a variety of other situations
are also covered in later sections.

We assume that all reduction was performed using CASA 4.2.2 or later; for very
early cycle data, check the weights (see Appendix B.2 CASA Guides).

At risk of stating the obvious, check the observing proposal if available, the
QA2 report, pipeline weblog or any other information about the observational
set up and notes on data processing so far. Also check any other information
about your target to guide you in what field of view is needed, what
sensitivity and resolution is intended, where to expect emission to appear
etc. – although you should also be prepared for the unexpected.

Sec. 4.2 explains when self-calibration is possible; in brief, for ALMA 12-m
array with $\sim 40$ antennas and $\sim 30$ min on-target, this is likely to
require image S/N of order 100; for less sensitive (e.g. ACA) observations S/N
50 or less might suffice.

Figure 5 shows a typical workflow for self-calibration accumulating gain
tables (see Sec. 4.8 for alternative approaches). The starting point is a
Measurement Set (MS) with phase calibrator corrections applied. In all cases
it is assumed that you are making an image from a continuum-only channel
selection but all spw are represented (for other situations see Sec. 5.1). As
implemented in CASA gaincal, the visibilities are compared with the model per
baseline and the corrections needed are estimated and optimised per-antenna
using a least squares (or similar) minimisation. Secs. 4.4 and Appendices C.1
and C.2 summarise guidance in setting the main parameters for the CASA tasks
to derive and apply calibration.

Each stage below covers making a correction table, following Fig. 5 in
performing two rounds of phase-only self calibration followed by amplitude
self-calibration.

Self-cal 1.

Start with the MS with phase reference corrections applied.

  1. 1.

Split out the target data, so this now forms the data column of a new MS.

  2. 2.

Make a target continuum image (see Sec. 4.3, check that the model will be
saved). Mask carefully close to the most believable emission. Using a simple,
but possibly incomplete model is better than starting with a more complicated
model that may contain doubtful features.

  3. 3.

The model is used by gaincal (Appendix C.1), which compares it with the MS
data column. Specify the same spw/channel selection as used for the image.
Solve for phase only and, for simplicity, assume you can solve for each spw
separately and use gaintype=’G’, solving for polarisations separately. For
most data, the target scan length is a good starting solution interval. Here,
the resulting gain table is called p0. Check that the solutions are OK (see
Sec. 4.6 and examples in Fig. 10; (a) shows good solutions after phase
referencing).

  4. 4.

applycal p0 to the MS (all spw, no channel selection), forming the corrected
column (Appendix C.2).

  5. 5.

Image again, making sure to use the corrected column (the default in tclean,
if it is present). Check that the image $\sigma_{\mathrm{rms}}$ has gone down
and the peak is stable or has increased (not decreased significantly), and the
structure does not have any artefacts e.g. sidelobe-like.

Self-cal 2.

Simply having a image model more accurately representing the target field can
allow you to refine phase calibration. A shorter solint may be possible (see
Sec. 4.4.2),

  1. 1.

Check that the model is in the MS (Sec. 4.3.2).

  2. 2.

Repeat step 1.(d) but in gaincal, apply table p0 as a gain table, generate a
second table p1 (possibly with a shorter solint). p1 should show smaller,
additional corrections. See Sec. 4.6 for guidance, a quick check is that
solutions should show a consistent trend for both polarisations; if the
discrepancies are noise-like and comparable to the range of time-dependent
correction the solint is probably too short (or the previous calibration has
not been applied).

  3. 3.

Repeat step 1.(e) but in applycal apply both p0 and p1, which will _overwrite_
the previous corrected column.

  4. 4.

Image again; use deconvolver=’mtmfs’, nterms=2 if there is enough S/N to
measure the spectral index (Sec. 4.5.1), and check again.

Self-cal 3.

(and further) If you have not reached the expected noise or dynamic range
limit, investigate whether the model can be improved or the solution interval
shortened for more rounds of phase self-calibration. If enough S/N do
amplitude self-calibration:

  1. 1.

Check that the model is in the MS (Sec. 4.3.2).

  2. 2.

Run gaincal, amplitude only, applying p0 and p1, with a longer solution
interval, typically at least a scan or even longer. For ALMA, normally, use
gaintype=’T’ to average polarisations. This makes table a1, see Fig. 11 for
examples of good and bad solutions.

  3. 3.

In applycal apply p0, p1 and a1 (and any additional tables if needed).

  4. 4.

Image again, check as before. If the model has changed greatly (e.g. more
extended, bright flux is included) consider repeating phase calibration
cycles.

  5. 5.

For S/N many hundreds or more, you might want to do more cycles of self-
calibration as the model improves (or even use a better model to start again
from the phase-only stages). You can decrease the solution interval but be
very careful if the structure is complex. See Sec. 4.9 for stopping criteria;
once there is no more improvement, make a perfect final image with PB
correction!

Figure 5: Flow chart of self-calibration using incremental solution tables.
Start at top left. The black arrows connect products such as the target MS and
the initial image via the tasks which are used and the mainly horizontal
arrows shown the accumulation of calibration tables.

Figure 6: VY CMa data as used in Sec. 3. Visibility data for a single channel
after applying phase calibrator solutions, before and after (‘corrected’)
self-calibration, compared with model. Top left: Target visibility phases v.
$uv$ distance, all baselines. Top right: Target visibility amplitudes v. $uv$
distance, all baselines. Bottom left: Target visibility phases v. time, single
baseline. Bottom right: Target visibility amplitudes v. time, single baseline.

If you change your mind and want to repeat a step, make sure to close any
plotting windows. To repeat an imaging step, make sure that the correct
table(s) have been applied first; to repeat a calibration step make sure that
the correct model has been Fourier transformed into the MS and the correct
tables, if any, are applied in gaincal and applycal. To go back to the start,
use clearcal and delmod. If you want to undo the effects of a gaintable used
to flag data by failed solutions, also use flagmanager to restore the flagged
data (assuming that you backed up the flagging state first), see Sec. 4.6.3.
See Sec. 4.8 for more guidance in modifying the workflow.

Fig. 6 top left shows the target phase before/after self-calibration. The
divergence with $uv$ distance indicates a source offset from the phase centre.
Phase self-calibration has significantly reduced the scatter and the
calibrated phase is mostly very close to the model. This can also be seen in
phase as a function of time, bottom left. Fig. 6 top right shows a similar
reduction in scatter from amplitude self-calibration. The model does not
represent the data fully, probably due partly to weak flux not being included
in the model (corrected data exceeds the model, more so on some shorter
baselines) and partly due to some remaining phase decorrelation (model exceeds
corrected data, mostly on some longer baselines). Fig. 6 bottom right shows
the increase in amplitude for a shorter baseline, due to correcting
decorrelation. Fig. 8 right and Table 3 show that the most substantial
improvement (a factor of 3 in S/N) comes from the initial phase self-
calibration. The final amplitude self-calibration should not change the flux
density by more than a few percent, as this is mainly determined by the input
model, but it does reduce the noise.

The basic principles of simple self-calibration are, _whatever tables you
apply in gaincal, apply these tables plus the new one in applycal_ (there are
rare exceptions, e.g. Sec. 5.1.2) and, _always check that the solutions are
not pure noise (Sec. 4.6) and the image S/N improves_. The following sections
explain how to make the choices for this.

###  4.2 How to tell if a data set is worth self-calibrating

ALMA science observations are calibrated and imaged using a pipeline or
standard scripts and the quality is checked carefully at all stages (known as
Quality Assurance stages QA0 to QA2, or QA3 if later improvements are made,
see ALMA-TH. In a typical ALMA data delivery or retrieval of archive data,
there are ready-made sample images, with phase calibrator and other
corrections applied. Products which passed QA2 are usually well-calibrated but
if you suspect problems, see the pipeline or QA2 logs and refer to Sec. 6. You
can contact your ARC333https://almascience.eso.org/help if you have queries.

Thus, the standard images can usually be used to start assessing whether they
could be improved by self-calibration.

####  4.2.1 Measuring the signal to noise ratio

In order to decide whether it is worth self-calibrating, measure the S/N for a
target image, usually for line-free continuum. The web log may give you values
for the peak and the off-source rms measured before PB correction. Otherwise,
the pipeline or QA2 produces an aggregate continuum image, which should have
been made excluding any lines. If you need to make an image yourself, do not
apply PB correction.

To measure S/N (peak/noise rms) using the viewer draw round the peak and use
the Maximum in Jy/beam – it is the peak which counts, not the total flux. The
noise $\sigma_{\mathrm{rms}}$ should be measured in as large a region as
possible avoiding the target emission and any noisy regions at the edge of a
primary-beam corrected image, as shown in Fig. 7, left. You can also use
imstat in a script; see Appendix D.4 for a script fragment to do this. If
there is very extended emission and it seems impossible to find a suitable
region, you can make an image without PB correction and measure the off-source
noise to the edges, or the $\sigma_{\mathrm{rms}}$ of the residual image. You
will need to make an image for self-calibration anyway, see Sec. 4.3.

Figure 7: Left: Example pipeline image with PB correction showing possible
location of box to measure rms. Centre: VY CMa showing Clean Components
(yellow) including positive (filled) and negative (hollow) spurious components
due to over-cleaning, within and around the rim of the mask (white). Right: VY
CMa synthesised beam (psf); contours at (–5 , –2.5, 2.5, 5, 10, 20, 40, 80)%
of the beam peak; the greyscale shows the beam at $>$50%.

You can also inspect the visibility phases in plotms, such as are shown in
light green in Fig. 6 lower left. For speed, just plot all or some baselines
to the reference antenna (covering the longest baselines) and iterate through
them. If you can see a clear pattern, then the target probably can be self-
calibrated. For continuum, average line-free channels. You can only average
continuous channel selections. This may not give enough S/N; if so, you can
back up the flags and then flag the line channels, which will allow entire spw
(or even all spw) to be averaged. Restore the flagged channels before the
actual calibration. If necessary average in time, which will also give an idea
of a suitable solution interval. Beware that if some averaging intervals
contain less data they will appear noisier, e.g. Fig. 10(h). If the phase is
coherent but wraps very fast on some or all baselines (as in Fig. 10 (g)), see
Secs. 5.3 or 5.10.3; this may indicate that the target is very offset from the
pointing centre. In this case, you can improve plotting the S/N by using the
plotms transform tab to shift the phase centre used for averaging to the peak
position, to reveal residual wiggles due to phase errors.

####  4.2.2 Conditions for self-calibration

The conditions can be assessed more quantitatively. It is likely to be worth
self-calibrating, at least for phase, if condition (1) below is met; (2) and
(3) are typical situations.

  1. 1.

The target S/N is high enough (typically 3), per antenna, in the longest
interval over which useful corrections can be made, typically a scan. For a
typical execution of a single EB with the 12-m array in full operations
($\sim$43 antennas), 30 mins of on-target data in 5-min scans using the full
available bandwidth of which about half, $\sim$4 GHz, is continuum, self-
calibration should be possible if the image S/N is 100 or more. This is not a
hard limit as the initial $\sigma_{\mathrm{rms}}$ is probably higher – maybe
by a factor of a few – than the potential noise. Moreover, additional
averaging over spw and polarisations may be possible.

  2. 2.

The image noise $\sigma_{\mathrm{rms}}$ is worse than expected for the actual
observing conditions. However, it can be worth self-calibrating even if this
is not the case, as small to moderate phase errors can degrade an image
without noticeably increasing the noise.

  3. 3.

The target dynamic range is hoped to be higher than that of the phase
calibrator, so even if the latter’s solutions were transferred perfectly, the
target solution accuracy can be improved (see also Sec. 3.3). Since the target
is typically observed in longer scans, this can be the case even for a
brighter phase reference source (although the relative bandwidths used also
have to be considered).

Section 4.4.2 derives expressions for the minimum image signal to noise ratio,
S/Nsc, which is ‘enough’ for self-calibration, based on the relationship
between the whole image S/N and the S/N per antenna, per averaging interval.
The longer the whole observation contributing to the image, and the more
antennas, the smaller is the contribution of an individual antenna or a single
scan. For example, for the VY CMa data used here, with only 20 antennas and 1
GHz continuum bandwidth, the minimum S/N required for self-calibration is no
more than $\sim$50.

It is usually worth self-calibrating even in the absence of obvious noise or
dynamic range problems, as moderate phase errors can degrade an image without
noticeable increasing the image $\sigma_{\mathrm{rms}}$. If your data have a
lower S/Nsc than is predicted to be required for straightforward self-
calibration, see Sec. 5.10, but if the S/N in phase-referenced data is less
than about 10, it is very unlikely to be self-calibratable under any
conditions. In any case, not all images can be improved by self-calibration –
see Sec. 6.

###  4.3 Making a preparatory image and model

Calibration compares a model with the data and derives the corrections needed
to make the latter correspond more closely to the former. The model for an
unresolved, extra-solar calibration source may be simply a point of known flux
density at the pointing centre, inserted using task setjy. For target self-
calibration, the model is usually composed of the Clean Components (CC) from a
previous set of image products for the target. We describe here how to prepare
that, but sometimes you may use a product from a different observation of the
same source at comparable resolution (see Sec. 5.12 for Solar system sources
or Appendix D.5 for using AIPS images).

For normal ALMA observations, all previous calibration and flagging up to
phase referencing should be applied, e.g. run scriptForPI.py on the archive
products (see Appendix B.2, the pipeline CASA guide). Alternatively, a local
ARC may be able to supply a calibrated MS, see e.g. the NRAO Science Ready
Data Products service, Appendix B.5.

Split out the target without continuum subtraction. Find the line-free
channels – e.g. use the pipeline/QA2 selection, but check for yourself. In
ALMA data there may be lines even in TDM spw designated continuum. At mm and
shorter wavelengths, the S/N is often greater in the continuum than for a
spectral line, relative to the available bandwidth for each, so we start by
describing using a continuum model. See Sec. 5.2 for additional issues in
using a spectral line for self-calibration.

If the data are FDM with thousands of channels, it can save a lot of imaging
time to make a second copy with averaging to TDM resolution (and select the
renumbered continuum channels). If there has been any channel-selective
flagging (e.g. due to RFI or arising from failed bandpass or
$T_{\mathrm{sys}}$ solutions) then channel-dependent weights are required, see
Sec. 4.7.1. In this manual, we use channel selection to exclude lines from
continuum self-calibration but the lines can alternatively be (temporarily)
flagged. This approach is used in the NRAO template imaging script (link in
Appendix B.5) and requires channel-dependent weights. The script also gives
guidance on limits to frequency- and time-averaging to avoid smearing. This
will not affect typical ALMA averaging within the primary beam FWHM; Appendix
E shows approximate limits for channel- and time-averaging which can cause
smearing; see Sec. 6 for more references, especially if you are using wide-
field cm-wage data.

The advantages in using all spw assume that they provide roughly equal
continuum sensitivity; see Sec. 5.11 and Secs. 5.1 – 5.3 if you are combining
multiple executions and/or need to be more spectrally selective and make an
image accordingly.

This manual assumes the use of tclean but in principle any method of
generating an image model could be used, as long as the model can be Fourier
transformed into the MS and any additional information (e.g. frequency
dependence) is recognised.

####  4.3.1 Imaging for self-calibration

If you are unfamiliar with interactive imaging, see the relevant CASA Guides
(Appendix B.2). Difficult/exceptional situations (for ALMA) are covered in
Secs. 5.5 to 5.12.

For early phase-only calibration, it is better to underclean than overclean;
calibration will not usually remove real emission but spurious CC may lead to
solutions freezing the artefacts into the data. You can usually tell if this
has happened as the image S/N will not improve or sidelobes will worsen. The
risk is greater for sparse visibility plane coverage. Use any a-priori
knowledge of the target field to guide you.

For the first image model:

  * •

If continuum, either make a flag backup and then flag the line channels, or
set the continuum channel selection in tclean spw parameter; here we assume
the latter. If using a spectral line, see Sec. 5.2.

  * •

Use robust=0.5 or greater, usually, as lower values can produce artefacts.

  * •

For homogeneous arrays and many similar baselines (e.g. ALMA 12-m array in all
but the most extended configurations) the weights should be proportional to
sensitivity, see Sec. 4.7.1 and Brogan et al. (2018). If some antennas are
very distant or otherwise hard to calibrate, or for heterogeneous arrays e.g.
e-MERLIN, avoid tapering or other downweighting of particular antennas if
possible unless vital to avoid artefacts (all spacings should be fully
represented to optimise the calibration of all antennas).

  * •

You do not necessarily need to image the whole field of view but all detected
emission must be included, whether or not it is of scientific interest,
leaving an outer signal-free margin of $\sim$$10\%$ to avoid aliasing. At this
stage don’t do the PB correction (see Sec. 5.6 if this would affect your
target).

  * •

Use savemodel =’modelcolumn’ so that your final CC are Fourier transformed
into the MS, to act as a model for the next round of self-calibration (see
Sec. 4.3.2 to check this).

  * •

Mask carefully (usually interactively). Take care not to include sidelobes.
Clean gently. If you have one or more bright peaks plus possibly weak
emission, it is often best to mask just the peaks initially and use a low
cycleniter e.g. 10 or 20; as the peaks are subtracted and stored as CC, the
residual S/N of weaker emission will improve and you can extend the mask and
increase the cycleniter as needed, also see e.g. Brogan et al. (2018) 2.4.1
Mira example.

  * •

Stop cleaning when you can no longer be sure that emission structure left in
the residual image is definitely part of the source (rather than just noise
fluctuations). At this stage there is no need to include faint, extended
emission you are not absolutely sure is real, nor to clean down to a
predefined level of e.g. $3\sigma_{\mathrm{rms}}$.

Fig. 7, centre, shows good Clean Components overlaying real emission, but also
artefacts due to overcleaning. Fig. 8 right shows a safer collection of CC.
When masking, be wary of emission which has a positive or negative counterpart
in a position mirrored about a strong peak. These may be artefacts due to
amplitude or phase errors (Sec. 1.3).

The peak (not integrated) flux density is what determines whether you can
self-calibrate, since that represents the signal on baselines to all antennas.
However, as all emission must be imaged, if the source is very extended,
tclean deconvolver=’multiscale’ processes multiple CC more effectively,
equally usable as models. When you come to making a model for continuum
amplitude self-calibration, ’mtmfs’ also lets you fit for spectral index or
higher terms, see Sec. 4.5.1. Sec. 6.2 discusses further issues which can make
imaging trickier.

You can compare the location of the Clean Components (.model image, display in
the casaviewer as a marker map) with the .psf (see Fig. 7, centre and right)
to see if the distribution is too much like sidelobes. It is not easy to edit
CC in CASA, but in any case it is better to optimise cleaning in the first
place by careful masking and setting a realistic threshold (a few times
$\sigma_{\mathrm{rms}}$ to begin with). The once-common practice of rejecting
components below the worst negative has no real basis (see SI99 Ch. 13 Perley)
since artefacts can be both positive and negative.

If a plot of the target visibility amplitude against $uv$ distance shows a
steep rise in emission on the shortest baselines, suggesting extended emission
which is not properly sampled, or there are nulls in the visibilities (e.g.
for a planet), see Sec. 5.12.

####  4.3.2 Inserting the model for self-calibration in the MS

tclean savemodel=’modelcolumn’ will Fourier transform the CC into the MS, see
Appendix B.3 for link to tclean documentation. This allows gaincal to use this
as a model in the next round of self-calibration. Each time the model is
saved, it overwrites previous models. Check the casalogger at the end of
tclean to ensure the model has been saved, especially if tclean has been
interrupted or if running CASA versions $<$ 6.2.1.

The tclean documentation explains how to run the model insertion process
without re-cleaning, if necessary. This can be done if tclean is interrupted,
or even if you want to revert to a previous model as in Sec. 4.8, as long as
you still have the clean products. Re-run tclean with the parameters and image
name used for the desired model, but with niter=0, savemodel=’modelcolumn’,
calcpsf=False, calcres=False, restoration=False (see the tclean
documentation).

If this is not possible (e.g. you are using a model from a different
observation) you can use task ft to insert the model (similarly, if possible
usescratch=True, to write a full modelcolumn). If you used tclean mtmfs
nterms=2 or higher, set the same value for nterms in ft and include model.tt0,
model.tt1.

In all cases, use of the model column is preferred to a virtual model and the
latter should never be used for ephemeris objects or imaging using the wide
field parameters. If in doubt use plotms to check the model is present and
reasonably close to the data, as in e.g. Fig. 6 top right. In initial rounds
of phase-only self-calibration weaker or extended structure may not be well
represented, but for amplitude self-calibration the model flux should follow
the corrected data well. If not, use gaincal solnorm=True (see Appendix C.1).

Figure 8: Left: VY CMa continuum per-scan (‘inf’) phase solutions for X polarisation, shown as large dots, overlaid with incremental 30-s solutions, for two antennas. Right: VY CMa continuum images at the calibration stages labelled, see Table 3. | Peak (mJy beam-1) |  $\sigma_{\mathrm{rms}}$ (mJy) | S/N
---|---|---|---
Phase calibrator solutions only | 179 | 3.0 | 60
Phase self-calibration (solint inf) | 198 | 1.1 | 180
Phase self-calibration (solint 30s) | 199 | 0.8 | 250
Phase & amp self-calibration | 199 | 0.6 | 325
Table 3: Improvements in the signal to noise ratio (S/N) during incremental
continuum self-calibration of VY CMa (see also Fig. 8).

###  4.4 Deriving the self-calibration solution table (gaincal)

The CASA task gaincal is used to derive solutions by comparing the data and
model columns of an MS and calculating per-antenna corrections to apply to
remove discrepancies from the visibility data. Each visibility represents a
single baseline measurement but the dominant errors are due to the atmosphere
or other effects on specific antennas. Thus, solutions are derived for all
baselines to each antenna and (by default) a least squares procedure is used
to decompose the baseline solutions to find a representative solution for each
antenna which is compatible with good solutions for all antennas. See Sec. 4.6
for assessing the effects of changing parameters on the quality of calibration
tables. Some parameters can usually be left as default (see Appendix B.3, CASA
documentation). The gaincal parameters most relevant for deriving and applying
ALMA self-calibration and suggested values are given in Appendices C.1 and
C.2.

####  4.4.1 Choice of reference antenna

Having inserted a good model in the MS, the next choice is reference antenna
(known as refant). The reference antenna phases are set as the origin of
phase. The refant(s) should be antenna(s) with as much good data as possible,
near the centre of the array. Phase errors are usually less on short baselines
so a central reference antenna helps ensure that it contributes to as good
solutions as possible and thus an accurate origin of phase444For heterogeneous
arrays, use a sensitive antenna, e.g. phased ALMA is normally the refant when
in mm VLBI.

Look for what was used by the pipeline or other prior bandpass and phase
calibrator calibration. The pipeline provides logs for the hif_refant task, or
you can check plots of phase solutions, which should be zero for the reference
antenna. For full polarisation, the same refant should be employed for each
set of data using a given polarization calibrator observation, using gaincal
refantmode=’strict’, which will fail all solutions in a given interval if the
solution for the reference antenna fails. Similarly, if using multiple mosaic
fields to derive the model, a fixed reference antenna should be used.
Otherwise, gaincal, refantmode=’flex’ allows alternative antennas to be used
but it is worth specifying a list of refants, since the defaults may not be
the most suitable.

####  4.4.2 Phase self-calibration and choosing the solution interval

One almost always starts with phase-only self-calibration, since for ALMA and
most cm to sub-mm interferometers, phase errors have the biggest impact on
image fidelity, as explained in Sec. 3. Phase solutions should be derived
separately for the two hands of polarisations (gaintype ’G’) and each spw, at
least for the first round of self-calibration, since there are often
significant phase deviations, unless they have to be combined in order to get
enough S/N, see Sec. 5.10. The choice of averaging interval for each phase
solution depends on the S/N of the data and on how good the model is, both of
which should improve in successive rounds of self-calibration.

The usual ALMA approach is to start with the length of a scan, in order to
reduce the effects of the separation from the phase calibrator and provide an
improved model. If a bright target is known to have a very simple structure
entirely visible in the first image, you might start with a shorter solution
interval. In any case, after applying each set of solutions, the image S/N
should improve and shorter solution intervals may be possible. Section 4.6.1,
Figs. 10 provides guidance for inspecting solution tables. How short an
solution interval to go down to depends on S/N and on how well the image is
improving (so a much shorter interval could be used for a much better model)
down to a minimum (see next paragraphs). If possible, choose solution
intervals which are both an exact multiple of the integration time and
factorise into the scan length, e.g. for 6-s integrations and 300-s scans,
ideal intervals would be e.g. 30-s or 150-s; 75-s would be OK but $<6$ sec
would not make sense and 96-s would leave a 12-s interval at the end of each
scan, see Fig. 10(h).

However you set the solution interval, most solutions should succeed (see
logger Fig. 9) and it should lead to a better image. The minimum solution
interval can be determined in several ways:

Trial and error is a typical approach for small data sets, reducing the solint
until many solutions fail (typically, $>$10%) or the solutions are just random
and the image stops improving.

Inspection of the visibility phase to determine the rate of change of errors
with time. Plot target phase (channel-averaged) against time for baselines to
the reference antenna, as in Sec. 4.2.2. You are looking for the minimum
interval in which phase variations are due to systematic errors. It can be
hard to distinguish atmospheric phase drift from phase slopes due to target
structure. The phase calibrator phases (after applying scan averaged
solutions) can give a clearer indication of the residual phase error rate
(since there is usually no structural phase), Sec. 3.2. If possible, the
solution interval should be such that the errors change by $\leq$$45^{\circ}$
(0.785 rad), which should reduce the decorrelation per interval to
$\lesssim$$25\%$ (Eq. 3). One way to test this for intervals shorter than a
scan for the target is to apply the per-scan solutions, and then plot the
corrected data averaged in time by the same interval as the solint you are
thinking of using and look at the jump between averaged phase points. The
phase should show a systematic change with time, at least over a few averaging
intervals; if it looks random then probably it is dominated by noise and you
need to use a longer averaging interval, see examples in Fig. 10. NB if you
apply calibration tables for tests, you still have to specify whatever you
decide to use in gaincal (and thus the next applycal) as gaincal uses the data
column, not corrected.

Statistical assessment of solution intervals A more rigorous empirical
approach is described in the VLA self-calibration CASA guide (see Appendix B.2
link) testing the S/N of multiple solints to find the interval which gives the
most reliable solutions.

Analytical estimate of the shortest solution interval The shortest feasible
solint can also be estimated analytically, useful for large data sets and non-
interactive calibration.

The analytical estimate is derived as follows. The noise limit of an
interferometry observation with $N$ antennas (for a particular frequency and
other parameters), is given by

$\sigma_{\mathrm{rms}}=\frac{kT_{\mathrm{sys}}}{\sqrt{(N(N-1)/2)\Delta
t\Delta\nu N_{\mathrm{pol}}}}$ (22)

where $T_{\mathrm{sys}}$ is system temperature (Eq. 7) multiplied by a
constant $k$ covering conversion from K to Jy (for ALMA this term includes
estimating the atmospheric contribution for a given elevation and PWV and
antenna efficiency see ALMA-TH, sec. 9.2.1 in 2021); there can be different
considerations for other arrays. The noise is inversely proportional to the
square root of the number of baselines $N(N-1)/2$, the time on source $\Delta
t$, bandwidth contributing to image (e.g. continuum-only) $\Delta\nu$ and the
number of independent polarisations correlated $N_{\mathrm{pol}}$. This is the
predicted ideal image noise.

You can use a sensitivity calculator (Appendix B.4) to find the predicted
$\sigma_{\mathrm{rms}}$ for your whole observation, or indeed for a single
scan.

Since atmospheric, and most instrumental, errors are antenna-based, the S/N
for calibration is usually maximised by deriving solutions per antenna. If all
antennas have the same sensitivity then the noise per baseline over the whole
observation is thus $\sigma_{\mathrm{rms}}\times\sqrt{(N(N-1)/2)}$. Eq. 22 can
be rearranged to give the rms in a solution interval of $\delta t$, per
antenna, per polarisation, per frequency calibration interval $\delta\nu$,
which would typically be continuum-only channels for each separate spw:

$\sigma_{\mathrm{solint,ant}}=\sigma_{\mathrm{rms}}\times\sqrt{\frac{(N(N-1)/2)}{N-3}}\times\sqrt{\frac{\Delta
t}{\delta t}\frac{\Delta\nu}{\delta\nu}N_{\mathrm{pol}}}$ (23)

where $N-3$ is number of antennas – degrees of freedom. There are 3 degrees of
freedom for phase: $N-1$ baselines per antenna; the origin of phase set to
zero and the reference antenna phase (see Cornwell & Wilkinson (1981) and Sec.
2.3). A more formal derivation is presented in Sob et al. (2021) (although we
incorporate an additional degree of freedom).

Typically a S/N of 3 per antenna solution is wanted (see Appendix C.1
parameter minsnr but also Sec 4.6), i.e. $\sigma_{\mathrm{solint,ant}}=P/3$
where $P$ is the image peak, leading to a minimum solint of:

$\delta
t_{0}=\left(\frac{3\sigma_{\mathrm{rms}}}{P}\right)^{2}\frac{(N(N-1)/2)}{N-3}\Delta
t\frac{\Delta\nu}{\delta\nu}N_{\mathrm{pol}}$ (24)

For the VY CMa example, there is only one spw so $\delta{\nu}=\Delta{\nu}$.
From Table 1 and Eq. 24, the minimum solint $\delta t_{0}$ at the start of
self-calibration is 1.7 min or $\sim 100$ sec. This fits well as it is close
to 1/3 of the scan length $\tau_{\mathrm{scan}}$. During self-calibration, the
S/N should improve, allowing a shorter solution interval. The theoretical
minimum solint is $\delta t_{0}\sim 3$ sec but, as in this case, it is not
always desirable to go to the minimum solint. Not only is it less than an
integration time but the shortest-timescale corrigible errors are over a few
tens seconds, below that is noise. Moreover, the rms level of 0.6 mJy obtained
after a 30-sec phase solint and 60-sec amplitude solint is already the
theoretical sensitivity for this frequency and observing parameters, see also
Sec. 4.9.

Given that $\frac{\sigma_{\mathrm{rms}}}{P}$ = 1/(S/N), Eq. 24 can also be
used to estimate the minimum S/N needed to perform per-scan, per-spw self-
calibration:

$\mathrm{S/N}_{\mathrm{sc}}=3\times\sqrt{\frac{(N(N-1)/2)}{N-3}\frac{\Delta
t}{\tau_{\mathrm{scan}}}\frac{\Delta\nu}{\delta\nu}N_{\mathrm{pol}}}$ (25)

For the observing parameters given it Table 1, S/Nsc needs to be at least 35,
and we can see from Table 3 that the starting S/N is well over this. Note that
the example data have only one spw; the commonest real-life difference is that
if there were 4 spw each contributing 1 GHz to the image, for example, S/Nsc
would need to be doubled.

The minimum useful solution interval is the larger of $\delta t_{0}$ (Eq. 24)
and the shortest interval which shows error structure. Do not use so short an
interval that the visibility scatter within it looks entirely like random
noise. If the solutions show a noise-like scatter, usually this means that you
need more averaging to increase S/N, but if you know that the S/N should be
high, it could be that you have averaged too much, see Sec. 4.6.1, Fig. 10(f)
and (g). Even if the minimum solint with sufficient S/N is a scan or more, you
may be able to correct systematic but more rapid phase errors by fitting a
gradient or spline, see Sec. 5.10.3.

###  4.5 Amplitude self-calibration

Amplitude corrections require a higher S/N than for phase. As explained in
Sec. 1.3, averaging data with phase errors decorrelates amplitudes and the
effect of even a few bad (high) solutions can add a lot of noise, so usually
the phase is calibrated first and corrections are applied in gaincal and
applycal during amplitude self-calibration. Section 4.6.1, Fig. 11 gives
examples of good and bad solutions. Amplitude-only self-calibration gaincal
calmode=’a’, is normally used since the phase should already be well-
calibrated and the amplitude self-calibration often uses longer solution
intervals. If calmode=’ap’ is used, residual phase solutions should be small;
if many solutions fail and/or the phase solutions have slowly-changing
structure (Figs.10(b) 11(m)) this probably means that the model is not a good
match to the data. Isolated, wild amplitude solutions (Fig. 11(l)) imply bad
data. Sometimes calmode=’ap’ is used for one-step calibration of simple,
bright sources (often the case for the ‘old’ VLA).

It is usual to start amplitude calibration with a solint of a scan. Formally,
you can use Eq. 24 to estimate the minimum solution interval by replacing
$(N-3)$ by $(N-4)$ (as there is an additional degree of freedom in the flux
scale, also see Sec. 2.3). This increases the minimum solution interval by
roughly 10% compared with that for phase, but usually, correctable amplitude
errors change much more slowly than phase errors so even for high S/N it is
rare to go to the shortest possible interval. If you are considering a
solution interval less than a scan, inspect suitably-averaged phase-corrected
visibility amplitudes against time. If the target is well-resolved, the
amplitude variations due to structure will be faster on long baselines but
errors will vary on similar scales at a given time on most baselines for ALMA
(although for arrays with hundred+ km baselines the weather may be
consistently worse at some antennas). If your target peak is not at the
pointing centre, use the Transform tab in mstransform to enter the offsets in
R.A. and Dec., which will adjust the phase in plotting and avoid amplitude
decorrelation simply due to the phase offset. As in assessing phase solution
intervals, you need to identify the timescale on which errors are systematic,
not just noise. In Fig. 4 bottom right, the scatter within a scan (small dots)
is noise-like so amplitude solution intervals less than a scan are unlikely to
be of any benefit for these data (see also Fig. 11 (k)). In some cases where
the error is the same throughout an observation (as in Fig. 11 (n)), many
scans can be averaged if necessary.

For linear feeds like ALMA, amplitude calibration normally averages X and Y
polarisations, gaincal gaintype=’T’ (see Appendix C.1) to avoid the effects of
parallactic angle rotation. Special care is needed with circular feeds for
circularly polarised targets, see Sec. 5.9. This assumes that at least one
phase solution table previously applied e.g. from the phase calibrator did use
gaintype=’G’ to remove phase offsets between X and Y. This can be checked from
the corrected phase calibrator visibilities. If no polarisation nor
parallactic angle correction has been applied, then for an unpolarised target
there should be no offset between XX and YY visibility amplitudes; if it is
polarised, typically a few percent or less, the offset should appear no more
than this and change smoothly in opposite senses over hours as the parallactic
angle of the feeds rotates with respect to the sky. If there is an excessive
or abrupt/irregular offset (more common for e.g. VLBI arrays than ALMA) then
the polarisations can be calibrated separately (gaintype=’G’) if you are only
interested in total intensity and the actual target polarisation is small.

It is important that the model used for amplitude self-calibration is as
faithful as possible a representation of the target and includes all the
target flux (unlike initial imaging for early phase-calibration when“if in
doubt leave it out”). As seen in Fig. 1, after phase calibration, amplitude
errors give symmetric artefacts – so if you see a peak with one other peak
beside it and no mirrored positive or negative, both peaks are probably real
(see Sec. 5.5.2 for the hazards of over-calibrating on an incorrect, single-
peaked model). Check the residual image when making the model, and if there is
remaining emission which looks like it is part of the target field, adjust the
mask if necessary and clean more deeply.

As explained in Appendix C.1, gaincal solnorm=True, is normally used if the
flux scale is thought to be accurate, especially if your model may not contain
all the target flux, e.g. due to much weak, extended emission. See Fig. 11 (m)
for the effects of a poor model. On the other hand, if there are some data
which are initially very badly scaled (e.g. an antenna for which
$T_{\mathrm{sys}}$ or phase referencing failed for some scans, see Sec. 5.3)
then you should not use normalisation. If amplitude self-calibration with
solnorm=False produces a significant decrease in flux density of the
subsequent image you should check the model and gaincal parameters, but if
nothing can be improved, repeat gaincal with solnorm=True. If you do not
normalise the solutions and the flux density increases by more than a few
percent, you should work out why. It is often because you have over-cleaned
and piled too much flux into a small area of model, so the image will have a
higher peak but worse sidelobes and/or missing extended structure. If so you
should re-make the input model (and check it has been inserted into the MS).
Alternatively, it may be a sign that the target is simply too weak for
amplitude self-calibration, at least without more averaging.

See Sec. 4.6.2 for more on assessing amplitude calibration tables.

####  4.5.1 Multi-frequency synthesis for amplitude self-calibration

Multi-frequency synthesis (MFS) in making a multi-channel continuum image
involves fitting for the variation of flux density with frequency (e.g.
spectral index) when deriving Clean Components. You do not usually need this
before phase-only self-calibration of an ALMA observation, as the position of
continuum emission in the field of view is not normally frequency dependent.
If the continuum S/N is high enough to consider amplitude self-calibration,
however, it is often worth fitting for spectral terms in tclean when preparing
the prior model, after applying the phase self-calibration. Even if the fitted
spectral index (.alpha image) has large uncertainties the total intensity
image will be improved and the model (.tt0 and .tt1) will make sure that the
flux density slope across spectral windows is correctly calibrated. For
spectral index $\alpha$, the flux density $S_{1}$ at frequency $\nu_{1}$ is
related to that at $\nu_{0}$ by:

$S_{1}=S_{0}\left(\frac{\nu_{1}}{\nu_{0}}\right)^{\alpha}$ (26)

You can thus estimate the flux density in the lowest and highest frequency spw
present. The full observation VY CMa observation used 4 spw centred at 314.0,
315.8, 326.0 and 327.8 GHz, the nominal central frequency is 320.9 GHz. The
total continuum flux density is 200 mJy and from the properties of a red
supergiant like VY CMa we expect $\alpha\sim 1.5$. So, the difference in flux
density between the highest and lowest spectral windows is (206.5-193.6) = 6.1
mJy. The sensitivity calculator gives rms per spectral window $\lessapprox 1$
mJy for each spw (for 1 GHz line-free continuum per spw and 30 min on target),
so it is worth using tclean deconvolver=’mtmfs’, nterms=2. (The VY CMa example
used here has just one spw so MFS was not used).

More generally, for a spectral index $\alpha=\pm 0.7$, this can make a 10%
difference across the maximum single-execution bandwidth at Band 3\. At Band 7
the difference is 3.3% which means that it is still significant for S/N$\geq
30$, and even at higher bands, $\alpha=\pm 2$ provides a similar significance.
This provides a smooth change in amplitude with frequency and better image
quality. However, when the fractional frequency span of all data used is
$\lessapprox$10% the precise slope and thus the $\alpha$ map itself is often
unreliable. Occasionally (very bright sources/combined observations over a
large fractional bandwidth) it may be possible to use nterms $>$ 2. However,
if it is difficult to get a good model, or if the S/N is close to the lower
limit, compare imaging with and without MFS to check that it makes an
improvement and does not produce amplitude artefacts, as it may be safer to
make a simple single-term image.

Continuum amplitude calibration, with a spectral slope if S/N allows, not only
improves the solution accuracy but it ensures that the flux scale is
consistent across spectral windows.

###  4.6 Judging the quality of solution tables, failed solutions and flagging

This section provides guidance in how to assess solution tables and what to do
in case of problems. This should be done alongside assessing their effects on
imaging (see error recognition from images Sec. 6) and on the visibilities.
When checking visibility data, apply all previous good calibration and if
necessary experiment with different averaging, Sec. 4.4.2 on Inspection of the
visibility phase (and the same goes for amplitude calibration). If all the
data for some antennas are noisier, but not pure noise, this may be inevitable
if they have mostly long baselines (many km for ALMA) or are less sensitive
(e.g. smaller diameters in VLBI); this usually should not be flagged as
downweighting may compensate without removing their contribution altogether,
Sec. 4.7.1.