rayoptics.raytr.wideangle module
Wide angle raytrace and ray aiming
This package was developed to ray trace fisheye, i.e. very wide field, lenses. These lenses have significant pupil spherical aberration. In order to trace highly oblique field angles, one must locate the actual entrance pupil location for a field angle. The function find_real_enp implements the search by parameterizing the z offset from the 1st interface along the object space optical axis. For extreme field angles, the rays that successfully reach the stop surface are far from the z offset for the paraxial entrance pupil.
The function z_enp_coordinate is used to evaluate where the chief ray hits the stop surface. This function is evaluated at regular intervals, spaced between the z distance of the paraxial entrance pupil and the first surface vertex (i. e. z_enp = 0). When the range of z values is identified that pass rays through the complete system, find_z_enp is called to find the exact conjugate point to the center of the stop surface.
The entrance pupil for the wide angle package is taken as normal to the chief ray at that field angle. The set_vignetting function using bisection works well with this definition.
- enp_z_coordinate(z_enp, *args)[source]
Trace a ray thru the center of the entrance pupil at z_enp.
- Parameters:
z_enp – The z distance from the 1st interface of the entrance pupil for the field angle dir0
seq_model – The sequential model
stop_idx – index of the aperture stop interface
dir0 – direction cosine vector in object space
obj_dist – object distance to first interface
wvl – wavelength of raytrace (nm)
- find_real_enp(opm, stop_idx, fld, wvl, vselector='rev1')[source]
Locate the z center of the real pupil for fld
- find_real_enp_rev1(opm, stop_idx, fld, wvl, check_direction=True)[source]
Locate the z center of the real pupil for fld, wrt 1st ifc
This function implements a 2 step process to finding the chief ray for fld and wvl for wide angle systems. fld should be of type (‘object’, ‘angle’), even for finite object distances.
The first phase searches for the window of pupil locations by sampling the z coordinate starting from the paraxial pupil location. The real pupil can move either inward or outward from the paraxial pupil location. As soon as 2 successful rays are traced, the search direction is updated if needed. The search continues until z_enp values are found giving rays that straddle the stop center. If no interval is found that contains the central ray, a finer sampled search is done to find the edges more accurately. If only a single successful trace is in hand, a second, more finely subdivided search is conducted around the successful point.
The outcome is a range, start_z -> end_z, an estimate of where the crossing point is (z_estimate), and a ray iteration (using
find_z_enp_on_interval()) to find the center of the stop surface.
- find_edge(f, a, b, *args, max_iter=3)[source]
use binary search to find the edge of the fct’s range.
- find_z_enp_on_interval(opt_model, stop_idx, start_z, end_z, z_estimate, fld, wvl, **kwargs)[source]
iterates a ray to [0, 0] on interface stop_ifc, returning aim info
This function finds the entrance pupil location, z_enp, inside a range of pupil locations. The rays in the interval must be trace without throwing TraceError exceptions (ignoring aperture clipping).
- Parameters:
opt_model – input OpticalModel
stop_idx – index of the aperture stop interface
start_z – lower bound of the z_enp interval to be searched
end_z – upper bound of the z_enp interval to be searched
z_estimate – estimate of pupil location. this estimate must support a raytrace up to stop_ifc
fld – field point
wvl – wavelength of raytrace (nm)
Returns z distance from 1st interface to the entrance pupil.
If stop_ifc is None, i.e. a floating stop surface, returns paraxial entrance pupil.
If the iteration fails, a TraceError will be raised
- find_real_enp_orig(opm, stop_idx, fld, wvl)[source]
Locate the z center of the real pupil for fld, wrt 1st ifc
This function implements a 2 step process to finding the chief ray for fld and wvl for wide angle systems. fld should be of type (‘object’, ‘angle’), even for finite object distances.
The first phase searches for the window of pupil locations by sampling the z coordinate from the paraxial pupil location towards the first interface vertex. Failed rays are discarded until a range of z coordinates is found where rays trace successfully. If the search forward is unsuccessful (i.e. winds up missing the 1st surface), the search is restarted moving away from the first interface. If only a single successful trace is in hand, a second, more finely subdivided search is conducted about the successful point.
The outcome is a range, start_z -> end_z, that is divided in 3 and a ray iteration (using
find_z_enp()) to find the center of the stop surface is done. Sometimes the start point doesn’t produce a solution; use of the mid-point as a start is a reliable second try.
- find_z_enp(opt_model, stop_idx, z_enp_0, fld, wvl, **kwargs)[source]
iterates a ray to [0, 0] on interface stop_ifc, returning aim info
- Parameters:
opt_model – input OpticalModel
stop_idx – index of the aperture stop interface
z_enp_0 – estimate of pupil location. this estimate must support a raytrace up to stop_ifc
fld – field point
wvl – wavelength of raytrace (nm)
Returns z distance from 1st interface to the entrance pupil.
If stop_ifc is None, i.e. a floating stop surface, returns paraxial entrance pupil.
If the iteration fails, a TraceError will be raised
- eval_real_image_ht(opt_model, fld, wvl)[source]
Trace reverse ray from image point to get object space inputs.
This function traces the chief ray for fld and wvl through the center of the stop surface, starting from the specified real image height.
This is the implementation of
obj_coords()for (‘image’, ‘real height’). It returns the starting ray in object space and the z entrance pupil distance wrt the first interface.