6.5. tracer.geometry Submodule¶
6.5.1. tracer.geometry.aperture¶
- class optrace.tracer.geometry.aperture.Aperture(surface, pos, **kwargs)¶
Create a Aperture object. Used for absorption of rays.
- Parameters:
6.5.2. tracer.geometry.detector¶
6.5.3. tracer.geometry.filter¶
- class optrace.tracer.geometry.filter.Filter(surface, pos, spectrum, **kwargs)¶
Create a Filter object. A filter is a surface with wavelength dependent or constant transmittance. Useful for color filters or apertures.
- Parameters:
Surface – Surface object
spectrum (TransmissionSpectrum) – transmission spectrum. Output range needs be inside [0, 1].
kwargs – additional keyword arguments for parent classes
surface (Surface)
- __call__(wl)¶
Return filter transmittance for specified wavelengths, pass-through of spectrum.__call__, see this method for details
- color(rendering_intent='Absolute', clip=True, L_th=0, chroma_scale=None)¶
Get Filter color under daylight (D65). pass-through of spectrum.color, see this method for details
6.5.4. tracer.geometry.group¶
- class optrace.tracer.geometry.group.Group(elements=None, n0=None, **kwargs)¶
Create a group by including elements from the ‘elements’ parameter. Without this parameter an empty group is created.
A Group contains multiple elements of types Lens, PointMarker, LineMarker, RaySource, Filter, Aperture, Detector. This class provides the functionality for moving, rotating and flipping its whole geometry. A well as including, removing elements and clearing is whole content.
- Parameters:
elements (list[Element]) – list of elements to add. Can be empty
n0 (RefractionIndex) – ambient refraction index
kwargs – additional keyword arguments for the BaseClass class
- add(el)¶
Add an element, list or group to the geometry.
- clear()¶
clear geometry, remove all objects from group
- Return type:
None
- flip(y0=0, z0=None)¶
Flip the group (= rotate by 180 deg) around an axis parallel to the x-axis and through the point (y0, z0). By default y0 = 0 and z0 is the center of the z-extent of the group.
This also sets and reassigns ambient and lens refraction indices.
- has(el)¶
checks if element is included in geometry. Don’t use this function with lists or Groups.
- move_to(pos)¶
Moves all elements such that pos is the new position of the first element. Relative distances between objects are mantained
- remove(el)¶
Remove the element specified by its id from raytracing geometry. Returns True if element(s) have been found and removes, False otherwise.
- rotate(angle, x0=0, y0=0)¶
Rotate the group around an axis at (x0, y0) with direction (0, 0, 1) The rotation angle is the angle in the xy-plane with counter-clockwise direction
- tma(wl=555.0)¶
Creates an ray transfer matrix analysis object from the group geometry. Note that this is a snapshot and does not get updated.
- apertures¶
apertures in raytracing geometry
- detectors¶
detectors in raytracing geometry
- property extent: tuple[float, float, float, float, float, float]¶
Extent of all elements. Equivalent to the smallest cuboid that encompasses all group objects inside.
- Returns:
tuple of the form (x0, x1, y0, y1, z0, z1)
- filters¶
filters in raytracing geometry
- lenses¶
lenses in raytracing geometry
- markers¶
markers in raytracing geometry
- n0¶
ambient refraction index
- ray_sources¶
ray sources in raytracing geometry
- property tracing_surfaces: list[Surface]¶
List of all tracing surfaces (lenses, apertures, filters). Sorted by center z-position.
- Returns:
sorted list of tracing surfaces
- volumes¶
volumes in raytracing geometry
6.5.5. tracer.geometry.ideal_lens¶
- class optrace.tracer.geometry.ideal_lens.IdealLens(r, D, pos, n2=None, **kwargs)¶
Create an ideal lens, that refracts light without aberrations to the correct image distance. An IdealLens has a disc geometry (CircularSurface) and zero thickness.
- Parameters:
r (float) – radial size of the lens
D (float) – optical power of the lens, this is the inverse of the geometrical focal length
n2 (RefractionIndex) – refraction index behind lens (positive z direction) (RefractionIndex object)
pos (list | ndarray) – 3D position of lens center (list or numpy array)
kwargs – additional keyword arguments for parent classes
6.5.6. tracer.geometry.lens¶
- class optrace.tracer.geometry.lens.Lens(front, back, n, pos, de=0, d=None, d1=None, d2=None, n2=None, **kwargs)¶
Creates a lens object using 2 surfaces and additional properties. Of the thickness parameters only one of d, de or (d1, d2) needs to be specified.
A lens is an geometrical object with two refractive surfaces. A refractive index is specified for the material and one for the area behind the lens (optional)
- Parameters:
front (Surface) – front surface (smaller z-position) (Surface object)
back (Surface) – back surface (higher z-position) (Surface object)
de (float) – thickness extension. additional thickness between maximum height of front and minimal height of back, (float)
d (float) – thickness at the optical axis / lens center
d1 (float) – thickness of front surface relative to surface center position (float)
d2 (float) – thickness of back surface relative to surface center position (float)
n (RefractionIndex) – material refraction index (RefractionIndex object)
n2 (RefractionIndex) – refraction index behind lens (positive z direction) (RefractionIndex object)
pos (list | ndarray) – 3D position of lens center (list or numpy array)
kwargs – additional keyword arguments for parent classes
- tma(wl=555.0, n0=None)¶
Matrix analysis object for the lens. Note that the lens does not know which medium n0 comes before it, if you want some value n0 != 1, you need to specify n0. The medium 2 after it is set by Lens.n2
- Parameters:
wl (float)
n0 (RefractionIndex)
- Returns:
transfer matrix analysis object
6.5.7. tracer.geometry.ray_source¶
- class optrace.tracer.geometry.ray_source.RaySource(surface, pos=None, divergence='None', div_angle=0.5, div_2d=False, div_axis_angle=0, div_func=None, div_args={}, spectrum=None, power=1.0, s=None, s_sph=None, orientation='Constant', conv_pos=None, or_func=None, or_args={}, polarization='Uniform', pol_angle=0.0, pol_angles=None, pol_probs=None, pol_func=None, pol_args={}, **kwargs)¶
Create a RaySource with a specific area, orientation, divergence, polarization, power and spectrum.
When a ‘surface’ is provided as Surface (RectangularSurface, RingSurface, Point, Line, CircularSurface), there will be uniform emittance over the surface and the spectrum can be set by the ‘spectrum’ parameter.
When ‘surface’ is provided as GrayscaleImage, the emittance follows the image intensity distribution, the spectrum can be set by the ‘spectrum’ parameter.
When ‘surface’ is provided as RGBImage, the spectrum and brightness for each pixel is generated from three primaries so it matches the pixel color.
- Parameters:
surface (Surface | Line | Point | GrayscaleImage | RGBImage) – emitting Surface, Point, Line, RGBImage or GrayscaleImage object
divergence (str) – divergence type, see “divergences” list
orientation (str) – orientation type, see “orientations” list
polarization (str) – polarization type, see “polarizations” list
spectrum (LightSpectrum) – LightSpectrum of the RaySource
power (float) – total power of the RaySource in W
div_angle (float) – cone opening angle in degrees
div_2d (bool) – if divergence is inside of a circular arc instead a cone
div_axis_angle (float) – axis angle for 2D divergence with div_2d=True
div_func (Callable[[ndarray], ndarray]) – divergence function, must take angles in radians in range [0, div_angle] and return a probability
div_args (dict) – additional keywords arguments for div_func in a dictionary
conv_pos (list[float] | ndarray) – convergence position for orientation=’Converging’, 3D position
pol_angle (float) – polarization angle as float, value in degrees
pol_angles (list[float]) – polarization angle list, values in degrees
pol_func (Callable[[ndarray], ndarray]) – polarization function, must take an numpy array in range [0, 2*pi] and return a probability
pol_args (dict) – dictionary of additional keyword arguments for pol_func
s_sph (list | ndarray) – 3D direction vector in spherical coordinates, specified as theta, phi, both in degrees
or_func (Callable[[ndarray, ndarray], ndarray]) – orientation function, takes 1D array of x and y coordinates as input, returns (N, 3) numpy 2D array with orientations
or_args (dict) – dictionary of additional keyword arguments for or_func
kwargs – additional keyword arguments for parent classes
- color(rendering_intent='Ignore', clip=False)¶
Get the average color of the RaySource
- create_rays(N, no_pol=False, power=None)¶
Generate N rays according to the property of the RaySource
- Parameters:
- Returns:
position array (numpy 2D array), direction array (numpy 2D array), polarization array (numpy 2D array) weight array (numpy 1D array), wavelength array (numpy 1D array) first dimension: ray number, second dimension: values
- Return type:
6.5.8. tracer.geometry.element¶
Parent class for Filter, Aperture, Lens, Detector, Volume, RaySource, Marker and Volume
A Element has a front and an optional back.
- Meaning of ‘front’ and ‘back’
Defined by the surface z-position
Element.front: Surface with smaller z-position
Element.back: Surface with larger z-position
- Properties with FrontSurface only:
Element.pos is Element.front.pos.
Element.extent is Element.front.extent.
Element.surface is an alias for Element.front
- Properties with FrontSurface + BackSurface:
d = (Element.d1 + Element.d2) is the whole z-difference between the centers of both surfaces
Element.d1 defines the z-distance between z-pos of the Element and the z-pos of Element.front
Element.d2 defines the z-distance between z-pos of the Element and the z-pos of Element.back
- Element.pos is (z-pos of front + d1) or (z-pos of back - d2),
which by above definitions are the same.
- Element.extent is the extent of both surfaces,
each value is determined by checking which surface has a larger extent in this dimension
- class optrace.tracer.geometry.element.Element(front, pos, back=None, d1=None, d2=None, **kwargs)¶
Parent class for Lens, RaySource, Detector, Aperture, Filter, PointMarker and LineMarker.
- Parameters:
- cylinder_surface(nc=100)¶
Get a 3D surface representation of the Element cylinder for plotting.
- flip()¶
flip the element around the x-axis, absolute position stays the same
- Return type:
None
- get_desc(fallback=None)¶
Get the description of the object.
- move_to(pos)¶
Moves the Element in 3D space.
- rotate(angle)¶
rotate the object around the z-axis :param angle: rotation angle in degrees
- Parameters:
angle (float)
- Return type:
None
- set_surface(surf)¶
Assign a new Surface to the Element.
- Parameters:
surf (Surface) – Surface to assign
- Return type:
None
- property surface¶
alias for Element.front
6.5.9. tracer.geometry.point¶
- class optrace.tracer.geometry.point.Point(**kwargs)¶
Create a Point object. This is just a position in 3D space
- Parameters:
kwargs – additional keyword arguments for parent classes
- flip()¶
flip the point around the x-axis
- Return type:
None
- move_to(pos)¶
Moves the surface in 3D space.
- random_positions(N)¶
Get random positions, for a point that is just the list of its position.
6.5.10. tracer.geometry.line¶
- class optrace.tracer.geometry.line.Line(r, angle=0, **kwargs)¶
Create a Line object. A Line lies in a plane perpendicular to the z-axis.
- Parameters:
- flip()¶
flip the line around the x-axis
- Return type:
None
- move_to(pos)¶
Move the line in 3D space.
- random_positions(N)¶
Get random 3D positions on the line, uniformly distributed
6.5.11. tracer.geometry.marker.point_marker¶
- class optrace.tracer.geometry.marker.point_marker.PointMarker(desc, pos, text_factor=1.0, marker_factor=1.0, label_only=False, **kwargs)¶
Create a new PointMarker.
A PointMarker is an Element, where the front surface is a point Markers are used as point and/or text annotations in the tracing geometry text only: provide a text string and set the parameter label_only=True marker/point only: leave the text empty
6.5.12. tracer.geometry.marker.line_marker¶
- class optrace.tracer.geometry.marker.line_marker.LineMarker(r, pos, desc='', angle=0, text_factor=1.0, line_factor=1.0, **kwargs)¶
Create a new LineMarker.
A LineMarker is an Element, where the front surface is a Line LineMarkers are used as line and text annotations in the tracing geometry
- Parameters:
6.5.13. tracer.geometry.volume.sphere_volume¶
- class optrace.tracer.geometry.volume.sphere_volume.SphereVolume(R, pos, color=None, opacity=0.3, **kwargs)¶
Create a sphere volume.
6.5.14. tracer.geometry.volume.box_volume¶
- class optrace.tracer.geometry.volume.box_volume.BoxVolume(dim, length, pos, color=None, opacity=0.3, **kwargs)¶
Create a box volume.
6.5.15. tracer.geometry.volume.cylinder_volume¶
- class optrace.tracer.geometry.volume.cylinder_volume.CylinderVolume(r, length, pos, color=None, opacity=0.3, **kwargs)¶
Create a cylinder volume.
6.5.16. tracer.geometry.volume.volume¶
- class optrace.tracer.geometry.volume.volume.Volume(front, back, pos, d1, d2, color=None, opacity=0.3, **kwargs)¶
Create a volume object with two surfaces and thickness. A volume object is an Element that displays some 3D object and does not interact with rays.
- Parameters:
front – front surface
back – back surface
pos – position
d1 – thickness between front and position
d2 – thickness between position and back
opacity (float) – plotting opacity, value range 0.0 - 1.0
kwargs – additional keyword args for class Element and BaseClass