eradiate.scenes.biosphere.MeshTreeElement

eradiate.scenes.biosphere.MeshTreeElement#

class eradiate.scenes.biosphere.MeshTreeElement(id='mesh_tree_element', mesh_units=None, reflectance=0.5, transmittance=0.0, *, mesh_filename)[source]#

Bases: object

Container class for mesh based constituents of tree-like objects in a canopy. Holds the filepath for the triangulated mesh and all parameters specifying the associated BSDF.

Important

The triangulated mesh must be provided in .ply or .obj format.

Since mesh definition files cannot carry Pint units, the attribute mesh_units lets users provide the unit which their mesh is defined in. Upon kernel dict creation the mesh is scaled to match the length unit used in the kernel. If mesh_units is not provided, no scaling of the mesh is performed.

The MeshTreeElement.from_dict() constructor instantiates the class from a configuration dictionary.

Parameters:
  • id (str, optional) – User-defined object identifier.

  • mesh_filename (path-like) – Path to the triangulated mesh data file. This parameter is required.

  • mesh_units (str or pint.Unit, optional) – Units the mesh was defined in. Used to convert to kernel units. If unset, the mesh is interpreted as being defined in kernel units.

  • reflectance (Spectrum or dict, default: 0.5) – Reflectance of the object. Must be a reflectance spectrum (dimensionless).

  • transmittance (Spectrum or dict, default: 0.0) – Transmittance of the object. Must be a transmittance spectrum (dimensionless).

Fields:
  • id (str, optional) – User-defined object identifier.

  • mesh_filename (pathlib.Path) – Path to the triangulated mesh data file.

  • mesh_units (pint.Unit, optional) – Units the mesh was defined in.

  • reflectance (Spectrum) – Reflectance of the object.

  • transmittance (Spectrum) – Transmittance of the object.

static convert(value)[source]#

Object converter method.

If value is a dictionary, this method uses from_dict() to create an MeshTreeElement. Otherwise, it returns value.

Parameters:

value – Value to attempt conversion of.

Returns:

any type – Converted value.

static from_dict(d)[source]#

Create from a dictionary. This class method will additionally pre-process the passed dictionary to merge any field with an associated "_units" field into a pint.Quantity container.

Parameters:

d (dict) – Configuration dictionary used for initialisation.

Returns:

MeshTreeElement – Created object.