eradiate.scenes.biosphere.DiscreteCanopy#

class eradiate.scenes.biosphere.DiscreteCanopy(id='canopy', size=None, instanced_canopy_elements=_Nothing.NOTHING)[source]#

Bases: Canopy

Discrete canopy scene element [discrete_canopy].

A discrete canopy composed of one or several CanopyElement instances. The underlying implementation holds a list of InstancedCanopyElement, allowing for arbitrary cloning of each CanopyElement. The produced canopy can be padded with clones of itself using the padded_copy() method.

Class method constructors

homogeneous([padding, id])

Generate a homogeneous discrete canopy, possibly padded with copies of itself.

leaf_cloud_from_files(size, leaf_cloud_dicts)

Directly create a leaf cloud canopy from text file specifications, possibly padded with copies of itself.

padded([padding])

Create a discrete canopy and pad it with copies of itself.

Parameters:
  • id (str, optional, default: "canopy") – Identifier of the current scene element.

  • size (array-like) – Canopy extent as a 3-vector.

    Unit-enabled field (default: ucc[‘length’]).

  • instanced_canopy_elements (list of InstancedCanopyElement, default: []) – List of CanopyElement defining the canopy. Can be initialised with a InstancedCanopyElement, which will be automatically wrapped into a list. Dictionary-based specifications are allowed as well.

Fields:
classmethod homogeneous(padding=0, id='homogeneous_discrete_canopy', **leaf_cloud_kwargs)[source]#

Generate a homogeneous discrete canopy, possibly padded with copies of itself.

Parameters:
  • padding (int) – Amount of padding around the canopy. Must be positive or zero. The resulting padded canopy is a grid of \(2 \times \mathit{padding} + 1\) copies.

  • id (str, default: "homogeneous_discrete_canopy") – Canopy object ID.

  • **leaf_cloud_kwargs – Keyword arguments forwarded to LeafCloud.cuboid().

Returns:

DiscreteCanopy – Created canopy object.

Notes

The leaf cloud’s ID will be set to f"{id}_leaf_cloud".

classmethod leaf_cloud_from_files(size, leaf_cloud_dicts, padding=0, id='discrete_canopy')[source]#

Directly create a leaf cloud canopy from text file specifications, possibly padded with copies of itself.

CanopyElement dictionary format

Each item of the leaf_cloud_dicts list shall have the following structure:

{
    "sub_id": "some_value",  # leaf cloud ID string part, optional if leaf_cloud_dicts has only 1 entry
    "instance_filename": "some_path",  # path to instance specification file
    "leaf_cloud_filename": "some_other_path", # path to leaf cloud specification file
    "leaf_reflectance": 0.5,  # optional, leaf reflectance (default: 0.5)
    "leaf_transmittance": 0.5,  # optional, leaf transmittance (default: 0.5)
}
Parameters:
  • size (quantity) – Canopy size as a 3-vector (in metres).

  • leaf_cloud_dicts (list of dict) – List of dictionary specifying canopy elements and instances (see format above).

  • padding (int, default: 0) – Amount of padding around the canopy. Must be positive or zero. The resulting padded canopy is a grid of \(2 \times \mathit{padding} + 1\) copies.

  • id (str, default: "discrete_canopy") – Canopy ID.

Returns:

DiscreteCanopy – Created canopy object.

classmethod padded(padding=0, **kwargs)[source]#

Create a discrete canopy and pad it with copies of itself. Keyword arguments are forwarded to the default constructor.

Parameters:
  • padding (int) – Amount of padding around the canopy. Must be positive or zero. The resulting padded canopy is a grid of \(2 \times \mathit{padding} + 1\) copies.

  • **kwargs`` – Keyword arguments forwarded to the DiscreteCanopy constructor.

Returns:

DiscreteCanopy – Padded discrete canopy.

padded_copy(padding)[source]#

Return a copy of the current canopy padded with additional copies.

Parameters:

padding (int) – Amount of padding around the canopy. Must be positive or zero. The resulting padded canopy is a grid of \(2 \times \mathit{padding} + 1\) copies.

Returns:

DiscreteCanopy – Padded copy of self.

traverse(callback)#

Traverse this scene element and collect kernel dictionary template and parameter update map contributions.

Parameters:

callback (SceneTraversal) – Callback data structure storing the collected data.

update()#

Enforce internal state consistency. This method should be called when fields are modified. It is automatically called as a post-init step.

property objects#

Map of child objects associated with this scene element.

Returns:

dict – A dictionary mapping object names to a corresponding object to be inserted in the Eradiate scene graph.

property params#
Returns:

dict[str, UpdateParameter] or None – A dictionary mapping parameter paths, consisting of dot-separated strings, to a corresponding update protocol.

property template#

Kernel dictionary template contents associated with this scene element.

Returns:

dict – A flat dictionary mapping dot-separated strings describing the path of an item in the nested scene dictionary to values. Values may be objects which can be directly used by the mitsuba.load_dict() function, or InitParameter instances which must be rendered.