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_correlationvariable and itscellular_cell_id2,cellular_ssb_start_time,cellular_ssb_beam_index, andcellular_ssb_lagcoordinates -
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 overcellular_cell_id2;'cellular_cell_id2'draws one line per cell sector ID, averaged overcellular_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
Nonewhen the backend writes no file
Raises:
-
KeyError–if
hueis 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_spectrogramvariable and itscellular_ssb_index,cellular_ssb_symbol_index, andcellular_ssb_baseband_frequencycoordinates -
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) ofdatain thenoise_bandwidthof the variable; nothing is marked withoutsystem_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_autocorrelationvariable and itslink_direction,subcarrier_spacing, andcyclic_sample_lagcoordinates -
plotter(_PlotBackend) –the backend that draws the figure
-
hue(str, default:'link_direction') –'link_direction'draws one line per link direction at thesubcarrier_spacingwith 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
Nonewhen the backend writes no file
Raises:
-
TypeError–if
hueis 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_histogramvariable and itslink_directionandcellular_resource_power_bincoordinates -
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) ofdatain thenoise_bandwidthof the power bins; nothing is marked withoutsystem_noise -
yscale(ScaleOptions, default:'linear') –the y axis scale,
'linear'or'log'
Returns:
-
Path | None–the path of the figure file, or
Nonewhen 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_histogramvariable and itspower_detectorandchannel_power_bincoordinates -
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) ofdatain thenoise_bandwidthof the power bins; nothing is marked withoutsystem_noise -
yscale(ScaleOptions, default:'linear') –the y axis scale,
'linear'or'log'
Returns:
-
Path | None–the path of the figure file, or
Nonewhen 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_seriesvariable and itspower_detectorandtime_elapsedcoordinates -
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) ofdatain thenoise_bandwidthof the variable; nothing is marked withoutsystem_noise
Returns:
-
Path | None–the path of the figure file, or
Nonewhen 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_powervariable -
plotter(_PlotBackend) –the backend that draws the figure
-
center_statistic(str | float, default:'mean') –the
cyclic_statisticvalue drawn as the line -
bound_statistics(tuple[str | float, str | float], default:('min', 'max')) –the
cyclic_statisticvalues 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_lagsample -
noise_line(bool, default:True) –True marks the system noise level on each facet
Returns:
-
Path | None–the path of the figure file, or
Nonewhen the backend writes no file
Raises:
-
ValueError–if
center_statisticor either ofbound_statisticsis not acyclic_statisticvalue ofdata
data_var_plotters
¶
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 ofds
Returns:
-
Dataset–the data and coordinates of
dswith the multi-index set
Raises:
-
ValueError–if
index_coordsdo 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_datathat 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 aunitsattr of 1 or 2 characters -
short(bool, default:True) –True labels with
standard_name; False labels withlong_namewhen 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
figwhenfigis given -
fig(Optional[Figure], default:None) –when given with
axNone, an x or y label is set once as a figure super-label and the per-axes labels are hidden
Raises:
-
ValueError–if
which_axisis 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.formattemplate; 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
datathat supplies the attrs and values, or None fordataitself -
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.Legendadded toax
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_densityvariable and itstime_statisticandbaseband_frequencycoordinates; the variable and the statistic coordinate are also read under the namespersistence_spectrumandpersistence_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) ofdatain thenoise_bandwidthof the variable; nothing is marked withoutsystem_noise
Returns:
-
Path | None–the path of the figure file, or
Nonewhen the backend writes no file
spectrogram
¶
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
spectrogramvariable and itsspectrogram_timeandspectrogram_baseband_frequencycoordinates -
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) ofdatain thenoise_bandwidthof the variable; nothing is marked withoutsystem_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_histogramvariable and itsspectrogram_power_bincoordinate -
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) ofdatain thenoise_bandwidthof the power bins; nothing is marked withoutsystem_noise
Returns:
-
Path | None–the path of the figure file, or
Nonewhen 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_histogramvariable and itsspectrogram_ratio_power_bincoordinate -
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
Nonewhen 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_coordsinindex_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 ofds
Returns:
-
Dataset–the dataset with one dimension per entry of
dim_coordsin place of -
Dataset–capture
Raises:
-
ValueError–if
dim_coordsdo not select exactly one capture