optiland.rays.ray_aiming.cached
Cached Ray Aiming Module
This module implements a caching wrapper for ray aiming algorithms. It stores previous results to speed up repetitive calculations, especially during optimization or tolerance analysis where system changes might be small.
Kramer Harrison, 2025
Classes
|
Cached ray aiming strategy. |
- class CachedRayAimer(optic: Optic, wrapped_aimer: BaseRayAimer, max_cache_size: int = 128, **kwargs: Any)[source]
Cached ray aiming strategy.
This class wraps another ray aimer and caches its results. It checks if the inputs and the optical system state have changed. If they match a cached entry, the result is returned immediately. If the system has changed but inputs match, the previous result is used as a starting guess.
- wrapped_aimer
The actual aiming strategy being cached.
- Type:
- max_cache_size
Maximum number of entries in the cache.
- Type:
int
- aim_rays(fields: tuple, wavelengths: Any, pupil_coords: tuple, initial_guess: tuple | None = None) tuple[source]
Calculate ray starting coordinates, using cache if available.
- Parameters:
fields (tuple) – Field coordinates.
wavelengths (Any) – Wavelengths.
pupil_coords (tuple) – Pupil coordinates.
initial_guess (tuple | None, optional) – Explicit starting guess.
- Returns:
Ray parameters (x, y, z, L, M, N).
- Return type:
tuple