Optical Table#

Classes#

OpticalTable#

class OpticalTable(**kwargs)[source]#

Bases: object

__init__(**kwargs)[source]#
add_components(component: OpticalComponent | List)[source]#
add_monitors(monitor: Monitor | List)[source]#
property bbox#
get_bbox()[source]#
ray_tracing(rays: Ray | List[Ray], perfomance_limit=None)[source]#

Perform ray tracing simulation.

Parameters:

rays – Ray or list of Ray objects.

render(ax=None, type: str = 'Z', roi=None, **kwargs)[source]#
calculate_abcd_matrix(mon0: Monitor, mon1: Monitor, rays: List[Ray], disp=1e-05, rot=1e-05, debugaxs=None) ndarray[source]#

Calculate the ABCD matrix between two monitors mon0 and mon1 (mon0 to mon1). default principal axis is “Y”. raysids are the ids of the rays used to calculate the matrix. If None, use all rays that intersect with mon0. The principal axis for each monitor is specified by pax0 and pax1, it can be either “Y” or “Z” or a custom vector lying on the plane of the monitor. delta is the small perturbation applied to calculate the matrix elements.

Returns:

A Nray x 2 x 2 numpy array representing the ABCD matrix for each ray.

static calibrate_symmetric_4f(lens: OpticalComponent | ComponentGroup, rays: List[Ray], F10: float, F20: float, criterion: str = 'M=-I', debugaxs=None, optimize=True, display_M=False)[source]#

Calibrate a symmetric 4f system formed by two lenses and two monitors. The distances are mon0 - F1 - lens - 2*F2 - lens(rotated 180) - F1 - mon1. The function will adjust the distances F1 and F2 to achieve the desired 4f imaging condition.

Parameters:
  • lens – OpticalComponent, the lens to be calibrated.

  • rays – List[Ray], the rays to be traced.

  • F10 – float, the initial distances.

  • F20 – float, the initial distances.

  • debugaxs – matplotlib axes, optional, for debugging visualization.

Returns:

calibrated distances.

Return type:

F1, F2

add_wavelength_legend(ax, wavelengths)[source]#

Adds a custom color legend to an existing ax for specified wavelengths. wavelengths: list of floats/ints in nm

gather_rays_csv()[source]#

Gather all rays in the optical table.

gather_components(avoid_flatten_classname: List = [], ignore_classname: List = []) List[dict][source]#

Gather all components in the optical table, avoiding flattening if specified.

export_rays_csv(filename: str)[source]#

Export rays to a file.

export_components_csv(filename: str, avoid_flatten_classname: List = [], ignore_classname: List = [])[source]#

Export components to a file. Including its class, origin and normal vector