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#
Plot results of the 2T0D constant-mass NRP simulation. |
Functions#
|
Format x-ticks as ns (or µs above 1000 ns). |
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).
- 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:
states (
SimulationData) – Full simulation state array, as saved byrizer.misc.simulation.post_process_io.postprocess_and_save()and restored viarizer.misc.simulation.post_process_io.load_simulation_results().radius_changes (
listoftupleoffloat) –(time_of_change, new_radius)pairs, sorted by increasing time, as returned byrizer.misc.simulation.simulation.get_radius_change_events(). An empty list means the radius stayed constant for the whole run.
- Returns:
len(radius_changes) + 1contiguous, non-overlapping segments covering the whole of states, in order, split at the first recorded state at or after each change time.- Return type:
- 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
saveandshowflags set on the instance.- Parameters:
states (
SimulationData) – Full simulation state array.segments (
listofSimulationData) – states split at each radius-change time – seesplit_states_by_radius_changes(). A single-element list means no radius change occurred.change_times (
listoffloat) – 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 underfigures/where SVGs are saved.annotations_yaml_path (
strorpathlib.PathorNone, optional) – Path to a YAML file with per-plot configuration keyed by method name. Each top-level key may contain anaxesmapping (axis name ->{xlim, ylim}) and/or anannotationslist (each entry matchingrizer.misc.plt_utils.get_annotation()parameters). If None, no auto-applied configuration is loaded. Whensaveis 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 (
listofstr, 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 (
strorNone, 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 withsave_current_figure. Default True.show (
bool, optional) – If True, callplt.show()after each figure. Default True.validate_text_positions (
bool, optional) – If True, just before saving/showing each figure, walk every axis and warn (viawarnings) when aTextorAnnotationartist sits outside the axis limits. Moveable positions (text and annotationxytext) are clamped just inside the limits; annotationxyarrow 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 (
tupleofstr, 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 (
dictofstrtofloatorNone, 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:
fig (
matplotlib.figure.Figure)ax_v, ax_i, ax_e (
matplotlib.axes.Axes) – Voltage [kV], current [A], and cumulated energy [mJ] axes.