ska_sdp_instrumental_calibration.numpy_processors.solvers.solver module

class ska_sdp_instrumental_calibration.numpy_processors.solvers.solver.Solver(niter=50, tol=1e-06, **_)[source]

Bases: object

Base class for gain solvers.

This class provides a common interface and shared configuration for calibration solvers. Subclasses should implement the solve method for specific algorithms. This class also acts as a central registry, allowing for the dynamic retrieval and instantiation of solver classes based on string identifiers.

Parameters:
  • niter (int, optional) -- Maximum number of iterations for the solver. Default is 50.

  • tol (float, optional) -- Convergence tolerance for the iterative solver. Default is 1e-6.

  • **_ (dict) -- Additional keyword arguments (ignored by the base class).

niter

Maximum number of iterations.

Type:

int

tol

Convergence tolerance.

Type:

float

Class Attributes
----------
_solvers

A registry dictionary mapping unique solver names (str) to their corresponding classes (type).

Type:

dict

Examples

>>> # Assuming GainSubstitution is defined with _SOLVER_NAME_
>>> solver = Solver.get_solver("gain_substitution", niter=10)
>>> print(type(solver))
<class 'GainSubstitution'>
classmethod get_solver(solver='gain_substitution', **kwargs)[source]

Retrieve and instantiate a solver by name.

Parameters:
  • solver (str, optional) -- The unique identifier of the solver to instantiate. Default is "gain_substitution".

  • **kwargs -- Keyword arguments passed directly to the solver's constructor.

Returns:

An instance of the requested solver class.

Return type:

object

Raises:

ValueError -- If the requested solver name is not found in the registry.

solve(vis_vis, vis_flags, vis_weight, model_vis, model_flags, gain_gain, gain_weight, gain_residual, ant1, ant2)[source]

Run the calibration solver (abstract method).

This method defines the standard signature for all solver implementations. It accepts observed data, model data, and initial gain estimates, returning updated gains.

Parameters:
  • vis_vis (np.ndarray) -- Observed visibility data. Shape: (time, baseline, freq, pol).

  • vis_flags (np.ndarray) -- Flags for observed visibilities. Shape matches vis_vis.

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

  • model_vis (np.ndarray) -- Model visibility data. Shape matches vis_vis.

  • model_flags (np.ndarray) -- Flags for model visibilities. Shape matches vis_vis.

  • gain_gain (np.ndarray) -- Initial gain estimates. Shape: (time, ant, freq, rec1, rec2).

  • gain_weight (np.ndarray) -- Storage for gain weights. Shape matches gain_gain.

  • gain_residual (np.ndarray) -- Storage for gain residuals. Shape matches gain_gain.

  • ant1 (np.ndarray) -- Indices of antenna 1 for each baseline. Shape: (nbl,).

  • ant2 (np.ndarray) -- Indices of antenna 2 for each baseline. Shape: (nbl,).

Returns:

A tuple containing:

  • Updated gain array.

  • Gain weights.

  • Gain residuals.

Return type:

tuple of np.ndarray

Raises:

NotImplementedError -- This method must be overridden by subclasses.