corset.plot#
Plotting functions for optical setups and mode matching solutions and analyses.
- class corset.plot.ModeMatchingPlot(ax, setup, desired_beam, ranges, apertures, passages, focuses, handles) None#
Plot of a mode matching solution with references to the plot elements.
- Parameters:
- desired_beam: OpticalSetupPlot#
Plot of the desired beam profile
- setup: OpticalSetupPlot#
Plot of the actual optical setup
- class corset.plot.OpticalSetupPlot(ax, zs, rs, beam, beam_ci, fit_data, lenses, handles, r_max) None#
Plot of an optical setup with references to the plot elements.
- Parameters:
ax (Axes)
zs (ndarray)
rs (ndarray)
beam (FillBetweenPolyCollection)
fit_data (PathCollection | None)
lenses (list[tuple[LineCollection, Annotation, Rectangle | None]])
r_max (float)
- beam: FillBetweenPolyCollection#
Fill between collection for the beam
- fit_data: PathCollection | None#
Scatter plot of the fit data points
- lenses: list[tuple[LineCollection, Annotation, Rectangle | None]]#
List of lens plot elements
- class corset.plot.ReachabilityPlot(ax, center, center_ci, lines, contour, colorbar) None#
Plot of a reachability analysis with references to the plot elements.
- Parameters:
- center: PathCollection#
Point representing the optimal focus and waist
- class corset.plot.SensitivityPlot(ax, displacements_ci, contours, colorbar, handles) None#
Plot of a sensitivity analysis with references to the plot elements.
- Parameters:
- corset.plot.get_handles(ax) list[tuple[Any, str]]#
Get a list of plot handles by their legend labels.
- corset.plot.plot_mode_match_solution_all(self, *, figsize=None, width_ratios=None, tight_layout=None, setup_kwargs=None, reachability_kwargs=None, sensitivity_kwargs=None) tuple[Figure, tuple[ModeMatchingPlot, ReachabilityPlot, SensitivityPlot]]#
Plot the mode matching solution setup, reachability analysis, and sensitivity analysis in a single figure.
- Parameters:
self (
ModeMatchingSolution) – The mode matching solution instance.figsize (
tuple[float,float] |None, default:None) – Figure size for the combined plot. IfNone, this defaults toConfig.PlotAll.figsize.width_ratios (
tuple[float,float,float] |None, default:None) – Width ratios for the three subplots. IfNone, this defaults toConfig.PlotAll.width_ratios.tight_layout (
bool|None, default:None) – Whether to use tight layout for the figure. IfNone, this defaults toConfig.PlotAll.tight_layout.setup_kwargs (
dict|None, default:None) – Additional keyword arguments for the setup plot. IfNone, this defaults toConfig.PlotAll.setup_kwargs.reachability_kwargs (
dict|None, default:None) – Additional keyword arguments for the reachability plot. IfNone, this defaults toConfig.PlotAll.reachability_kwargs.sensitivity_kwargs (
dict|None, default:None) – Additional keyword arguments for the sensitivity plot. IfNone, this defaults toConfig.PlotAll.sensitivity_kwargs.
- Return type:
tuple[Figure,tuple[ModeMatchingPlot,ReachabilityPlot,SensitivityPlot]]- Returns:
A tuple containing the figure and an inner tuple with the three plot objects.
- corset.plot.plot_mode_match_solution_setup(self, *, ax=None, setup_kwargs=None, desired_kwargs=None, show_legend=None, legend_loc=None, fraction_unit=None) ModeMatchingPlot#
Plot the mode matching solution setup including the desired beam and constraints.
- Parameters:
self (
ModeMatchingSolution) – The mode matching solution instance.ax (
Axes|None, default:None) – The axes to plot on. IfNone, the current axes are used.setup_kwargs (
dict|None, default:None) – Additional keyword arguments passed to the setup plot function. IfNone, this defaults toConfig.PlotSolution.setup_kwargs.desired_kwargs (
dict|None, default:None) – Additional keyword arguments passed to the desired beam plot function. IfNone, this defaults toConfig.PlotSolution.desired_kwargs.7show_legend (
bool|None, default:None) – Whether to show a legend for the plot. IfNone, this defaults toConfig.PlotSolution.show_legend.legend_loc (
str|None, default:None) – Location of the legend in the plot. IfNone, this defaults toConfig.PlotSolution.legend_loc.fraction_unit (
FractionUnit|None, default:None) – Unit for fractional quantities, i.e., the mode overlap and coupling coefficients. IfNone, this defaults toConfig.Units.fraction.
- Return type:
- Returns:
An
ModeMatchingPlotcontaining references to the plot elements.
- corset.plot.plot_reachability(self, *, ax=None, displacement=None, num_samples=None, line_step=None, dimensions=None, focus_range=None, waist_range=None, confidence_interval=None, grid_resolution=None, axial_unit=None, radial_unit=None, fraction_unit=None) ReachabilityPlot#
Plot a reachability analysis of the mode matching solution.
- Parameters:
self (
ModeMatchingSolution) – The mode matching solution instance.ax (
Axes|None, default:None) – The axes to plot on. IfNone, the current axes are used.displacement (
float|list[float] |None, default:None) – Maximum displacement from the optimal position(s) in meters. IfNone, this defaults toConfig.PlotReachability.displacement.num_samples (
int|list[int] |None, default:None) – Number of samples to take along each dimension. IfNone, this defaults toConfig.PlotReachability.num_samples.line_step (
int|list[int] |None, default:None) – Step size to skip certain lines for increased smoothness while retaining clarity. IfNone, this defaults toConfig.PlotReachability.line_step.dimensions (
list[int] |None, default:None) – Indices of the dimensions to analyze. IfNone, all dimensions are used.focus_range (
tuple[float,float] |None, default:None) – Range of focus values to display on the x-axis. IfNone, determined automatically.waist_range (
tuple[float,float] |None, default:None) – Range of waist values to display on the y-axis. IfNone, determined automatically.confidence_interval (
float|None, default:None) – Confidence ellipse probability for focus position and waist radius. IfNone, this defaults toConfig.PlotReachability.confidence_interval.grid_resolution (
int|None, default:None) – Resolution of the grid for the background mode overlap contour plot. IfNone, this defaults toConfig.Overlap.grid_resolution.axial_unit (
LengthUnit|None, default:None) – Unit to use for the axial quantities along the beam, i.e., the coordinate along the beam. IfNone, this defaults toConfig.Units.axial.radial_unit (
LengthUnit|None, default:None) – Unit to use for the radial across the beam, i.e., the beam radius. IfNone, this defaults toConfig.Units.radial.fraction_unit (
FractionUnit|None, default:None) – Unit for fractional quantities, i.e., the mode overlap and coupling coefficients. IfNone, this defaults toConfig.Units.fraction.
- Return type:
- Returns:
A
ReachabilityPlotcontaining references to the plot elements.
- corset.plot.plot_sensitivity(self, *, ax=None, dimensions=None, worst_overlap=None, x_displacement=None, y_displacement=None, z_displacement=None, num_samples_z=None, confidence_interval=None, force_contour_lines=None, grid_resolution=None, axial_unit=None, fraction_unit=None, sensitivity_unit=None) SensitivityPlot#
Plot a sensitivity analysis of the mode matching solution.
- Parameters:
self (
ModeMatchingSolution) – The mode matching solution instance.ax (
Axes|None, default:None) – The axes to plot on. IfNone, the current axes are used.dimensions (
tuple[int,int] |tuple[int,int,int] |None, default:None) – Indices of the dimensions to analyze. IfNone, the two least coupled dimensions are used as the x and y dimensions, and the remaining most sensitive dimension is used as the auxiliary z dimension if applicable.worst_overlap (
float|None, default:None) – Worst-case mode overlap contour line that should still be fully visible in the plot used for automatic range determination. IfNone, this defaults toConfig.PlotSensitivity.worst_overlap.x_displacement (
float|None, default:None) – Displacement magnitude for x-axis values. IfNone, determined automatically from worst_overlap.y_displacement (
float|None, default:None) – Displacement magnitude for y-axis values. IfNone, determined automatically from worst_overlap.z_displacement (
float|None, default:None) – Displacement magnitude for z-axis values. IfNone, determined automatically from worst_overlap.num_samples_z (
int|None, default:None) – Number of z-slices to plot if 3 dimensions are used. IfNone, this defaults toConfig.PlotSensitivity.num_samples_z.confidence_interval (
float|None, default:None) – Confidence ellipse probability in terms of the required x and y displacements. IfNone, this defaults toConfig.PlotSensitivity.confidence_interval.force_contour_lines (
bool|None, default:None) – IfTrue, always use contour lines instead of filled contours for plots with two degrees of freedom. IfNone, this defaults toConfig.PlotSensitivity.force_contour_lines.grid_resolution (
int|None, default:None) – Resolution of the grid for the contour plots. IfNone, this defaults toConfig.Overlap.grid_resolution.axial_unit (
LengthUnit|None, default:None) – Unit to use for the axial quantities along the beam, i.e., the coordinate along the beam. IfNone, this defaults toConfig.Units.axial.fraction_unit (
FractionUnit|None, default:None) – Unit for fractional quantities, i.e., the mode overlap and coupling coefficients. IfNone, this defaults toConfig.Units.fraction.sensitivity_unit (
SensitivityUnit|None, default:None) – Unit for sensitivity quantities, i.e., the overlap lost for a certain squared displacement. IfNone, this defaults toConfig.Units.sensitivity.
- Return type:
- Returns:
A
SensitivityPlotcontaining references to the plot elements.
- corset.plot.plot_setup(self, *, ax=None, points=None, limits=None, beam_kwargs=None, confidence_interval=None, show_fit_data=None, rayleigh_range_cap=None, free_lenses=[], show_legend=None, legend_loc=None, axial_unit=None, radial_unit=None) OpticalSetupPlot#
Plot the the beam profile and optical elements of the setup.
- Parameters:
self (
OpticalSetup) – The optical setup instance.ax (
Axes|None, default:None) – The axes to plot on. IfNone, the current axes are used.points (
int|ndarray|None, default:None) – Number of points or specific z-coordinates to evaluate the beam profile. IfNone, this defaults toConfig.PlotSetup.beam_points.limits (
tuple[float,float] |None, default:None) – Z-coordinate limits for the plot. IfNone, limits are determined from the beam and elements.beam_kwargs (
dict|None, default:None) – Additional keyword arguments passed to the beam plot. IfNonethis defaults toConfig.PlotSetup.beam_kwargs.confidence_interval (
float|bool|None, default:None) – Confidence interval probability for beam uncertainty visualization and labeling. IfFalse, no uncertainty is plotted or shown. IfNonethis defaults toConfig.PlotSetup.confidence_interval.show_fit_data (
bool|None, default:None) – Whether to show the fit data points. IfNone, this defaults toConfig.PlotSetup.show_fit_data.rayleigh_range_cap (
float|None, default:None) – Maximum Rayleigh range to consider when determining plot limits. IfNonethis defaults toConfig.PlotSetup.rayleigh_range_cap.free_lenses (
list[int], default:[]) – Indices of lenses to treat as free elements in the plot.show_legend (
bool|None, default:None) – Whether to show a legend for the plot. IfNone, this defaults toConfig.PlotSetup.show_legend.legend_loc (
str|None, default:None) – Location of the legend in the plot. IfNone, this defaults toConfig.PlotSetup.legend_loc.axial_unit (
LengthUnit|None, default:None) – Unit to use for the axial quantities along the beam, i.e., the coordinate along the beam. IfNone, this defaults toConfig.Units.axial.radial_unit (
LengthUnit|None, default:None) – Unit to use for the radial across the beam, i.e., the beam radius. IfNone, this defaults toConfig.Units.radial.
- Return type:
- Returns:
An
OpticalSetupPlotcontaining references to the plot elements.
- corset.plot.RELATIVE_MARGIN = 0.1#
Relative margin size for plotting optical setups