eradiate.scenes.atmosphere.ParticleStateComponent#
- class eradiate.scenes.atmosphere.ParticleStateComponent(id='atmosphere', geometry='plane_parallel', extremum_resolution=(1, 1, 1), has_absorption=True, has_scattering=True, force_polarized_phase=False, *, use_rrt=True, ddis_threshold=0.0, scale=None, force_majorant=False, profile, properties, amount=None, state_variables=NOTHING, phase=None)#
Bases:
ParticleComponentGeneric class for a particulate medium parametrized by an amount and one or two tabulated state variables, which vary as a function of space coordinates.
The
profileholds the fields of the state variables. The tabulated ones serve as a lookup pivot in thepropertiestable, which maps state dimensions to per-unit-amount optical properties (extinction, albedo, phase function).Generic by nature, this class carries metadata to specify the tabulated state variables: the
state_variablesmapping linkspropertiesstate dimension names to the profile variables supplying their per-voxel values. No specific units are enforced: the state variables exposed by the profile can be any physical quantity, as long as units are compatible between the state dimension (properties) and the profile variable (profile) linked by thestate_variablesdictionary.The
amountfield specifies the profile variable that scales the per-unit-amount extinction (e.g. mass or number concentration). Its units must be such that its product with the units of the per-unit-amount extinction inpropertieshas the dimensionality of an inverse length.Interpolation of the
propertiesagainststate_variablesis linear, and out-of-range state values are clamped. Extinction scaling is linear. When evaluated, theprofileis resampled onto the render grid. This spatial resampling is axis-dependent: thexandygrids are not interpolated and must match the render grid’s extent and resolution; each render grid cell takes the values of the profile cell containing its centre, and cells whose centre lies outside the profile’s vertical extent get zero for every state variable.Extinction and albedo are interpolated per voxel in Python; the phase function is interpolated per voxel at render time by the
particlephasekernel plugin, wrapped byGriddedParticlePhaseFunction.- Parameters:
id (
str, optional, default:"atmosphere") – Identifier of the current scene element.geometry (
SceneGeometryordictorstr, optional, default:"plane_parallel") – Parameters defining the basic geometry of the scene. Note if the atmosphere is used in a simulation, the experiment has all control over the atmosphere’s geometry and is going to set it. Therefore, in such a case it is best to define the geometry at the experiment level. When the atmosphere is used standalone, care must be taken to ensure that the geometry is consistent with the vertical extent of the atmosphere.use_rrt (
bool) – If set to true, prescribe the use of residual ratio tracking to estimate transmittance for integrators that allow it. Otherwise, falls back to ratio tracking. Residual ratio tracking generally reduces variance and can improve performance for high optical thickness. Ignored on components of aHeterogeneousAtmosphere; set it on the parent instead.ddis_threshold (
float) – Specifies the probability to importance sample the phase using the emitter as incident direction. Set negative to deactivate. Ignored on components of aHeterogeneousAtmosphere; set it on the parent instead.scale (
float, optional) – If set, the extinction coefficient is scaled by the corresponding amount during computation.force_majorant (
bool, optional) – If set to true, uses heterogeneous medium, which is compatible with all integrators except PiecewiseVolpathIntegrator. Otherwise, uses a piecewise medium which is compatible with PiecewiseVolPathIntegrator and other integrators. This setting only affects PlaneParallelGeometry, other geometries use heterogeneous mediums. Ignored on components of aHeterogeneousAtmosphere; set it on the parent instead.extremum_resolution (
tuple[int,int,int], default:(1,1,1)) – [EXPERIMENTAL] Resolution of the extremum structure. Applies to both plane parallel and spherical shell geometries but the latter only accepts a resolution greater than one along its radial dimension (first dimension). Also note than in plane parallel the dimensions are [x, y, z] and in spherical shell [r, theta, phi]. The default value (1, 1, 1) falls back to a global majorant. In plane parallel, set to (0,0,0) to trigger an adaptive search of the optimal resolution. Note that this is an expensive search that triggers at spectral update. Ignored by piecewise media (plane parallel with a 1D grid andforce_majorantunset). Ignored on components of aHeterogeneousAtmosphere; set it on the parent instead.has_absorption (
bool, default:True) – Absorption bypass switch. IfTrue, the absorption coefficient is computed. Else, the absorption coefficient is not computed and instead set to zero.has_scattering (
bool, default:True) – Scattering bypass switch. IfTrue, the scattering coefficient is computed. Else, the scattering coefficient is not computed and instead set to zero.force_polarized_phase (
bool, default:False) – Force the use of a polarized phase function implementation, even when no polarization information is available.profile (
ParticleProfileorDatasetor path-like) – Dense volumetric state profile, in the Ppr-Core v1 format. This parameter has no default.properties (
ParticlePropertiesorDatasetor path-like orstr) – Particle properties, in the Prt-Core v1 format extended with 1 or 2 state dimensions (see Extensions). This parameter has no default.amount (
str, optional, default:None) – Name of the profile variable that scales the per-unit-amount extinction (e.g. mass or number concentration). If unset, the unique profile variable whose units makeamount * extan inverse length is selected automatically.state_variables (
dict[str,str], optional, default:{}) – Tabulated state variables, as a mapping from apropertiesstate dimension name to the profile variable supplying its per-voxel value. State dimensions not listed here default to a profile variable of the same name.phase (
PhaseFunctionordict, optional, default:None) – Phase function override. If unset, aGriddedParticlePhaseFunctionis built fromprofileandproperties.
- Fields:
geometry (
SceneGeometry) – Parameters defining the basic geometry of the scene.use_rrt (
bool) – If set to true, prescribe the use of residual ratio tracking to estimate transmittance for integrators that allow it.ddis_threshold (
float) – Specifies the probability to importance sample the phase using the emitter as incident direction.scale (
floatorNone) – If set, the extinction coefficient is scaled by the corresponding amount during computation.force_majorant (
bool) – If set to true, uses heterogeneous medium, which is compatible with all integrators except PiecewiseVolpathIntegrator.extremum_resolution (
tuple[int,int,int]) – [EXPERIMENTAL] Resolution of the extremum structure.has_absorption (
bool) – Absorption bypass switch.has_scattering (
bool) – Scattering bypass switch.force_polarized_phase (
bool) – Force the use of a polarized phase function implementation, even when no polarization information is available.profile (
ParticleProfile) – Dense volumetric state profile, in the Ppr-Core v1 format.properties (
ParticleProperties) – Particle properties, in the Prt-Core v1 format extended with 1 or 2 state dimensions (see Extensions).amount (
strorNone) – Name of the profile variable that scales the per-unit-amount extinction (e.g. mass or number concentration).state_variables (
dict[str,str]) – Tabulated state variables, as a mapping from apropertiesstate dimension name to the profile variable supplying its per-voxel value.
- classmethod convert(value)#
Conversion logic:
If value is a ParticleStateComponent instance, return it unchanged.
If value is a dictionary, it is interpreted by
atmosphere_factory; the"type"parameter may be omitted and will automatically be set to"particle_state".Otherwise, the value is returned unchanged.
- eval_albedo(si, grid=None)#
Evaluate the single-scattering albedo on the render grid.
- Parameters:
si (
SpectralIndex) – Spectral index at which to evaluate.grid (
SpatialGrid, optional) – Target render grid. Defaults toself.geometry.grid.
- Returns:
pint.Quantity– Single-scattering albedo array of shape(n_x_cells, n_y_cells, n_z_cells), dimensionless.- Raises:
RuntimeError – If both
has_absorptionandhas_scatteringareFalse.
- eval_radprops(si, grid=None, optional_fields=False)#
Evaluate the extinction coefficients and albedo profiles.
- Parameters:
si (
SpectralIndex) – Spectral index.grid (
SpatialGrid, optional) – Altitude grid on which evaluation is performed. If unset, an instance-specific default is used (seegrid).optional_fields (
bool, optional, default:False) – IfTrue, also output the absorption and scattering coefficients, not required for scene setup but useful for analysis and debugging.
- Returns:
Dataset– A dataset with the following variables:sigma_t: extinction coefficient;albedo: albedo;sigma_a: absorption coefficient (optional);sigma_s: scattering coefficient (optional).
with dimensions
(x_cell, y_cell, z_layer)and coordinates:x_cell: X cell centres (azimuth for a spherical grid);y_cell: Y cell centres (colatitude for a spherical grid);z_layer: layer centre altitude.
- eval_sigma_a(si, grid=None)#
Evaluate the absorption coefficient on the render grid.
- Parameters:
si (
SpectralIndex) – Spectral index at which to evaluate.grid (
SpatialGrid, optional) – Target render grid. Defaults toself.geometry.grid.
- Returns:
pint.Quantity– Absorption coefficient array of shape(n_x_cells, n_y_cells, n_z_cells), in units of \(\mathrm{km}^{-1}\).
- eval_sigma_s(si, grid=None)#
Evaluate the scattering coefficient on the render grid.
- Parameters:
si (
SpectralIndex) – Spectral index at which to evaluate.grid (
SpatialGrid, optional) – Target render grid. Defaults toself.geometry.grid.
- Returns:
pint.Quantity– Scattering coefficient array of shape(n_x_cells, n_y_cells, n_z_cells), in units of \(\mathrm{km}^{-1}\).
- eval_sigma_t(si, grid=None)#
Evaluate the extinction coefficient on the render grid.
- Parameters:
si (
SpectralIndex) – Spectral index at which to evaluate.grid (
SpatialGrid, optional) – Target render grid. Defaults toself.geometry.grid.
- Returns:
pint.Quantity– Extinction coefficient array of shape(n_x_cells, n_y_cells, n_z_cells), in units of \(\mathrm{km}^{-1}\).- Raises:
RuntimeError – If both
has_absorptionandhas_scatteringareFalse.
- eval_transmittance(si, interaction='extinction')#
Evaluate the atmosphere’s transmittance with respect to specific interaction.
- Parameters:
si (
SpectralIndex) – Spectral index.interaction (
{"extinction", "absorption", "scattering"}, optional, default:"extinction") – Interaction type.
- Returns:
quantity– Total atmosphere transmittance.
- to_profile_regular_grid()#
Return a copy of this
ParticleStateComponentwith its geometry set to a regular grid aligned with the profile.
- 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()#
Update internal state.
- property absorption_data#
- Returns:
AbsorptionDatabaseorNone– If relevant, the molecular absorption database associated with this atmosphere.
- property is_piecewise#
Trueif this atmosphere is rendered with apiecewisemedium, which requires aPlaneParallelGeometrywith a 1D grid andforce_majorantunset. Only this medium is compatible withPiecewiseVolPathIntegrator; it ignoresextremum_resolutionanduse_rrt.
- property medium_id#
- Returns:
str– ID of the medium associated with the atmosphere in the Mitsuba scene tree.
- 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] orNone– A dictionary mapping parameter paths, consisting of dot-separated strings, to a corresponding update protocol.
See also
- property phase#
- Returns:
PhaseFunction– Phase function associated with the atmosphere.
- property phase_id#
- Returns:
str– ID of the phase function associated with the atmosphere in the Mitsuba scene tree.
- property shape#
- Returns:
Shape– Shape associated with this atmosphere, based on the scene geometry.
- property shape_id#
- Returns:
str– ID of the shape associated with the atmosphere in the Mitsuba scene tree.
- property state_dims#
- Returns:
tuple[str,]– Names ofproperties’ state dimensions (seeParticleProperties.state_dims).
- 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 themitsuba.load_dict()function, orDictParameterinstances which must be rendered.
See also