plotting ======== .. py:module:: plotting .. autoapi-nested-parse:: Plotting utilities for Paroto visualization. This module provides functions for visualizing generator operating windows, parameter spaces, and other system characteristics. Functions --------- .. autoapisummary:: plotting.plot_operating_window plotting.add_design_points_to_operating_window plotting.plot_constraint_boundary Module Contents --------------- .. py:function:: 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: .. math:: P_{window} = \\frac{f \\cdot V^2 \\cdot t_{pulse}}{Z} \\leq P_{max} The boundary curve is given by: .. math:: V = \\sqrt{\\frac{P_{max} \\cdot Z}{f \\cdot t_{pulse}}} :param ax: Matplotlib axes object to plot on :type ax: :py:class:`matplotlib.axes.Axes` :param Z: Design output impedance of generator (Ohm), default=50.0 :type Z: :py:class:`float`, *optional* :param t_pulse: Pulse duration (s), default=20e-9 (20 ns) :type t_pulse: :py:class:`float`, *optional* :param P_max: Maximum power in operating window (W), default=1000.0 :type P_max: :py:class:`float`, *optional* :param f_range: (f_min, f_max) frequency range in Hz. If None, uses (1000, 300000) :type f_range: :py:class:`tuple` of :py:class:`float`, *optional* :param V_range: (V_min, V_max) voltage range in V. If None, auto-computed from boundary :type V_range: :py:class:`tuple` of :py:class:`float`, *optional* :param show_annotations: If True, add text annotations with parameter values, default=True :type show_annotations: :py:class:`bool`, *optional* :returns: * **f_boundary** (:py:class:`np.ndarray`) -- Frequency values along the boundary (Hz) * **V_boundary** (:py:class:`np.ndarray`) -- Voltage values along the boundary (V) .. rubric:: 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() .. py:function:: 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. :param ax: Matplotlib axes object (should already have operating window plotted) :type ax: :py:class:`matplotlib.axes.Axes` :param frequencies: Frequency values in Hz :type frequencies: :py:class:`array_like` :param voltages: HV voltage values in V :type voltages: :py:class:`array_like` :param constraint_values: Operating window constraint satisfaction values (≥1 is feasible) :type constraint_values: :py:class:`array_like` :param label_prefix: Prefix for legend labels, default='Design' :type label_prefix: :py:class:`str`, *optional* :returns: * **scatter_feasible** (:py:class:`matplotlib.collections.PathCollection`) -- Scatter plot object for feasible points * **scatter_infeasible** (:py:class:`matplotlib.collections.PathCollection`) -- Scatter plot object for infeasible points (or None if all feasible) .. rubric:: 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() .. py:function:: 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. :param ax: Matplotlib axes object to plot on :type ax: :py:class:`matplotlib.axes.Axes` :param boundary_data: 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 fields :type boundary_data: :py:class:`dict` :param param1_name: Name for x-axis (parameter 1). If None, uses boundary_data['param1_name'] :type param1_name: :py:class:`str`, *optional* :param param2_name: Name for y-axis (parameter 2). If None, uses boundary_data['param2_name'] :type param2_name: :py:class:`str`, *optional* :param show_grid_points: If True, plot evaluated grid points, default=True :type show_grid_points: :py:class:`bool`, *optional* :param show_refinement_regions: If True, highlight adaptively refined regions, default=False :type show_refinement_regions: :py:class:`bool`, *optional* :param shade_regions: If True, shade feasible/infeasible regions, default=True :type shade_regions: :py:class:`bool`, *optional* :param boundary_color: Color for boundary curve, default='red' :type boundary_color: :py:class:`str`, *optional* :param boundary_width: Line width for boundary curve, default=2 :type boundary_width: :py:class:`float`, *optional* :param show_colorbar: If True, add colorbar showing constraint values, default=False :type show_colorbar: :py:class:`bool`, *optional* :rtype: :py:obj:`None` .. rubric:: 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()