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:
apertures: list[Line2D]#

List of aperture lines in the plot

ax: Axes#

Axes containing the plot

desired_beam: OpticalSetupPlot#

Plot of the desired beam profile

focuses: list[Line2D]#

List of focus diamonds in the plot

handles: list[tuple[Any, str]]#

List of plot handles by their legend labels

passages: list[Rectangle]#

List of passage rectangles in the plot

ranges: list[Rectangle]#

List of ranges in the plot

setup: OpticalSetupPlot#

Plot of the actual optical setup

class corset.plot.OpticalSetupPlot(ax, zs, rs, beam, beam_ci, lenses, handles, r_max) None#

Plot of an optical setup with references to the plot elements.

Parameters:
ax: Axes#

Axes containing the plot

beam: FillBetweenPolyCollection#

Fill between collection for the beam

beam_ci: list[Line2D]#

List of lines representing beam confidence intervals

handles: list[tuple[Any, str]]#

List of plot handles by their legend labels

lenses: list[tuple[LineCollection, Annotation, Rectangle | None]]#

List of lens plot elements

r_max: float#

Maximum beam radius in the plot

rs: ndarray#

Radii of the beam profile

zs: ndarray#

Z-coordinates of the beam profile

class corset.plot.ReachabilityPlot(ax, center, center_ci, lines, contour, colorbar) None#

Plot of a reachability analysis with references to the plot elements.

Parameters:
ax: Axes#

Axes containing the plot

center: PathCollection#

Point representing the optimal focus and waist

center_ci: Ellipse | None#

Uncertainty of the arriving beam around the optimal point

colorbar: Colorbar | None#

Colorbar for the contour plot

contour: Any#

Contour plot of the mode overlap

lines: list[list[Line2D]]#

Lines representing parameter variations

class corset.plot.SensitivityPlot(ax, displacements_ci, contours, colorbar, handles) None#

Plot of a sensitivity analysis with references to the plot elements.

Parameters:
ax: Axes#

Axes containing the plot

colorbar: Colorbar | None#

Colorbar for the contour plots

contours: list[Any]#

Contour plots of the sensitivity

displacements_ci: Ellipse | None#

Confidence ellipse in terms of required displacements

handles: list#

Handles for the plot elements

corset.plot.fig_to_png(fig) bytes#

Convert a Matplotlib figure to a PNG as bytes.

Parameters:

fig (Figure) – The figure to convert.

Return type:

bytes

Returns:

The PNG representation of the figure as bytes.

corset.plot.get_handles(ax) list[tuple[Any, str]]#

Get a list of plot handles by their legend labels.

Parameters:

ax (Axes) – The axes to get the handles from.

Return type:

list[tuple[Any, str]]

Returns:

A list of tuples containing legend handles and their corresponding labels, empty if no legend exists.

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:
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, *, setup_kwargs=None, desired_kwargs=None, ax=None, show_legend=None, legend_loc=None) ModeMatchingPlot#

Plot the mode matching solution setup including the desired beam and constraints.

Parameters:
Return type:

ModeMatchingPlot

Returns:

An ModeMatchingPlot containing references to the plot elements.

corset.plot.plot_reachability(self, *, displacement=None, num_samples=None, line_step=None, dimensions=None, focus_range=None, waist_range=None, confidence_interval=None, grid_resolution=None, ax=None) ReachabilityPlot#

Plot a reachability analysis of the mode matching solution.

Parameters:
Return type:

ReachabilityPlot

Returns:

A ReachabilityPlot containing references to the plot elements.

corset.plot.plot_sensitivity(self, *, 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, ax=None) SensitivityPlot#

Plot a sensitivity analysis of the mode matching solution.

Parameters:
  • self (ModeMatchingSolution) – The mode matching solution instance.

  • dimensions (tuple[int, int] | tuple[int, int, int] | None, default: None) – Indices of the dimensions to analyze. If None, 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. If None, this defaults to Config.PlotSensitivity.worst_overlap.

  • x_displacement (float | None, default: None) – Displacement magnitude for x-axis values. If None, determined automatically from worst_overlap.

  • y_displacement (float | None, default: None) – Displacement magnitude for y-axis values. If None, determined automatically from worst_overlap.

  • z_displacement (float | None, default: None) – Displacement magnitude for z-axis values. If None, determined automatically from worst_overlap.

  • num_samples_z (int | None, default: None) – Number of z-slices to plot if 3 dimensions are used. If None, this defaults to Config.PlotSensitivity.num_samples_z.

  • confidence_interval (float | None, default: None) – Confidence ellipse probability in terms of the required x and y displacements. If None, this defaults to Config.PlotSensitivity.confidence_interval.

  • force_contour_lines (bool | None, default: None) – If True, always use contour lines instead of filled contours for plots with two degrees of freedom. If None, this defaults to Config.PlotSensitivity.force_contour_lines.

  • grid_resolution (int | None, default: None) – Resolution of the grid for the contour plots. If None, this defaults to Config.Overlap.grid_resolution.

  • ax (Axes | None, default: None) – The axes to plot on. If None, the current axes are used.

Return type:

SensitivityPlot

Returns:

A SensitivityPlot containing references to the plot elements.

corset.plot.plot_setup(self, *, points=None, limits=None, beam_kwargs=None, confidence_interval=None, rayleigh_range_cap=None, free_lenses=[], ax=None, show_legend=None, legend_loc=None) OpticalSetupPlot#

Plot the the beam profile and optical elements of the setup.

Parameters:
Return type:

OpticalSetupPlot

Returns:

An OpticalSetupPlot containing references to the plot elements.

corset.plot.RELATIVE_MARGIN = 0.1#

Relative margin size for plotting optical setups

corset.plot.micro_formatter = <matplotlib.ticker.FuncFormatter object>#

Formatter for micrometer axes

corset.plot.milli_formatter = <matplotlib.ticker.FuncFormatter object>#

Formatter for millimeter axes