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().- _registry
Class-level registry mapping
ap_typestrings to concrete subclass types. Populated automatically via__init_subclass__.- Type:
dict[str, type[BaseSystemAperture]]
- abstract property ap_type: str
String identifier matching the legacy type key (e.g.
'EPD').
- abstract 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().
- abstract 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.
- abstract to_dict() dict[source]
Serialize to a JSON-compatible dictionary.
- Returns:
A dict with at least
"type"and"value"keys.
- abstract property value: float
Raw aperture value as supplied by the user.
- 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.
- property ap_type: str
String identifier matching the legacy type key (e.g.
'EPD').
- 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.
- property is_scalable: bool
True if the stored value should be scaled during
optic.scale().
- 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.
- to_dict() dict[source]
Serialize to a JSON-compatible dictionary.
- Returns:
A dict with at least
"type"and"value"keys.
- property value: float
Raw aperture value as supplied by the user.
- 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.
- property ap_type: str
String identifier matching the legacy type key (e.g.
'EPD').
- 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.
- property is_scalable: bool
True if the stored value should be scaled during
optic.scale().
- 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.
- to_dict() dict[source]
Serialize to a JSON-compatible dictionary.
- Returns:
A dict with at least
"type"and"value"keys.
- property value: float
Raw aperture value as supplied by the user.
- 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.
- property ap_type: str
String identifier matching the legacy type key (e.g.
'EPD').
- 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.
- property is_scalable: bool
True if the stored value should be scaled during
optic.scale().
- 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.
- to_dict() dict[source]
Serialize to a JSON-compatible dictionary.
- Returns:
A dict with at least
"type"and"value"keys.
- property value: float
Raw aperture value as supplied by the user.
- 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(θ)).
- property ap_type: str
String identifier matching the legacy type key (e.g.
'EPD').
- 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.
- property is_scalable: bool
True if the stored value should be scaled during
optic.scale().
- 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.
- to_dict() dict[source]
Serialize to a JSON-compatible dictionary.
- Returns:
A dict with at least
"type"and"value"keys.
- property value: float
Raw aperture value as supplied by the user.
- 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.