corset.config#

Configuration for analysis and plotting functions.

class corset.config.Config#

Configuration namespace for Beam Corset.

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]] = [0.8, 0.9, 0.95, 0.98, 0.99, 0.995, 0.998, 0.999, 1.0]#

Overlap levels as fractions.

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] = {'setup_kwargs': {'show_fit_data': False}}#

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_fit_data: bool = True#

Whether to plot the data points that were used to fit the beam(s).

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 Repr#

Configuration IPython display representations.

classmethod set_minimal()#

Set the table columns to a minimal set.

Equivalent to:

Config.Repr.solution_element_summary_columns = ["element", "shape", "position", "clearance_left", "clearance_right", "sensitivity"]
Config.Repr.solution_summary_columns = ["overlap", "num_elements", "elements", "max_sensitivity", "min_coupling"]
Config.Repr.lens_list_columns = ["name", "shape", "focal_length", "left_margin", "right_margin"]
lens_list_columns: list[str] | None = None#

Subset of columns to show in the lens list representation table. If None, all columns are shown.

solution_element_summary: Literal['show', 'hide', 'expanded', 'collapsed'] = 'collapsed'#

Whether to show the element summary table in the solution representation. Options are: - "show": Show the table. - "hide": Do not show the table. - "expanded": Show the table in an expanded details view. - "collapsed": Show the table in a collapsed details view.

solution_element_summary_columns: list[str] | None = None#

Subset of columns to show in the solution element summary table. If None, all columns are shown.

solution_summary_columns: list[str] | None = None#

Subset of columns to show in the solution summary table. If None, all columns are shown.

class Units#

Configuration of default units for displaying values in plots and tables.

axial: LengthUnit = LengthUnit(unicode='mm', tex='\\mathrm{mm}', factor=0.001, decimals=0)#

Unit for axial length unit display

fraction: FractionUnit = FractionUnit(unicode='%', tex='\\%', factor=0.01, decimals=1)#

Unit for overlap display

radial: LengthUnit = LengthUnit(unicode='μm', tex='\\mathrm{\\mu m}', factor=1e-06, decimals=0)#

Unit for radial length unit display

sensitivity: SensitivityUnit = SensitivityUnit(unicode='%/cm²', tex='\\%/\\mathrm{cm}^2', factor=100.0, decimals=2)#

Unit for sensitivity analysis display

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