PlotUtils.AnomalyBands#

PlotUtils.AnomalyBands.py

Shared utility for drawing anomaly exclusion bands across all plot types (plot_compact, plot_components, MplMonitor).

get_anomaly_mask_from_ssd(ssd)#

Extract the XR anomaly mask from an SSD object.

Returns (jv, mask) where mask is a boolean array, or (None, None) if no anomaly information is available.

Handles both concrete boolean arrays (from corrected_copy()) and slice objects (stored by set_anomaly_mask() on trimmed data), converting the latter to a boolean array over jv.

draw_anomaly_bands(ax, jv, mask, color=None, alpha=None)#

Draw shaded vertical bands for contiguous runs of True in mask.

Parameters:
  • ax (matplotlib Axes) – The axes to draw on.

  • jv (array-like) – Frame indices (x-axis values).

  • mask (array-like of bool) – True for anomalous frames.

  • color (str, optional) – Band color. Default: ‘red’.

  • alpha (float, optional) – Band transparency. Default: 0.08.

draw_anomaly_bands_for_ssd(xr_ax, uv_ax, ssd)#

Draw anomaly bands on XR and UV axes using SSD anomaly info.

Parameters:
  • xr_ax (matplotlib Axes) – XR elution axis.

  • uv_ax (matplotlib Axes or None) – UV elution axis (may be twin axis).

  • ssd (SecSaxsData) – The data object carrying anomaly mask information.