rizer.misc.simulation.plt_simulation#

Plotting helpers for 2T0D constant-mass NRP simulation results.

This module provides SimulationPlotter, a class wrapping the figures produced from a post-processed SimulationData simulation output. Per-plot configuration (axis limits, annotations) is externalized to a YAML file consumed by SimulationPlotter._apply_axis_config and SimulationPlotter._apply_annotations.

Classes#

SimulationPlotter

Plot results of the 2T0D constant-mass NRP simulation.

Functions#

tick_func(→ str)

Format x-ticks as ns (or µs above 1000 ns).

split_states_by_radius_changes(...)

Split states into per-radius segments at known radius-change times.

Module Contents#

rizer.misc.simulation.plt_simulation.tick_func(x: float, pos: int) str#

Format x-ticks as ns (or µs above 1000 ns).

Parameters:
  • x (float) – The x-value to format.

  • pos (int) – The position of the tick on the x-axis. Not used in this function.

Returns:

The formatted x-tick.

Return type:

str

rizer.misc.simulation.plt_simulation.split_states_by_radius_changes(states: rizer.misc.simulation.post_process_io.SimulationData, radius_changes: list[tuple[float, float]]) list[rizer.misc.simulation.post_process_io.SimulationData]#

Split states into per-radius segments at known radius-change times.

Unlike detecting a change from a heuristic jump threshold on the recorded radius itself (fragile: it silently misses a real but small change, or misfires on numerical noise), this uses the exact change times from the simulation’s own input configuration – see rizer.misc.simulation.simulation.get_radius_change_events() – so the split always matches what the simulation actually did, however large or small each radius step is, and however many of them there are.

Parameters:
Returns:

len(radius_changes) + 1 contiguous, non-overlapping segments covering the whole of states, in order, split at the first recorded state at or after each change time.

Return type:

list of SimulationData

class rizer.misc.simulation.plt_simulation.SimulationPlotter(states: rizer.misc.simulation.post_process_io.SimulationData, segments: list[rizer.misc.simulation.post_process_io.SimulationData], change_times: list[float], figure_subfolder: str, annotations_yaml_path: str | pathlib.Path | None = None, experiment_ids: list[str] | None = None, run_id: str | None = None, save: bool = True, show: bool = True, validate_text_positions: bool = True)#

Plot results of the 2T0D constant-mass NRP simulation.

Each plotting method builds a figure and returns it together with its axes. Saving and displaying are controlled by the save and show flags set on the instance.

Parameters:
  • states (SimulationData) – Full simulation state array.

  • segments (list of SimulationData) – states split at each radius-change time – see split_states_by_radius_changes(). A single-element list means no radius change occurred.

  • change_times (list of float) – Time of each radius change, in s, in order (len(change_times) == len(segments) - 1). Empty if no radius change occurred.

  • figure_subfolder (str) – Sub-path under figures/ where SVGs are saved.

  • annotations_yaml_path (str or pathlib.Path or None, optional) – Path to a YAML file with per-plot configuration keyed by method name. Each top-level key may contain an axes mapping (axis name -> {xlim, ylim}) and/or an annotations list (each entry matching rizer.misc.plt_utils.get_annotation() parameters). If None, no auto-applied configuration is loaded. When save is True, a copy of this YAML is dropped next to the figures (<figures>/<figure_subfolder>/) on the first successful save, so the saved figures and the configuration that produced them stay paired.

  • experiment_ids (list of str, optional) – Experiment .npz ids (relative to data/experiments/, e.g. "T326/run24/electron_density.npz") to overlay wherever a plot method supports an experiment comparison. Empty by default – no experiment .npz is baked in unless explicitly requested, unlike the overlays this class drew before per-run experiment selection existed (see _matching_experiment_data).

  • run_id (str or None, optional) – This run’s opaque identifier (see rizer.spice.backend.models.results_schemas.RunInfo.id), used only by plot_electrical_signals_unified to look up its own entry in a time_offsets_ns dict keyed the same way experiment ids are. None (default) if the caller has no such identifier (e.g. a standalone archival script) – plot_electrical_signals_unified then applies no offset to this run’s own curves.

  • save (bool, optional) – If True, save each figure with save_current_figure. Default True.

  • show (bool, optional) – If True, call plt.show() after each figure. Default True.

  • validate_text_positions (bool, optional) – If True, just before saving/showing each figure, walk every axis and warn (via warnings) when a Text or Annotation artist sits outside the axis limits. Moveable positions (text and annotation xytext) are clamped just inside the limits; annotation xy arrow targets are flagged but never moved (clamping would silently re-anchor the arrow to a different data point). Default True.

states#
segments#
change_times#
figure_subfolder#
experiment_ids#
run_id = None#
save = True#
show = True#
validate_text_positions = True#
times_ns#
annotations_yaml_path#
plot_experimental_electrical_signal() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes, matplotlib.axes.Axes]#

Plot the experimental electrical signal (voltage and current).

plot_electric_generators_comparison() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]#

Plot the experimental signal vs the trapezoidal generator voltage.

plot_temperatures_electric_field_zoomed() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes, matplotlib.axes.Axes]#

Plot zoomed temperatures, electric field and voltages.

plot_generator_plasma_voltage_zoomed() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes, matplotlib.axes.Axes]#

Plot the generator voltage (zoomed) with a placeholder twin axis.

plot_temperatures_electric_field_full() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes, matplotlib.axes.Axes]#

Plot full-time-range temperatures and plasma voltage.

plot_voltage_current_energy_zoomed() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes, matplotlib.axes.Axes, matplotlib.axes.Axes]#

Plot zoomed plasma voltage, current and cumulated energy.

plot_voltage_current_energy_full() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes, matplotlib.axes.Axes, matplotlib.axes.Axes]#

Plot full-range plasma voltage, current and cumulated energy.

plot_plasma_resistance() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]#

Plot the plasma resistance versus the cable impedance.

plot_electron_density_vs_experiment() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]#

Plot the simulated electron density against experimental data.

plot_species_mole_fractions() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]#

Plot the species mole fractions and the residual ‘Others’ curve.

plot_pressure() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]#

Plot the pressure versus time.

plot_plasma_radius() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]#

Plot the simulated plasma radius against experimental diameters.

plot_density() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]#

Plot the gas density versus time.

plot_elastic_inelastic_power_ratio() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]#

Plot the inelastic-to-elastic power ratio with plasma-on shading.

plot_power_repartition() tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]#

Plot the power repartition curves (no save in original code).

plot_electrical_signals_unified(*, hidden_groups: tuple[str, Ellipsis] = (), time_offsets_ns: dict[str, float] | None = None) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes, matplotlib.axes.Axes, matplotlib.axes.Axes]#

Plot plasma, mid-cable, generator, and experimental electrical signals together.

Replaces plot_experimental_electrical_signal, plot_electric_generators_comparison, and plot_voltage_current_energy_full with one panel, so every electrical-signal curve overlays on the same 3 axes (voltage, current, energy) instead of being split across 3 disconnected plots.

Parameters:
  • hidden_groups (tuple of str, optional) – Curve-group ids (see rizer.misc.simulation.plot_registry.PlotKind.curve_groups) to skip drawing entirely. Default: draw every available group.

  • time_offsets_ns (dict of str to float or None, optional) – Per-source time offset, in nanoseconds, keyed by self.run_id for this run’s own curves (plasma_*, mid_cable_*, generator_voltage) or by experiment id for experimental_*. Added to the raw nanosecond time value before any display-unit conversion. None (default) applies no offset to anything.

Returns: