The ray_bundle module

class tracer.ray_bundle.RayBundle(vertices=None, directions=None, energy=None, parents=None, ref_index=None, **kwds)

Contains information about a ray bundle, using equal-length arrays, the length of which correspond to the number of rays in a bundle. Each array represents one trait of the ray. Of those, at least the vertices and directions should be set; for most of the optics managers (see tracer.optics_callables) that come with Tracer, the energy should also be set, and for the refractive ones, the current refractive index of the volume in which the ray is traveling.

The ray bundle also has a concept of its parent rays - an array where for each ray, an index into another bundle of rays is stored. This is used by optics managers and the tracer engine to keep track of progression of the source rays through reflections and refractions.

For examples on how to create ray bundles, see examples/, tracer.sources, and most of the test-suite.

Initialize the ray bundle as empty or using the given arrays. Let n be the number of rays, then for each of the arguments, .shape[-1] == n.

Arguments

  • vertices: each column is the (x,y,z) coordinets of a ray’s vertex.
  • directions: each column is the unit vector composed of the direction cosines of each ray.
  • energy: each cell has the energy carried by the corresponding ray.
  • parents: (not for source rays, for use in optics managers etc.) the index of the parent ray within the ray bundle used to create this bundle.
  • ref_index: each cell has the refractive index of the medium in which the corresponding ray travels.
  • kwds: more ray properties, each property named by the keyword, with a value whose shape[-1] == n.
delete_rays(selector)

Create a new ray bundle which copies this bundle, except in that rays denoted by selector are not copied. Basically equivalent to using inherit(), with an inverted selector and no other arguments.

static empty_bund()

Create an empty ray bundle - that is, a ray whose attributes are fully set, but to empty arrays of correct size.

get_num_rays()

Returns the number of rays in the bundle. Assumes that the mandatory attributes were set (vertices, directions).

has_property(propname)

Checks whether the looked-after property propname exists for this bundle.

inherit(selector=slice(None, None, None), vertices=None, direction=None, energy=None, parents=None, ref_index=None, **kwds)

Create a bundle with some ray properties given, and unspecified properties copied from this bundle, at the places noted by selector.

Arguments

  • selector: array of ray indices in the current bundle to use, must be the same length as the number of rays in the given properties vertices, direction, energy, parents, ref_index - set the corresponding properties instead of using this bundle.
  • kwds: the same for properties that were created during ray bundle construction in addition to the basic set of properties.
tracer.ray_bundle.concatenate_rays(bundles)

Take a list of bundles and merge them into one bundle.

Arguments

  • bundles: a list of RayBundle objects, all with the same set of attributes set.

Returns

A RayBundle object with all attributes that are set in the first bundle.

Previous topic

Tracer Package

Next topic

The has_frame module

This Page