aperture#
Aperture Package
Provides the system aperture type hierarchy for Optiland. Each aperture type encapsulates how to compute the entrance pupil diameter (EPD), whether the type supports telecentric object space, and whether its value scales with system scaling.
Public API#
BaseSystemAperture— abstract base classEPDAperture— entrance pupil diameterImageFNOAperture— image-space F-numberObjectNAAperture— object-space numerical apertureFloatByStopAperture— float by stop surface diametermake_system_aperture()— factory from legacy type string
Functions
|
Create a system aperture from a legacy type string and value. |
- class BaseSystemAperture[source]#
Abstract base class for system aperture type definitions.
Each concrete subclass encapsulates the logic for computing the entrance pupil diameter (EPD) for one aperture specification style (e.g. EPD, image-space F-number, object-space NA, or float-by-stop-size).
Subclasses must declare a class-level
ap_typestring (e.g."EPD") that matches the legacy type key used in serialized lens files. This string is used both for serialization round-trips and for the__init_subclass__auto-registration that powersfrom_dict().- Variables:
_registry (dict[str, type[BaseSystemAperture]]) – Class-level registry mapping
ap_typestrings to concrete subclass types. Populated automatically via__init_subclass__.
- abstractmethod compute_epd(paraxial: Paraxial, wavelength: float | None = None) float[source]#
Return the entrance pupil diameter using paraxial context.
- Parameters:
paraxial – The paraxial engine for the current optical system.
wavelength – Primary wavelength in micrometers. When
None, implementations may fall back toparaxial.optic.primary_wavelength.
- Returns:
Entrance pupil diameter in lens units.
- direct_fno() float | None[source]#
Return the F-number directly if this type stores it, else
None.Overridden only by
ImageFNOApertureto avoid a redundant EPD computation inFNO().- Returns:
F-number value, or
Noneif this type does not store one directly.
- classmethod from_dict(data: dict | None) BaseSystemAperture | None[source]#
Deserialize from a dictionary, dispatching by the
"type"field.- Parameters:
data – Dictionary produced by
to_dict(). PassingNonereturnsNone(mirrors legacyAperture.from_dictbehaviour).- Returns:
A concrete
BaseSystemApertureinstance, orNoneif data isNone.- Raises:
ValueError – If required keys are missing or the type is not registered.
- abstract property is_scalable: bool#
True if the stored value should be scaled during
optic.scale().
- abstractmethod scale(factor: float) BaseSystemAperture[source]#
Return a new aperture with the value scaled by factor.
Non-scalable types (where
is_scalableisFalse) returnselfunchanged since they are immutable and scaling has no effect.- Parameters:
factor – Multiplicative scale factor (e.g. 0.001 to convert mm to m).
- Returns:
A new
BaseSystemApertureinstance, orselffor non-scalable types.
- abstract property supports_telecentric: bool#
True if this aperture type is compatible with telecentric object space.
- class EPDAperture(value: float)[source]#
Aperture specified directly as an entrance pupil diameter.
The stored value is the entrance pupil diameter in lens units.
- Parameters:
value – Entrance pupil diameter.
- compute_epd(paraxial: Paraxial, wavelength: float | None = None) float[source]#
Return the stored EPD value directly.
- Parameters:
paraxial – Unused for this aperture type.
wavelength – Unused for this aperture type.
- Returns:
The entrance pupil diameter.
- direct_fno() float | None#
Return the F-number directly if this type stores it, else
None.Overridden only by
ImageFNOApertureto avoid a redundant EPD computation inFNO().- Returns:
F-number value, or
Noneif this type does not store one directly.
- classmethod from_dict(data: dict | None) BaseSystemAperture | None#
Deserialize from a dictionary, dispatching by the
"type"field.- Parameters:
data – Dictionary produced by
to_dict(). PassingNonereturnsNone(mirrors legacyAperture.from_dictbehaviour).- Returns:
A concrete
BaseSystemApertureinstance, orNoneif data isNone.- Raises:
ValueError – If required keys are missing or the type is not registered.
- scale(factor: float) EPDAperture[source]#
Return a new
EPDAperturewith value scaled by factor.- Parameters:
factor – Multiplicative scale factor.
- Returns:
A new EPDAperture instance.
- property supports_telecentric: bool#
True if this aperture type is compatible with telecentric object space.
- class FloatByStopAperture(value: float)[source]#
Aperture specified as the diameter of the stop surface.
The entrance pupil diameter is derived via paraxial ray tracing through the stop surface. For infinite-conjugate systems the marginal ray is traced forward; for finite-conjugate systems the object-space angle is scaled from the paraxial stop height.
- Parameters:
value – Stop surface diameter in lens units.
- compute_epd(paraxial: Paraxial, wavelength: float | None = None) float[source]#
Compute EPD by paraxial ray tracing through the stop surface.
- Parameters:
paraxial – Paraxial engine providing ray tracing and system access.
wavelength – Primary wavelength in micrometers. When
None, falls back toparaxial.optic.primary_wavelength.
- Returns:
Entrance pupil diameter.
- Raises:
ValueError – If the object surface is not defined.
- direct_fno() float | None#
Return the F-number directly if this type stores it, else
None.Overridden only by
ImageFNOApertureto avoid a redundant EPD computation inFNO().- Returns:
F-number value, or
Noneif this type does not store one directly.
- classmethod from_dict(data: dict | None) BaseSystemAperture | None#
Deserialize from a dictionary, dispatching by the
"type"field.- Parameters:
data – Dictionary produced by
to_dict(). PassingNonereturnsNone(mirrors legacyAperture.from_dictbehaviour).- Returns:
A concrete
BaseSystemApertureinstance, orNoneif data isNone.- Raises:
ValueError – If required keys are missing or the type is not registered.
- scale(factor: float) FloatByStopAperture[source]#
Return a new
FloatByStopAperturewith value scaled by factor.- Parameters:
factor – Multiplicative scale factor.
- Returns:
A new FloatByStopAperture instance.
- property supports_telecentric: bool#
True if this aperture type is compatible with telecentric object space.
- class ImageFNOAperture(value: float)[source]#
Aperture specified as an image-space F-number.
The entrance pupil diameter is derived as
EPD = f2 / FNO.- Parameters:
value – Image-space F-number.
- compute_epd(paraxial: Paraxial, wavelength: float | None = None) float[source]#
Compute EPD as
f2 / FNO.- Parameters:
paraxial – Paraxial engine used to obtain the back focal length.
wavelength – Unused for this aperture type.
- Returns:
Entrance pupil diameter.
- direct_fno() float[source]#
Return the stored F-number directly, bypassing EPD computation.
- Returns:
The image-space F-number.
- classmethod from_dict(data: dict | None) BaseSystemAperture | None#
Deserialize from a dictionary, dispatching by the
"type"field.- Parameters:
data – Dictionary produced by
to_dict(). PassingNonereturnsNone(mirrors legacyAperture.from_dictbehaviour).- Returns:
A concrete
BaseSystemApertureinstance, orNoneif data isNone.- Raises:
ValueError – If required keys are missing or the type is not registered.
- scale(factor: float) ImageFNOAperture[source]#
Return
self— F-number is dimensionless and does not scale.- Parameters:
factor – Ignored.
- Returns:
This same instance (immutable, so returning self is safe).
- property supports_telecentric: bool#
True if this aperture type is compatible with telecentric object space.
- class ObjectNAAperture(value: float)[source]#
Aperture specified as an object-space numerical aperture.
The entrance pupil diameter is derived from the object-space NA using the object distance, primary wavelength, and the refractive index of the medium at the object surface.
- Parameters:
value – Object-space numerical aperture (NA = n * sin(θ)).
- compute_epd(paraxial: Paraxial, wavelength: float | None = None) float[source]#
Compute EPD from object-space NA.
- Parameters:
paraxial – Paraxial engine providing access to system geometry and material data.
wavelength – Primary wavelength in micrometers. When
None, falls back toparaxial.optic.primary_wavelength.
- Returns:
Entrance pupil diameter.
- Raises:
ValueError – If the object surface is not defined.
- direct_fno() float | None#
Return the F-number directly if this type stores it, else
None.Overridden only by
ImageFNOApertureto avoid a redundant EPD computation inFNO().- Returns:
F-number value, or
Noneif this type does not store one directly.
- classmethod from_dict(data: dict | None) BaseSystemAperture | None#
Deserialize from a dictionary, dispatching by the
"type"field.- Parameters:
data – Dictionary produced by
to_dict(). PassingNonereturnsNone(mirrors legacyAperture.from_dictbehaviour).- Returns:
A concrete
BaseSystemApertureinstance, orNoneif data isNone.- Raises:
ValueError – If required keys are missing or the type is not registered.
- scale(factor: float) ObjectNAAperture[source]#
Return
self— NA is dimensionless and does not scale.- Parameters:
factor – Ignored.
- Returns:
This same instance (immutable, so returning self is safe).
- property supports_telecentric: bool#
True if this aperture type is compatible with telecentric object space.
- make_system_aperture(aperture_type: str, value: float) BaseSystemAperture[source]#
Create a system aperture from a legacy type string and value.
This is the preferred factory for constructing aperture objects when using the string-based API (e.g. via
set_aperture()).- Parameters:
aperture_type – One of
'EPD','imageFNO','objectNA','float_by_stop_size'.value – The aperture value in lens units (or dimensionless for FNO/NA).
- Returns:
A concrete
BaseSystemApertureinstance.- Raises:
ValueError – If aperture_type is not a registered type.