canopy_factory.raytrace package¶
Submodules¶
canopy_factory.raytrace.base module¶
- class canopy_factory.raytrace.base.RayTracerBase(args, mesh, geometryids=None)[source]¶
Bases:
RegisteredClassBaseBase class for ray tracers.
- property camera_direction¶
Unit vector for camera’s pointing direction.
- Type:
np.ndarray
- property camera_distance¶
Distance between the camera and the scene scenter.
- Type:
float
- property camera_location¶
Coordinates of the camera.
- Type:
np.ndarray
- property camera_right¶
Unit vector for camera’s right direction.
- Type:
np.ndarray
- property camera_scene_dims¶
Scene dimensions parallel to the image plant.
- Type:
np.ndarray
- property camera_up¶
Unit vector in the camera’s up direction.
- Type:
np.ndarray
- property clipping_distance¶
Maximum distance of any scene limits from the scene center along the camera line-of-sight.
- Type:
float
- coverage()[source]¶
Compute the scene coverage.
- Returns:
Percent of rays that hit the plants.
- Return type:
float
- property east¶
Vector direction of east in the scene.
- Type:
np.ndarray
- face2vertex(face_scalar, method='average')[source]¶
Convert an array of scalars for each face to an array of scalars for each vertex.
- Parameters:
face_scalar (np.ndarray) – Array of scalars for each face.
method (str, optional) –
Method to use to map from face values to vertex values.:
'average': Average over the values for each face that vertices are part of. 'deposit': Split the values for each face amongst its vertices additively.
- Returns:
Array of scalars for each vertex.
- Return type:
np.ndarray
- property field_scene_model¶
Field scene properties.
- Type:
- classmethod finalize_face_index(idx, Nface, shift=0)[source]¶
Convert a face index to a numpy array.
- Parameters:
idx (dict) – Dictionary of indices created when selecting a subset of a mesh.
Nface (int) – Number of faces in the mesh.
shift (int, optional) – Factor that should be added to the final index.
- Returns:
Face indices selected by idx.
- Return type:
np.ndarray
- property geometryid_order¶
Set of IDs that should be used to split the geometry into parts.
- Type:
list
- property ground¶
Coordinates of the scene center on the ground.
- Type:
np.ndarray
- property ground_origin¶
Coordinates of the scene center on the ground.
- Type:
np.ndarray
- property image_center¶
Coordinates of the image’s center.
- Type:
np.ndarray
- property image_distance¶
Distance of the image plane from the camera.
- Type:
float
- property image_height¶
Image height.
- Type:
float
- property image_nx¶
Number of pixels in the x direction.
- Type:
int
- property image_ny¶
Number of pixels in the y direction.
- Type:
int
- property image_width¶
Image width.
- Type:
float
- property layout_scene_model¶
Field scene properties.
- Type:
- mesh_item(key)[source]¶
Get the portion of the mesh corresponding to a key specifying which part of the geometry should be selected.
- Parameters:
key (tuple, None) – Key specifying a part of the geometry.
- Returns:
Mesh dictionary for selected part of the geometry.
- Return type:
dict
- mesh_keys()[source]¶
Get the set of keys splitting up the mesh geometry into parts.
- Returns:
Keys.
- Return type:
list
- property north¶
Vector direction of north in the scene.
- Type:
np.ndarray
- property nvirtual¶
- parse_axis(x)[source]¶
Parse axis values that specify direction relative to the scene.
- Parameters:
x (str) – Input string.
- Returns:
Axis vector.
- Return type:
np.ndarray
- property periodic_shifts¶
Shifts for positions of periodic plants.
- Type:
np.ndarray
- property plant_triangles¶
Yields tuples of plant ID & arrays of triangles for the faces in that plant.
- property ray_directions¶
Ray directions.
- Type:
np.ndarray
- property ray_lengths¶
Ray lengths.
- Type:
np.ndarray
- property ray_origins¶
Coordinates of ray origins.
- Type:
np.ndarray
- raytrace(query)[source]¶
Run the ray tracer and get values for each face.
- Parameters:
query (str) – Type of raytrace operation that should be performed.
- Returns:
Ray tracer results for each face.
- Return type:
np.ndarray
- property real_scene_model¶
Scene properties.
- Type:
- render(values)[source]¶
Image the scene.
- Parameters:
values (np.ndarray) – Values on each face that should be used when imaging the scene.
- Returns:
Ray tracer results for each pixel.
- Return type:
np.ndarray
- property resolution¶
Number of pixels per cm that image should be rendered will.
- Type:
float
- classmethod select_faces(mesh_dict, cond, continuous=False, dont_prune_vertices=False)[source]¶
Select a subset of the faces in a mesh.
- Parameters:
mesh_dict (dict) – Dictionary of mesh properties.
cond (np.ndarray) – Condition that should be used to select the faces.
continuous (bool, optional) – If True, the faces and vertices for which the condition is True are continuous.
dont_prune_vertices (bool, optional) – If True, vertices that are not selected are not removed.
- Returns:
- Dictionary of mesh properties with only the selected
faces.
- Return type:
dict
- classmethod select_vertices(mesh_dict, cond, continuous=False)[source]¶
Select a subset of the vertices in a mesh.
- Parameters:
mesh_dict (dict) – Dictionary of mesh properties.
cond (np.ndarray) – Condition that should be used to select the vertices.
continuous (bool, optional) – If True, the faces and vertices for which the condition is True are continuous.
- Returns:
- Dictionary of mesh properties with only the selected
vertices.
- Return type:
dict
- property up¶
Vector direction of up in the scene.
- Type:
np.ndarray
- property virtual_scene_model¶
Virtual scene properties.
- Type:
- property virtual_shifts¶
Shifts for positions of virtual plants.
- Type:
np.ndarray
- property zenith¶
Vector from the ground in the up direction with a length equal to the farthest point in the scene from the ground
- Type:
np.ndarray
- property zenith_origin¶
Vector from the ground in the up direction with a length equal to the farthest point in the scene from the ground
- Type:
np.ndarray
- class canopy_factory.raytrace.base.SceneModel(mins, maxs)[source]¶
Bases:
RegisteredClassBaseContainer for scene properties.
- Parameters:
mins (np.ndarray) – Minimum bounds of scene in each dimension.
maxs (np.ndarray) – Maximum bounds of scene in each dimension.
- property center¶
Coordinates of the scene’s center.
- Type:
np.ndarray
- property dim¶
Scene’s dimensions in each direction.
- Type:
np.ndarray
- property limits¶
Corners of a box containing the scene.
- Type:
np.ndarray
canopy_factory.raytrace.embree module¶
- class canopy_factory.raytrace.embree.EmbreeRayTracer(args, mesh, geometryids=None)[source]¶
Bases:
RayTracerBaseRaytracer using embree directly.
canopy_factory.raytrace.hothouse module¶
- class canopy_factory.raytrace.hothouse.HothouseRayTracer(args, mesh, geometryids=None)[source]¶
Bases:
RayTracerBaseRaytrace using hothouse.
- RTC_INVALID_GEOMETRY_ID = np.int32(-1)¶
- property camera_blaster¶
Blaster for camera.
- Type:
hothouse.blaster.RayBlaster
- coverage()[source]¶
Compute the scene coverage.
- Returns:
Percent of rays that hit the plants.
- Return type:
float
- property coverage_blaster¶
Blaster for coverage.
- Type:
hothouse.blaster.OrthographicRayBlaster
- get_solar_blaster(**kwargs)[source]¶
Create a hothouse SunRayBlaster.
- Parameters:
**kwargs – All keyword arguments are passed to the SunRayBlaster constructor after supplementing missing arguments with scene properties.
- Returns:
Blaster instance.
- Return type:
SunRayBlaster
- plantid2geomIDs(plantid, exclude_virtual=False)[source]¶
Get the scene geometry IDs for a given plant ID including both real and virtual plant geometries.
- Parameters:
plantid (int) – Plant ID to get geometry IDs for.
exclude_virtual (bool, optional) – If True, don’t include virtual plant geometries.
- Returns:
Geometry IDs.
- Return type:
list
- property point_source_blaster¶
Blaster for a point source.
- Type:
hothouse.blaster.SphericalRayBlaster
- property ray_directions¶
Ray directions.
- Type:
np.ndarray
- property ray_lengths¶
Ray lengths.
- Type:
np.ndarray
- property ray_origins¶
Coordinates of ray origins.
- Type:
np.ndarray
- property ray_properties¶
Ray properties.
- Type:
tuple
- raytrace(query)[source]¶
Run the ray tracer and get values for each face.
- Parameters:
query (str) – Type of raytrace operation that should be performed.
- Returns:
Ray tracer results for each face.
- Return type:
np.ndarray
- raytrace_sample(hits, values, value_miss=nan, method='accumulate')[source]¶
Sample a set of values for each face in the mesh based on the faces hit by the ray tracer.
- Parameters:
hits (dict) – Raytracer result.
values (np.ndarray) – Array of values at each face.
value_miss (np.float64, optional) – Value to use when a ray did not hit a face.
method (str, optional) – How the values should be sampled.
- Returns:
Result for each ray.
- Return type:
np.ndarray
- render(values, value_miss=-1.0, blaster=None)[source]¶
Image the scene.
- Parameters:
values (np.ndarray) – Values on each face that should be used when imaging the scene.
value_miss (float, optional) – Value that should be used for pixels that do not hit anything.
- Returns:
Ray tracer results for each pixel.
- Return type:
np.ndarray
- property scene¶
Scene containing geometry.
- Type:
hothouse.scene.Scene
- property solar_blaster¶
Blaster for sun.
- Type:
hothouse.blaster.SolarBlaster
- property solar_model¶
Model for the sun using pvlib.
- Type: