ska_sdp_instrumental_calibration.numpy_processors.solvers.gain_substitution_solver module

class ska_sdp_instrumental_calibration.numpy_processors.solvers.gain_substitution_solver.GainSubstitution(refant=0, phase_only=False, crosspol=False, **kwargs)[source]

Bases: Solver

Solver for antenna gains using the gain substitution algorithm.

This class implements the iterative gain substitution method for solving antenna-based complex gains in radio interferometric calibration. It compares observed visibilities against a model to derive gain corrections.

Parameters:
  • refant (int, optional) -- Index of the reference antenna. The phase of this antenna is clamped to zero during the solution. Default is 0.

  • phase_only (bool, optional) -- If True, solve only for the phase of the gains, keeping amplitudes constant. Default is False.

  • crosspol (bool, optional) -- If True, solve for cross-polarization terms (e.g., XY, YX, RL, LR) in addition to parallel hands. Default is False.

  • **kwargs -- Additional keyword arguments passed to the base Solver class (e.g., niter, tol).

refant

Reference antenna index.

Type:

int

phase_only

Whether to solve for phase only.

Type:

bool

crosspol

Whether to solve for cross-polarization.

Type:

bool

Examples

>>> solver = GainSubstitution(refant=0, phase_only=True, niter=50)
>>> gains, wgt, resid = solver.solve(vis, flags, wgt, model, ...)
solve(vis_vis, vis_flags, vis_weight, model_vis, model_flags, gain_gain, gain_weight, gain_residual, ant1, ant2)[source]

Run the gain substitution solver algorithm.

This method prepares the visibility data (creating point source equivalents) and invokes the iterative substitution solver.

Parameters:
  • vis_vis (np.ndarray) -- Complex observed visibilities. Shape: (ntime, nbl, nchan, npol).

  • vis_flags (np.ndarray) -- Boolean flags for observed visibilities (True is flagged).

  • vis_weight (np.ndarray) -- Weights for observed visibilities.

  • model_vis (np.ndarray) -- Complex model visibilities. Must be provided if model_flags is provided.

  • model_flags (np.ndarray) -- Boolean flags for model visibilities.

  • gain_gain (np.ndarray) -- Initial guess for complex gains. Shape: (ntime_sol, nchan_sol, nant, nrec, nrec).

  • gain_weight (np.ndarray) -- Weights for the gain solutions.

  • gain_residual (np.ndarray) -- Buffer to store residuals of the fit.

  • ant1 (np.ndarray) -- Indices of antenna 1 for each baseline.

  • ant2 (np.ndarray) -- Indices of antenna 2 for each baseline.

Returns:

A tuple containing (gain_gain, gain_weight, gain_residual) with the updated solutions.

Return type:

tuple of np.ndarray

Raises:

ValueError -- If refant is out of bounds. If model_vis contains only zeros or is mismatched with flags.