plotting#
Plotting utilities for Paroto visualization.
This module provides functions for visualizing generator operating windows, parameter spaces, and other system characteristics.
Functions#
|
Plot the high-voltage generator operating window. |
|
Add design points to an operating window plot. |
|
Visualize constraint boundary exploration results. |
Module Contents#
- plotting.plot_operating_window(ax, Z=50.0, t_pulse=2e-08, P_max=1000.0, f_range=None, V_range=None, show_annotations=True)#
Plot the high-voltage generator operating window.
The operating window defines the feasible region in (frequency, voltage) space where the generator can operate safely. The constraint is:
\[\begin{split}P_{window} = \\frac{f \\cdot V^2 \\cdot t_{pulse}}{Z} \\leq P_{max}\end{split}\]The boundary curve is given by:
\[\begin{split}V = \\sqrt{\\frac{P_{max} \\cdot Z}{f \\cdot t_{pulse}}}\end{split}\]- Parameters:
ax (
matplotlib.axes.Axes) – Matplotlib axes object to plot onZ (
float, optional) – Design output impedance of generator (Ohm), default=50.0t_pulse (
float, optional) – Pulse duration (s), default=20e-9 (20 ns)P_max (
float, optional) – Maximum power in operating window (W), default=1000.0f_range (
tupleoffloat, optional) – (f_min, f_max) frequency range in Hz. If None, uses (1000, 300000)V_range (
tupleoffloat, optional) – (V_min, V_max) voltage range in V. If None, auto-computed from boundaryshow_annotations (
bool, optional) – If True, add text annotations with parameter values, default=True
- Returns:
f_boundary (
np.ndarray) – Frequency values along the boundary (Hz)V_boundary (
np.ndarray) – Voltage values along the boundary (V)
Examples
>>> import matplotlib.pyplot as plt >>> from paroto.utils.plotting import plot_operating_window >>> fig, ax = plt.subplots() >>> f_bound, V_bound = plot_operating_window(ax) >>> ax.set_xlabel("Frequency (Hz)") >>> ax.set_ylabel("HV Voltage (V)") >>> plt.show()
- plotting.add_design_points_to_operating_window(ax, frequencies, voltages, constraint_values, label_prefix='Design')#
Add design points to an operating window plot.
Points are colored by whether they satisfy the operating window constraint.
- Parameters:
ax (
matplotlib.axes.Axes) – Matplotlib axes object (should already have operating window plotted)frequencies (
array_like) – Frequency values in Hzvoltages (
array_like) – HV voltage values in Vconstraint_values (
array_like) – Operating window constraint satisfaction values (≥1 is feasible)label_prefix (
str, optional) – Prefix for legend labels, default=’Design’
- Returns:
scatter_feasible (
matplotlib.collections.PathCollection) – Scatter plot object for feasible pointsscatter_infeasible (
matplotlib.collections.PathCollection) – Scatter plot object for infeasible points (or None if all feasible)
Examples
>>> import matplotlib.pyplot as plt >>> import numpy as np >>> from paroto.utils.plotting import ( ... plot_operating_window, ... add_design_points_to_operating_window, ... ) >>> fig, ax = plt.subplots() >>> plot_operating_window(ax) >>> f_points = np.array([50000, 100000, 150000]) >>> V_points = np.array([15000, 20000, 25000]) >>> constraints = np.array([1.2, 0.8, 1.5]) # Middle point violates constraint >>> add_design_points_to_operating_window(ax, f_points, V_points, constraints) >>> plt.show()
- plotting.plot_constraint_boundary(ax, boundary_data, param1_name=None, param2_name=None, show_grid_points=True, show_refinement_regions=False, shade_regions=True, boundary_color='red', boundary_width=2, show_colorbar=False)#
Visualize constraint boundary exploration results.
Plots the results from constraint boundary exploration, showing evaluated grid points, the constraint boundary, and feasible/infeasible regions.
- Parameters:
ax (
matplotlib.axes.Axes) – Matplotlib axes object to plot onboundary_data (
dict) – Dictionary returned from explore_constraint_boundary_2d() containing: - ‘param1_values’: Array of param1 evaluation points - ‘param2_values’: Array of param2 evaluation points - ‘constraint_values’: Array of constraint values - ‘feasible_mask’: Boolean array (True where feasible) - ‘boundary_points’: List of (param1, param2) tuples near boundary - Other metadata fieldsparam1_name (
str, optional) – Name for x-axis (parameter 1). If None, uses boundary_data[‘param1_name’]param2_name (
str, optional) – Name for y-axis (parameter 2). If None, uses boundary_data[‘param2_name’]show_grid_points (
bool, optional) – If True, plot evaluated grid points, default=Trueshow_refinement_regions (
bool, optional) – If True, highlight adaptively refined regions, default=Falseshade_regions (
bool, optional) – If True, shade feasible/infeasible regions, default=Trueboundary_color (
str, optional) – Color for boundary curve, default=’red’boundary_width (
float, optional) – Line width for boundary curve, default=2show_colorbar (
bool, optional) – If True, add colorbar showing constraint values, default=False
- Return type:
Examples
>>> import matplotlib.pyplot as plt >>> from paroto.utils.constraint_explorer import explore_constraint_boundary_2d >>> from paroto.utils.plotting import plot_constraint_boundary >>> # ... setup prob ... >>> result = explore_constraint_boundary_2d(prob, "param1", "param2", "constraint") >>> fig, ax = plt.subplots() >>> plot_constraint_boundary(ax, result) >>> plt.show()