eradiate.scenes.phase.GriddedParticlePhaseFunction#

class eradiate.scenes.phase.GriddedParticlePhaseFunction(id='phase', *, volume_1, grid_1, volume_2=None, grid_2=None, phase_data, geometry)#

Bases: PhaseFunction

Phase function for spatially heterogeneous particle components, looked up per voxel from one or two state variables.

Wraps the particlephase kernel plugin, which performs bilinear interpolation of the phase matrix over two state variables. The plugin names its two state variable slots after the effective radius and variance (r_eff_*, v_eff_*), but any state variables can be passed. When only one state variable is used, the second slot is padded with a degenerate, single-point grid, over which interpolation is a no-op.

The phase spectral properties are passed through the phase_data callable. This callable returns a dict with the following information:

  • mu: 2D array of shape (n_pts, max_len), where n_pts is len(grid_1) (or len(grid_1) * len(grid_2) if a second state variable is used). Each row holds the scattering angle cosine discretization for one grid point, padded with trailing NaN to the widest row’s length.

  • phase: 3D array of phase function values, shape (n_pts, n_phamat, max_len). Contains the tabulated phase function values indexed by mu. It follows the same per-row grid-point ordering and NaN-padding as mu, with an extra middle axis to select the Mueller phase matrix components.

  • ext: extinction coefficient, shape matching the state variable grid ((len(grid_1),) or (len(grid_1), len(grid_2))).

  • ssa: single-scattering albedo, same shape as ext.

  • max_union_size: upper bound on the CSR-flattened, cross-spectral angular index length built from mu.

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

  • volume_1 (quantity) – Dense (n_x, n_y, n_z) quantity of the first state variable on the render grid. Values must lie within grid_1.

  • grid_1 (quantity) – Strictly increasing 1-D array of values for the first state variable. Must have units compatible with volume_1.

  • volume_2 (quantity, optional, default: None) – Dense (n_x, n_y, n_z) quantity of the second state variable on the render grid, if any. Values must lie within grid_2.

  • grid_2 (quantity, optional, default: None) – Strictly increasing 1-D array of values for the second state variable, if any. Must be set iff volume_2 is set, with compatible units.

  • phase_data (callable()) – Callable returning the phase properties for a given spectral index. Its return value is a dict with the keys mu, phase, ext, ssa and max_union_size

  • geometry (SceneGeometry) – Geometry describing the render grid on which volume_1 and volume_2 are defined.

Fields:
  • id (str or None) – Identifier of the current scene element.

  • volume_1 (quantity) – Dense (n_x, n_y, n_z) quantity of the first state variable on the render grid.

  • grid_1 (quantity) – Strictly increasing 1-D array of values for the first state variable.

  • volume_2 (quantity or None) – Dense (n_x, n_y, n_z) quantity of the second state variable on the render grid, if any.

  • grid_2 (quantity or None) – Strictly increasing 1-D array of values for the second state variable, if any.

  • phase_data (callable()) – Callable returning the phase properties for a given spectral index.

  • geometry (SceneGeometry) – Geometry describing the render grid on which volume_1 and volume_2 are defined.

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, SceneParameter] 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 DictParameter instances which must be rendered.