Skip to content

striqt.figures

One plot function per measurement data variable, and the axis and legend labels derived from dataset coordinates.

cellular_5g_pss_correlation

cellular_5g_pss_correlation(
    data: Dataset,
    plotter: _PlotBackend,
    *,
    hue: str = 'cellular_ssb_beam_index',
    dB: bool = True,
) -> Path | None

plot cellular_5g_pss_correlation of data as power against cellular_ssb_lag.

The values are the squared magnitude of the correlation in the first sync block (cellular_ssb_start_time index 0). The lower y limit is 7 dB below the smallest median power over lags of the hue values.

Parameters:

  • data (Dataset) –

    the dataset with the cellular_5g_pss_correlation variable and its cellular_cell_id2, cellular_ssb_start_time, cellular_ssb_beam_index, and cellular_ssb_lag coordinates

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • hue (str, default: 'cellular_ssb_beam_index' ) –

    'cellular_ssb_beam_index' draws one line per beam index, averaged over cellular_cell_id2; 'cellular_cell_id2' draws one line per cell sector ID, averaged over cellular_ssb_beam_index

  • dB (bool, default: True ) –

    True draws the power in dB, False in linear units

Returns:

  • Path | None –

    the path of the figure file, or None when the backend writes no file

Raises:

  • KeyError –

    if hue is neither 'cellular_ssb_beam_index' nor 'cellular_cell_id2'

cellular_5g_ssb_spectrogram

cellular_5g_ssb_spectrogram(
    data: Dataset,
    plotter: _PlotBackend,
    noise_line: bool = True,
) -> None

plot cellular_5g_ssb_spectrogram of data as a heatmap of symbol by frequency.

The first burst set of each capture (cellular_ssb_index 0) is drawn. The color scale starts 6 dB below the lowest system noise level over the captures, in 2 dB bands; without a system_noise variable in data the scale starts at the data minimum.

Parameters:

  • data (Dataset) –

    the dataset with the cellular_5g_ssb_spectrogram variable and its cellular_ssb_index, cellular_ssb_symbol_index, and cellular_ssb_baseband_frequency coordinates

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • noise_line (bool, default: True ) –

    True marks the system noise level on the colorbar, from system_noise (dBm/Hz) of data in the noise_bandwidth of the variable; nothing is marked without system_noise

cellular_cyclic_autocorrelation

cellular_cyclic_autocorrelation(
    data: Dataset,
    plotter: _PlotBackend,
    *,
    hue: str = 'link_direction',
    dB: bool = False,
) -> Path | None

plot cellular_cyclic_autocorrelation of data against cyclic_sample_lag.

Parameters:

  • data (Dataset) –

    the dataset with the cellular_cyclic_autocorrelation variable and its link_direction, subcarrier_spacing, and cyclic_sample_lag coordinates

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • hue (str, default: 'link_direction' ) –

    'link_direction' draws one line per link direction at the subcarrier_spacing with the largest peak; 'subcarrier_spacing' draws one line per spacing of the 'downlink' row

  • dB (bool, default: False ) –

    True converts the values from linear power to dB before drawing

Returns:

  • Path | None –

    the path of the figure file, or None when the backend writes no file

Raises:

  • TypeError –

    if hue is neither 'link_direction' nor 'subcarrier_spacing'

cellular_resource_power_histogram

cellular_resource_power_histogram(
    data: Dataset,
    plotter: _PlotBackend,
    *,
    hue: str = 'link_direction',
    noise_line: bool = True,
    yscale: ScaleOptions = 'linear',
) -> Path | None

plot cellular_resource_power_histogram of data against the power bins.

The x axis spans from 12 dB below the system noise level of each capture, or from the lowest bin without a system_noise variable in data, to 3 dB above the highest populated bin over the captures.

Parameters:

  • data (Dataset) –

    the dataset with the cellular_resource_power_histogram variable and its link_direction and cellular_resource_power_bin coordinates

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • hue (str, default: 'link_direction' ) –

    the dimension of the histogram that selects one line per value

  • noise_line (bool, default: True ) –

    True marks the system noise level as a vertical line on each facet, from system_noise (dBm/Hz) of data in the noise_bandwidth of the power bins; nothing is marked without system_noise

  • yscale (ScaleOptions, default: 'linear' ) –

    the y axis scale, 'linear' or 'log'

Returns:

  • Path | None –

    the path of the figure file, or None when the backend writes no file

channel_power_histogram

channel_power_histogram(
    data: Dataset,
    plotter: _PlotBackend,
    hue: str = 'power_detector',
    noise_line: bool = True,
    yscale: ScaleOptions = 'linear',
) -> Path | None

plot channel_power_histogram of data against channel_power_bin.

The x axis spans from 12 dB below the system noise level of each capture, or from the lowest bin without a system_noise variable in data, to 3 dB above the highest populated bin over the captures.

Parameters:

  • data (Dataset) –

    the dataset with the channel_power_histogram variable and its power_detector and channel_power_bin coordinates

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • hue (str, default: 'power_detector' ) –

    the dimension of the histogram that selects one line per value

  • noise_line (bool, default: True ) –

    True marks the system noise level as a vertical line on each facet, from system_noise (dBm/Hz) of data in the noise_bandwidth of the power bins; nothing is marked without system_noise

  • yscale (ScaleOptions, default: 'linear' ) –

    the y axis scale, 'linear' or 'log'

Returns:

  • Path | None –

    the path of the figure file, or None when the backend writes no file

channel_power_time_series

channel_power_time_series(
    data: Dataset,
    plotter: _PlotBackend,
    *,
    hue: str = 'power_detector',
    noise_line: bool = True,
) -> Path | None

plot channel_power_time_series of data against time_elapsed.

Parameters:

  • data (Dataset) –

    the dataset with the channel_power_time_series variable and its power_detector and time_elapsed coordinates

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • hue (str, default: 'power_detector' ) –

    the dimension that selects one line per value

  • noise_line (bool, default: True ) –

    True marks the system noise level as a horizontal line on each facet, from system_noise (dBm/Hz) of data in the noise_bandwidth of the variable; nothing is marked without system_noise

Returns:

  • Path | None –

    the path of the figure file, or None when the backend writes no file

cyclic_channel_power

cyclic_channel_power(
    data: Dataset,
    plotter: _PlotBackend,
    *,
    center_statistic: str | float = 'mean',
    bound_statistics: tuple[str | float, str | float] = (
        'min',
        'max',
    ),
    hue: str = 'power_detector',
    dB: bool = True,
    steps: bool = True,
    noise_line: bool = True,
) -> Path | None

draw the center_statistic line and the bound_statistics band per hue value.

Parameters:

  • data (Dataset) –

    the dataset with the cyclic_channel_power variable

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • center_statistic (str | float, default: 'mean' ) –

    the cyclic_statistic value drawn as the line

  • bound_statistics (tuple[str | float, str | float], default: ('min', 'max') ) –

    the cyclic_statistic values at the lower and upper edge of the shaded band

  • hue (str, default: 'power_detector' ) –

    the dimension that selects one line and band per value

  • dB (bool, default: True ) –

    False converts the values from dB to linear power before drawing

  • steps (bool, default: True ) –

    True holds each value until the next cyclic_lag sample

  • noise_line (bool, default: True ) –

    True marks the system noise level on each facet

Returns:

  • Path | None –

    the path of the figure file, or None when the backend writes no file

Raises:

  • ValueError –

    if center_statistic or either of bound_statistics is not a cyclic_statistic value of data

data_var_plotters

data_var_plotters() -> Mapping[str, _DataVariablePlotter]

return a read-only mapping from data variable name to plotting function.

Each key is the name of a data variable in an analysis dataset. Each value is the function that draws the variable, called as plotter(ds, backend, **options): ds is the dataset that contains the variable, backend a PlotBackend, and options the keyword arguments of the function.

Returns:

  • Mapping[str, _DataVariablePlotter] –

    a read-only view of the registered functions; item assignment raises

  • Mapping[str, _DataVariablePlotter] –

    TypeError

index_dataset

index_dataset(
    ds: Dataset,
    index_coords: Sequence[str] = ('start_time', 'port'),
    *,
    chunks: int | Literal['auto'] | None = None,
) -> Dataset

return ds with a multi-index over index_coords.

With xarray older than 2024.9.0 the uniqueness check is skipped and a WARNING is logged on the analysis logger.

Parameters:

  • ds (Dataset) –

    the sensor dataset to index

  • index_coords (Sequence[str], default: ('start_time', 'port') ) –

    capture field names, or 'sweep_start_time', that together select exactly one capture

  • chunks (int | Literal['auto'] | None, default: None ) –

    a chunk size or 'auto' backs the result with dask arrays (xarray.Dataset.chunk), and None keeps the arrays of ds

Returns:

  • Dataset –

    the data and coordinates of ds with the multi-index set

Raises:

  • ValueError –

    if index_coords do not select exactly one capture

label_axis

label_axis(
    which_axis: Literal['x', 'y', 'colorbar'],
    ax_data: Union[DataArray, Dataset],
    *,
    coord_name: Optional[str] = None,
    tick_units: bool | Literal['auto'] = 'auto',
    short: bool = True,
    ax: Optional[Axes | list[Axes]] = None,
    fig: Optional[Figure] = None,
) -> None

label an axis with the quantity and units named by the attrs of ax_data.

The label text is striqt.analysis.labels.quantity_label of the attrs. With a units attr, an EngFormatter with one SI prefix is set on each target axis. The prefix is striqt.waveform.units.si_prefix of the extent of the finite values, and is fixed for the axis. The prefixed units are in every tick label with tick_units True, or in the axis label with tick_units False, never in both. A label is set with or without finite values. The xarray plot unit label format is changed process-wide to 'Label (units)'.

Parameters:

  • which_axis (Literal['x', 'y', 'colorbar']) –

    'x', 'y', or 'colorbar'; the colorbar axis is the first colorbar of the figure

  • ax_data (Union[DataArray, Dataset]) –

    the array with the attrs that name the quantity and the values that select the prefix

  • coord_name (Optional[str], default: None ) –

    a coordinate of ax_data that supplies the attrs and values instead, or None

  • tick_units (bool | Literal['auto'], default: 'auto' ) –

    True places the prefixed units in each tick label and False in the axis label; 'auto' is True for a units attr of 1 or 2 characters

  • short (bool, default: True ) –

    True labels with standard_name; False labels with long_name when the attrs set one

  • ax (Optional[Axes | list[Axes]], default: None ) –

    the axes, or list of axes, to label; None labels the current axes, or every axes of fig when fig is given

  • fig (Optional[Figure], default: None ) –

    when given with ax None, an x or y label is set once as a figure super-label and the per-axes labels are hidden

Raises:

  • ValueError –

    if which_axis is not one of the 3 values, if a colorbar is requested and the figure has none, or if there are no axes to label

label_by_coord

label_by_coord(
    data: DataArray,
    fmt: str,
    coord_or_dim: str = 'port',
    *,
    title_case: bool = True,
    **extra_fields: Any,
) -> list[str]

return fmt formatted once per value of coord_or_dim in data.

The fields of fmt are the coordinates on the dimension of coord_or_dim and extra_fields. The coordinate value is used when a coordinate and an extra field share a name. The xarray plot unit label format is changed process-wide to 'Label (units)'.

Parameters:

  • data (DataArray) –

    the array with the coordinates

  • fmt (str) –

    a str.format template; a numeric field accepts a prefix symbol spec ('{center_frequency:M}') or a float spec ('{center_frequency:.0f}')

  • coord_or_dim (str, default: 'port' ) –

    the coordinate or dimension that selects one entry per value

  • title_case (bool, default: True ) –

    True title-cases a lowercase string coordinate value

  • **extra_fields (Any, default: {} ) –

    further fields of fmt

Returns:

  • list[str] –

    one string per value of coord_or_dim

label_legend

label_legend(
    data: Union[DataArray, Dataset],
    *,
    coord_name: str | None = None,
    tick_units: bool = True,
    ax: Optional[Axes] = None,
) -> Legend

add a legend with one entry per value of data and a title naming the quantity.

Numeric entries share one SI prefix. A string value is written as is. The xarray plot unit label format is changed process-wide to 'Label (units)'.

Parameters:

  • data (Union[DataArray, Dataset]) –

    the array or dataset with the attrs and values that label the legend

  • coord_name (str | None, default: None ) –

    a coordinate of data that supplies the attrs and values, or None for data itself

  • tick_units (bool, default: True ) –

    True ends each entry with the prefixed units; False ends the title with the prefixed units in parentheses and leaves each entry a bare mantissa

  • ax (Optional[Axes], default: None ) –

    the axes that receives the legend; None uses the current axes

Returns:

  • Legend –

    the matplotlib.legend.Legend added to ax

power_spectral_density

power_spectral_density(
    data: Dataset,
    plotter: _PlotBackend,
    *,
    hue: str = 'time_statistic',
    noise_line: bool = True,
) -> Path | None

plot power_spectral_density of data against baseband_frequency.

Parameters:

  • data (Dataset) –

    the dataset with the power_spectral_density variable and its time_statistic and baseband_frequency coordinates; the variable and the statistic coordinate are also read under the names persistence_spectrum and persistence_statistics

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • hue (str, default: 'time_statistic' ) –

    the dimension that selects one line per value

  • noise_line (bool, default: True ) –

    True marks the system noise level as a horizontal line on each facet, from system_noise (dBm/Hz) of data in the noise_bandwidth of the variable; nothing is marked without system_noise

Returns:

  • Path | None –

    the path of the figure file, or None when the backend writes no file

spectrogram

spectrogram(
    data: Dataset,
    plotter: _PlotBackend,
    noise_line: bool = True,
) -> None

plot spectrogram of data as a heatmap of time by baseband frequency.

A frequency bin with a nan value in any pixel is not drawn. The color scale starts 6 dB below the lowest system noise level over the captures, in 2 dB bands; without a system_noise variable in data the scale starts at the data minimum.

Parameters:

  • data (Dataset) –

    the dataset with the spectrogram variable and its spectrogram_time and spectrogram_baseband_frequency coordinates

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • noise_line (bool, default: True ) –

    True marks the system noise level on the colorbar, from system_noise (dBm/Hz) of data in the noise_bandwidth of the variable; nothing is marked without system_noise

spectrogram_histogram

spectrogram_histogram(
    data: Dataset,
    plotter: _PlotBackend,
    *,
    yscale: ScaleOptions = 'linear',
    noise_line: bool = True,
) -> Path | None

plot spectrogram_histogram of data against spectrogram_power_bin.

The x axis spans from 12 dB below the system noise level of each capture, or from the lowest bin without a system_noise variable in data, to 3 dB above the highest populated bin over the captures.

Parameters:

  • data (Dataset) –

    the dataset with the spectrogram_histogram variable and its spectrogram_power_bin coordinate

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • yscale (ScaleOptions, default: 'linear' ) –

    the y axis scale, 'linear' or 'log'

  • noise_line (bool, default: True ) –

    True marks the system noise level as a vertical line on each facet, from system_noise (dBm/Hz) of data in the noise_bandwidth of the power bins; nothing is marked without system_noise

Returns:

  • Path | None –

    the path of the figure file, or None when the backend writes no file

spectrogram_ratio_histogram

spectrogram_ratio_histogram(
    data: Dataset,
    plotter: _PlotBackend,
    *,
    yscale: ScaleOptions = 'linear',
) -> Path | None

plot spectrogram_ratio_histogram of data against the power-ratio bins.

The x axis spans from the lowest bin to 3 dB above the highest populated bin over the captures.

Parameters:

  • data (Dataset) –

    the dataset with the spectrogram_ratio_histogram variable and its spectrogram_ratio_power_bin coordinate

  • plotter (_PlotBackend) –

    the backend that draws the figure

  • yscale (ScaleOptions, default: 'linear' ) –

    the y axis scale, 'linear' or 'log'

Returns:

  • Path | None –

    the path of the figure file, or None when the backend writes no file

unstack_dataset

unstack_dataset(
    ds: Dataset,
    dim_coords: Sequence[str] = ('start_time', 'port'),
    *,
    chunks: int | Literal['auto'] | None = None,
) -> Dataset

return ds with the capture dimension unstacked into dim_coords.

When dim_coords includes 'sweep_start_time' or 'sweep_index', a coordinate that spans the other new dimensions is replaced by its values at index 0 of sweep_start_time.

Parameters:

  • ds (Dataset) –

    the sensor dataset to unstack

  • dim_coords (Sequence[str], default: ('start_time', 'port') ) –

    the coordinate names that become dimensions, under the constraint of index_coords in index_dataset

  • chunks (int | Literal['auto'] | None, default: None ) –

    a chunk size or 'auto' backs the result with dask arrays (xarray.Dataset.chunk), and None keeps the arrays of ds

Returns:

  • Dataset –

    the dataset with one dimension per entry of dim_coords in place of

  • Dataset –

    capture

Raises:

  • ValueError –

    if dim_coords do not select exactly one capture