## Self-Calibration Implementation

The typical procedure for self-calibration consists in an iterative process based on the following steps:

1. UV_MAP /SELF + CLEAN + UV_RESTORE /SELF:
   from the classically calibrated (and preliminarily flagged) data, define an initial source model through a conservative (not too deep) first deconvolution : the model consists of a reasonably modest number of CLEAN components.
2. SOLVE: determine an estimate of the antenna gains (best fit to the observed visibilities)
3. APPLY: apply the derived gains to correct the observed data
4. STATISTIC: compare to the initial Image, and estimate the improvement through an adequate quality assessment (e.g., improvement of the dynamic range)
5. If necessary, re-build a new model from these corrected data, and iterate until the solution is satisfactory.

Phase-only self-calibration is less stringent on the signal-to-noise ratio (SNR) threshold than amplitude self-calibration, and it should therefore be attempted first. For phase self-calibration to work, the SNR values in the initial data should be at least of SNR>3 per antenna (in a solution interval shorter than the time for significant phase variations for all baselines to a single antenna). The SNR threshold in the initial image depends on the number of antennas and on the adopted time averaging. Depending on the complexity of the source (and the contribution from extended emission), all available baselines may not be considered in the process, and specific preliminary flagging could be necessary. Amplitude errors tend to be negligible for dynamic ranges below about 500. Amplitude self-calibration will thus be eventually attempted in a subsequent step.

Self Calibration is available in IMAGER through the command SELFCAL, which uses an iterative scheme driven by a script (gag_pro:p_selfcal.ima). From the above principle, the script controls
a) the number of iterations
b) the number of selected clean components at each iteration
c) the time scale of the solution, i.e. the integration time over which the gains are assumed to be constant

The parameters of the command SELFCAL are available as SELF_Names SIC variables. The script uses the commands UV_MAP, CLEAN, and SOLVE and APPLY from the CALIBRATE\ language. By default, a solution is searched for the phase calibration only ( SELF_MODE=PHASE), and the number of iterations is 3 ( SELF_LOOP). For each iteration:

- All components found by CLEAN are kept by default ( SELF_NITER = 0), but for simple source structures, 10 components only may be enough (the maximum number NITER of CLEAN components to subtract is automatically guessed by the program in the default process, see CLEAN_NITER and other usual clean convergence control variables),
- the minimum flux density per pixel to be considered by CLEAN can be defined ( SELF_MINFLUX = 0)
- The ”integration” times (gain averaging) are fixed to a default value SELF_TIMES =45 s (minimum value for NOEMA, while it is only 6 s for ALMA). This can be adapted for each loop (in general, one should start with larger solution times, depending on the SNR values and try to decrease it in order to better sample the atmospheric fluctuations).

The number of iterations can be changed by resizing the SELF_TIMES, SELF_NITER, or SELF_MINFLUX arrays (the number of loops SELF_LOOP is then automatically recomputed). You should make sure that these 3 arrays have the same dimension. If any of the SELF_NITER and/or SELF_MINFLUX array are constant then their dimension is accordingly changed by SELFCAL each time one of these arrays is resized. For instance, the following command allows to define 5 loops with an integration time for solution of 45 sec:

let Self_times 45 45 45 45 45 /resize

SELF_NITER and SELF_MINFLUX are automatically enlarged to the same size if, and only if, they were already constant. By default, all channels are averaged to compute a ”continuum” image, but the range of adequate channels can be specified through SELF_CHANNEL.

SELFCAL PHASE will compute a phase calibration, but will not apply it. One needs to call SELFCAL once more with the argument APPLY in order to apply the solution. The script really applies the solution if and only if the previously found solution can be considered as a good one (see SELF_STATUS argument value).

SELFCAL APPLY automatically saves the parameters and results in the selfcal.last file. By default, data are flagged if no sufficiently good solution is found. SELFCAL APPLY keep tracks of whether the solution has already been applied through SELF_APPLIED. SELFCAL APPLY will refuse to apply “bad” solutions: solutions are declared “bad” if the improvement in dynamic range and noise level is insufficient (i.e. below a precision level controlled by SELF_PRECISION). In this case, the SELF_STATUS variable is negative. In this case, the user can still decide to apply the solution directly using command APPLY, but the SELF_APPLIED variable will not be updated.

The merit criteria for the quality assessment of the computed solution are the final dynamic range, and the Clean map noise at each iteration. These quantities are stored in the SELF_DYNAMIC and SELF_RMSCLEAN variables (at each iteration). The dynamic is defined as the ratio of the peak flux density value to the noise in the clean map (automatically estimated with the command STATISTIC). The minimum signal to noise ratio value (for an antenna) for a valid solution is SELF_SNR=6 by default.

SELFCAL can be controlled through a widget, using command SELFCAL /WIDGET (see Figure )

Figure: The Self-Calibration widget

It is possible to visualize the computed corrections with the command SELFCAL SHOW. The solution computed with the SOLVE command is written in a 'self_sname'.tab file. By default, the difference between the last two iterations is displayed. For PHASE, the phase difference should be close to zero if the solution converged, and for AMPLI the amplitude values close to 1. It is also possible to show the difference between two specified iterations. In addition, the command SELFCAL SUMMARY will display the results of the process in terms of resulting noise and improved dynamic range. If the solution is satisfactory, the command SELFCAL SAVE can be used to save both the results and the parameters in the selfcal.last file. ( SELFCAL APPLY performs an implicit SELFCAL SAVE.)