ska_sdp_instrumental_calibration.plot.plot_gaintable module

class ska_sdp_instrumental_calibration.plot.plot_gaintable.PlotGaintable(refant=None, path_prefix=None)[source]

Bases: object

Base class for plotting gaintable solutions (amplitude and phase).

This class provides the core logic for preparing gaintable data (an xarray.Dataset) and generating faceted scatter plots. It is intended to be subclassed (e.g., by PlotGaintableFrequency or PlotGaintableTime) to specify the x-axis dimension and its corresponding secondary axis.

Parameters:
  • refant (int, default None) -- The reference antenna index used for normalizing the bandpass solutions. If provided, the gains will be divided by the reference antenna's gains while preserving phase.

  • path_prefix (str, optional) -- A prefix used to construct the output filenames for the plots. Defaults to None.

_plot_args

Default arguments passed to the xarray.plot.scatter method.

Type:

dict

_x_label

Label for the primary x-axis.

Type:

str

_x_sec_label

Label for the secondary x-axis (top).

Type:

str

_x_data

Data used to map between the primary and secondary x-axes.

Type:

array-like

_x_sec_data

Data used to map between the primary and secondary x-axes.

Type:

array-like

_path_prefix

Storage for the provided path_prefix.

Type:

str

property xdim

Abstract property for the x-dimension name.

This property defines a short string used in the output plot filename to identify the x-axis dimension (e.g., 'time' or 'freq').

Raises:

NotImplementedError -- This property must be overridden by a subclass.

Type:

str

observation_start_time(gaintable)[source]

Extract the observation start time from the gaintable.

Converts the first time timestamp in the gaintable (assumed to be seconds) to a UTC datetime object.

Parameters:

gaintable (xarray.Dataset) -- The input gaintable containing a 'time' coordinate.

Returns:

The start time of the observation in UTC.

Return type:

numpy.datetime64

plot()

Generate and save facet plots for gaintable phase and amplitude.

This is a Dask delayed method that creates two plots (unless phase_only is True): one for the phase and one for the amplitude of the gains, faceted by station and colored by Jones solution. The plots are saved to disk using the path_prefix.

Parameters:
  • gaintable (xarray.Dataset) -- The input gaintable dataset to plot.

  • figure_title (str, optional) -- A prefix for the main figure title. Defaults to "".

  • drop_cross_pols (bool, optional) -- If True, cross-polarization solutions (e.g., J_XY, J_YX) are dropped before plotting. Defaults to False.

  • fixed_axis (bool, optional) -- If True, the y-axis for the amplitude plot is fixed between 0 and 1. Defaults to False.

  • phase_only (bool, optional) -- If True, only the phase plot is generated and saved. Defaults to False.

  • plot_all_stations (bool, optional) -- If True, calls the _plot_all_stations method to generate an additional overview plot. Defaults to False.

Return type:

None

class ska_sdp_instrumental_calibration.plot.plot_gaintable.PlotGaintableFrequency(**kwargs)[source]

Bases: PlotGaintable

Plots gaintable solutions against frequency/channel.

This class extends PlotGaintable to handle plotting where the primary x-axis represents 'Channel' (index) and the secondary x-axis represents 'Frequency [MHz]'. It interpolates between these two domains to provide dual-axis visualizations.

Parameters:

**kwargs -- Keyword arguments passed to the PlotGaintable parent class, such as path_prefix.

property xdim

Specifies the x-dimension name for frequency plots.

Returns:

Returns "freq".

Return type:

str

Type:

str

class ska_sdp_instrumental_calibration.plot.plot_gaintable.PlotGaintableTime(**kwargs)[source]

Bases: PlotGaintable

Plots gaintable solutions against time.

This class extends PlotGaintable to handle plotting where the primary x-axis represents 'Observation Time (S)' (relative to the start) and the secondary x-axis represents 'Time Index'.

Parameters:

**kwargs -- Keyword arguments passed to the PlotGaintable parent class, such as path_prefix.

property xdim

Specifies the x-dimension name for time plots.

Returns:

Returns "time".

Return type:

str

Type:

str

class ska_sdp_instrumental_calibration.plot.plot_gaintable.PlotGaintableTargetIonosphere(path_prefix)[source]

Bases: PlotGaintableFrequency

Plots gaintable solutions as a Time vs. Frequency heatmap.

This class extends PlotGaintableFrequency to generate diagnostic plots specifically for ionospheric target calibration. It visualizes phase variations across both time and frequency channels simultaneously, creating a heatmap where the x-axis is Channel/Frequency and the y-axis is Time.

Parameters:

path_prefix (str) -- A prefix used to construct the output filenames for the plots.

property xdim

Specifies the dimension identifier for filenames.

Returns:

Returns "time-freq" to indicate a dual-domain plot.

Return type:

str

Type:

str

plot()

Generate and save Time vs. Frequency phase heatmaps.

This is a Dask delayed method that creates a faceted plot where each panel represents a station. The color intensity represents the phase of the gain solution.

Parameters:
  • gaintable (xarray.Dataset) -- The input gaintable dataset to plot.

  • figure_title (str, optional) -- A prefix for the main figure title. Defaults to "".

  • **kwargs -- Additional keyword arguments (ignored).

Return type:

None