visisipy.backend#
Backends for optical simulations.
This module provides a unified interface for different optical simulation backends, as well as functions to interact with these backends.
Interfaces:
BaseAnalysisRegistry: Base class for the backend analysis registry.
BaseBackend: Base class for simulation backends.
Functions:
set_backend: Set the backend to use for optical simulations.
get_backend: Get the current backend, or initialize the default backend if not set.
get_oss: Get the OpticStudioSystem instance if the current backend is OpticStudio.
get_optic: Get the Optic instance if the current backend is Optiland.
update_settings: Update settings on the current backend.
See Also#
visispy.opticstudio.backend : Backend for OpticStudio. visispy.optiland.backend : Backend for Optiland.
Classes#
A dictionary containing the settings for the backend. |
|
Base class for optical simulation backends. |
|
Available backends for optical simulations. |
Functions#
|
Set the backend to use for optical simulations. |
|
Get the current backend. |
|
Get the OpticStudioSystem instance from the current backend. |
|
Get the Optic instance from the current backend. |
|
Update settings on the current backend. |
Module Contents#
- class visisipy.backend.BackendSettings#
Bases:
visisipy.types.TypedDictA dictionary containing the settings for the backend.
- field_type: visisipy.types.FieldType#
The field type to use in the optical system. Must be one of ‘angle’ or ‘object_height’.
- fields: collections.abc.Sequence[visisipy.types.FieldCoordinate]#
List of field coordinates to use in the optical system.
- wavelengths: collections.abc.Sequence[float]#
List of wavelengths to use in the optical system.
- aperture_type: visisipy.types.ApertureType#
The aperture type to use in the optical system. Must be one of ‘float_by_stop_size’, ‘entrance_pupil_diameter’, ‘image_f_number’, or ‘object_numeric_aperture’.
- aperture_value: visisipy.types.NotRequired[float]#
The aperture value to use in the optical system. Not required for ‘float_by_stop_size’.
- class visisipy.backend.BaseBackend#
Bases:
abc.ABCBase class for optical simulation backends.
Backends should implement this interface to provide a unified interface for optical simulations.
- classmethod get_setting(name: str) Any#
Get a value from the backend settings.
This method is mainly intended for internal use, to prevent the type checker from warning about potentially missing keys in the settings dictionary.
Parameters#
- namestr
The name of the setting to get.
Returns#
- Any
The value of the setting.
Raises#
- KeyError
If the setting does not exist.
- class visisipy.backend.Backend#
Bases:
str,enum.EnumAvailable backends for optical simulations.
- visisipy.backend.set_backend(backend: Backend | Literal['opticstudio', 'optiland'] = Backend.OPTICSTUDIO, **settings: visisipy.types.Unpack[BackendSettings]) None#
Set the backend to use for optical simulations.
Parameters#
- backendBackend | str
The backend to use. Must be one of the values in the Backend enum. Defaults to Backend.OPTICSTUDIO.
- settingsBackendSettings, optional
Dictionary with settings for the backend. Defaults to None.
Raises#
- ValueError
If an invalid backend is specified.
- visisipy.backend.get_backend() type[BaseBackend]#
Get the current backend.
The backend is set to the default backend if it has not been set yet.
Returns#
- BaseBackend
The current backend.
- visisipy.backend.get_oss() zospy.zpcore.OpticStudioSystem | None#
Get the OpticStudioSystem instance from the current backend.
Returns#
- OpticStudioSystem | None
The OpticStudioSystem instance if the current backend is the OpticStudio backend, otherwise None.
- visisipy.backend.get_optic() optiland.optic.Optic | None#
Get the Optic instance from the current backend.
Returns#
- Optic
The Optic instance if the current backend is the Optiland backend, otherwise None.
- visisipy.backend.update_settings(backend: type[BaseBackend] | None = None, **settings: visisipy.types.Unpack[BackendSettings])#
Update settings on the current backend.
Optionally, the backend can be manually specified. By default, the current backend is used.
Parameters#
- backendtype[BaseBackend] | None
The backend to update. If None, the current backend is used.
- **settingsUnpack[BackendSettings]
The settings to update. The keys and values should match the backend’s configuration schema.
Raises#
- ValueError
If the settings are not valid for the current backend.