corset.config#

Configuration for analysis and plotting functions.

class corset.config.Config#

Configuration namespace for the mode matching solver.

class Overlap#

Configuration of default values for overlap contour plots.

classmethod colors() Sequence[tuple[float, float, float, float]]#

Get the colors corresponding to the overlap levels.

Return type:

Sequence[tuple[float, float, float, float]]

Returns:

A sequence of RGBA colors for each overlap level.

colormap: str = 'turbo'#

Colormap for overlap levels.

grid_resolution: int = 50#

Grid resolution for overlap contour plots.

levels: ClassVar[list[float]] = [80, 90, 95, 98, 99, 99.5, 99.8, 99.9, 100]#

Overlap levels in percent.

class PlotAll#

Configuration of default values for mode matching overview plots containing the setup, reachability, and sensitivity plots.

figsize: tuple[float, float] = (16, 4)#

Figure size for the overview plot.

reachability_kwargs: ClassVar[dict] = {}#

Keyword arguments to pass to the reachability plot.

sensitivity_kwargs: ClassVar[dict] = {}#

Keyword arguments to pass to the sensitivity plot.

setup_kwargs: ClassVar[dict] = {}#

Keyword arguments to pass to the setup plot.

tight_layout: bool = True#

Whether to use tight layout for the overview plot.

width_ratios: tuple[float, float, float] = (2, 1, 1)#

Width ratios for the three subplots in the overview plot.

class PlotReachability#

Configuration of default values for reachability plots.

confidence_interval: float | bool = 0.95#

Confidence ellipse for focus position and waist radius. If False, no confidence ellipse is shown.

displacement: float | list[float] = 0.005#

Displacement(s) to use for all or each dimension (if a list).

line_step: int | list[int] = 2#

Line step to use for all or each dimension (if a list), i.e. the step size to skip certain lines for increased smoothness while retaining clarity.

num_samples: int | list[int] = 7#

Number of samples to use for all or each dimension (if a list).

class PlotSensitivity#

Configuration of default values for sensitivity plots.

confidence_interval: float | bool = 0.95#

Confidence ellipse probability in terms of the required x and y displacements. If False, no confidence ellipse is shown.

force_contour_lines: bool = False#

Whether to always use contour lines instead of filled contours for plots with two degrees of freedom.

num_samples_z: int = 3#

Number of z-slices to plot if 3 dimensions are used.

worst_overlap: float = 0.98#

Approximate worst overlap that should still be fully contained in plot used for automatic plotting range determination.

class PlotSetup#

Configuration of default values for setup plots.

beam_kwargs: ClassVar[dict] = {'alpha': 0.5, 'color': 'C0'}#

The kwargs to pass to fill_between()

beam_points: int = 500#

Number of different \(z\) points to use when plotting beam propagation.

confidence_interval: float | bool = 0.95#

Confidence interval for the beam envelope. If False, no confidence interval is shown.

legend_loc: str = 'lower left'#

Location of the legend in the plot.

rayleigh_range_cap: float = 0.2#

During plotting, the interval of interest is automatically determined based on the Rayleigh range of the beam, for large Rayleigh ranges this can significantly inflate the plotted region, making the important features hard to see. This parameter limits this effect by capping the maximum Rayleigh range considered when determining the plotted interval.

show_legend: bool = False#

Whether to show a legend describing the plot aspects.

class PlotSolution#

Configuration of default values for mode matching solution plots.

desired_kwargs: ClassVar[dict] = {'color': 'C1', 'label': 'Desired Beam'}#

Keyword arguments for the desired beam plot.

legend_loc: str = 'lower left'#

Location of the legend in the plot.

setup_kwargs: ClassVar[dict] = {}#

Keyword arguments to pass to the setup plot.

show_legend: bool = False#

Whether to show a legend describing the plot aspects.

class SensitivityUnit(*values)#

Units for sensitivity analysis.

PERCENT_PER_CM2 = ('%/cm^2', '\\%/\\mathrm{cm}^2', 0.01)#
PERCENT_PER_MM2 = ('%/mm^2', '\\%/\\mathrm{mm}^2', 9.999999999999999e-05)#
PER_M2 = ('%/m^2', '\\%/\\mathrm{m}^2', 1)#
classmethod mpl_is_dark() bool#

Determine whether the current Matplotlib theme is dark by analyzing the figure background color.

Return type:

bool

Returns:

True if the current Matplotlib theme is dark, False otherwise.

static get(value, default) T#

Get a configuration value, using the default if the provided value is None.

Parameters:
  • value (TypeVar(T) | None) – The value to check.

  • default (TypeVar(T)) – The default value to use if value is None.

Return type:

TypeVar(T)

Returns:

The provided value or the default.

overwrite_dark_theme: bool | None = None#

Override automatic detection of dark theme in plots

sensitivity_unit = ('%/cm^2', '\\%/\\mathrm{cm}^2', 0.01)#

Unit for sensitivity analyses

class corset.config.Unit(ascii: str, tex: str, factor: float)#

Unit representation with ASCII and LaTeX strings and conversion factor to base unit.

Parameters:
count(value, /)#

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

ascii: str#

ASCII representation of the unit

factor: float#

Conversion factor to the SI base unit

tex: str#

LaTeX representation of the unit