eradiate

The Eradiate radiative transfer simulation software package.

Data handling

eradiate.asset_manager = eradiate.data.AssetManager(...)

Unique instance of the Eradiate asset manager. See AssetManager.

eradiate.fresolver = eradiate.data.FileResolver(...)

Unique instance of the Eradiate file resolver. See FileResolver.

Mode management

eradiate.get_mode(*args, **kwargs)[source]

Get current operational mode.

Parameters:

raise_exc (bool, default: True) – If True, raise an exception if mode has not been set prior (otherwise, this function will return None in such cases).

Returns:

Mode or None – Current operational mode.

Raises:

UnsetModeError – If no active mode has been selected.

See also

set_mode()

eradiate.mode(*args, **kwargs)[source]

This is a thin compatibility wrapper around get_mode().

eradiate.modes(*args, **kwargs)[source]

Get list of registered operational modes.

Parameters:
  • filter (callable(), optional) – A callable used to filter the returned modes. Operates on a Mode instance.

  • asdict (bool, default: False) – If True, returns a mode ID → mode instance dictionary; otherwise, returns a list of mode IDs only.

Returns:

modes (list[str] or dict[str, Mode]) – List of registered operational modes.

Examples

Return the full list of registered modes:

>>> eradiate.modes()

Return only CKD modes:

>>> eradiate.modes(lambda x: x.is_ckd)
eradiate.set_mode(*args, **kwargs)[source]

Set Eradiate’s operational mode.

This function sets and configures Eradiate’s operational mode. Eradiate’s modes map to Mitsuba’s variants and are used to make contextual decisions when relevant during the translation of a scene to its kernel format.

Valid mode IDs

  • mono: Alias to mono_double

  • ckd: Alias to ckd_double

  • mono_polarized: Alias to mono_polarized_double

  • ckd_polarized: Alias to ckd_polarized_double

  • mono_single: Monochromatic, single-precision

  • mono_polarized_single: Monochromatic, polarized, single-precision

  • mono_double: Monochromatic, double-precision

  • mono_polarized_double: Monochromatic, polarized, double-precision

  • ckd_single: CKD, single-precision

  • ckd_polarized_single: CKD, polarized, single-precision

  • ckd_double: CKD, double-precision

  • ckd_polarized_double: CKD, polarized, double-precision

  • none (no mode selected)

Parameters:

mode_id (str) – Mode to be selected (see list below).

Raises:

ValueErrormode_id does not match any of the known mode identifiers.

eradiate.supported_mode(*args, **kwargs)[source]

Check whether the current mode has specific features. If not, raise.

Parameters:

kwargs – Keyword arguments passed to Mode.check().

Raises:

UnsupportedModeError – Current mode does not pass the check.

eradiate.unsupported_mode(*args, **kwargs)[source]

Check whether the current mode has specific features. If so, raise.

Parameters:

kwargs – Keyword arguments passed to Mode.check().

Raises:

UnsupportedModeError – Current mode has the requested flags.

eradiate.Mode(*args, **kwargs)[source]

Data structure describing Eradiate’s operational mode and associated ancillary data.

Parameters:
  • id (str) – Mode identifier.

  • spectral_mode (ModeFlag or str) – Spectral dimension handling.

  • mi_backend (ModeFlag or str) – Mitsuba computational backend.

  • mi_color_mode (ModeFlag or str) – Mitsuba color mode.

  • mi_polarized (ModeFlag or str) – Mitsuba polarized mode.

  • mi_double_precision (ModeFlag or str) – Mitsuba double precision.

Fields:
  • id (str) – Mode identifier.

  • spectral_mode (ModeFlag) – Spectral dimension handling.

  • mi_backend (ModeFlag) – Mitsuba computational backend.

  • mi_color_mode (ModeFlag) – Mitsuba color mode.

  • mi_polarized (ModeFlag) – Mitsuba polarized mode.

  • mi_double_precision (ModeFlag) – Mitsuba double precision.

Warning

Instances are immutable.

eradiate.ModeFlag(value, names=None, *, module=None, qualname=None, type=None, start=1)[source]

Flags defining the various possible features associated to an Eradiate mode.

Unit management

eradiate.unit_registry(*args, **kwargs)

A wrapper class used to distribute changes to the application registry.

eradiate.unit_context_config

An overridable registry of UnitGenerator objects.

This class maintains a registry of UnitGenerator instances. Stored UnitGenerator objects can be conveniently overridden using the override() context manager.

Attributes / constructor arguments:
  • registry (Dict[Hashable, UnitGenerator]) – Unit generator registry. Keys can be any hashable type, but str or Enum are recommended. Defaults to an empty dictionary.

    Note

    The initialization sequence will make repeated calls to register() and will consequently apply the same key and value conversion rules.

  • interpret_str (bool) – If True, attempt string-to-units interpretation when specifying unit generators as str.

  • ureg (Optional[UnitRegistry]) – Unit registry used for string-to-units interpretation. If None, the default registry is used (see get_unit_registry()).

  • key_converter (Callable) – Converter used for keys. Defaults to identity().

Changed in version 1.1.0: Added ureg.

eradiate.unit_context_kernel

An overridable registry of UnitGenerator objects.

This class maintains a registry of UnitGenerator instances. Stored UnitGenerator objects can be conveniently overridden using the override() context manager.

Attributes / constructor arguments:
  • registry (Dict[Hashable, UnitGenerator]) – Unit generator registry. Keys can be any hashable type, but str or Enum are recommended. Defaults to an empty dictionary.

    Note

    The initialization sequence will make repeated calls to register() and will consequently apply the same key and value conversion rules.

  • interpret_str (bool) – If True, attempt string-to-units interpretation when specifying unit generators as str.

  • ureg (Optional[UnitRegistry]) – Unit registry used for string-to-units interpretation. If None, the default registry is used (see get_unit_registry()).

  • key_converter (Callable) – Converter used for keys. Defaults to identity().

Changed in version 1.1.0: Added ureg.

Metadata

eradiate.__version__

Eradiate version string.

Convenience aliases

eradiate.run(*args, **kwargs)[source]

Run an Eradiate experiment. This function performs kernel scene assembly, runs the computation and post-processes the raw results. The output consists of one or several xarray datasets.

Parameters:
  • exp (Experiment) – Reference to the experiment object which will be processed.

  • measures (int or str or list of int or str, optional) – Indices of the measures that will be processed. By default, all measures are processed.

  • spp (int, optional, default: 0) – Optional parameter to override the number of samples per pixel for all computed measures. If set to 0, the configured value for each measure takes precedence.

  • seed_state (SeedState, optional) – Seed state used to generate seeds to initialize Mitsuba’s RNG at every iteration of the parametric loop. If unset, Eradiate’s root seed state is used.

Returns:

Dataset or dict[str, Dataset] – If a single measure is processed, a single xarray dataset is returned. If several measures are processed, a dictionary mapping measure IDs to the corresponding result dataset is returned.

Notes

  • Successive calls to this function with different measures will not reset the Experiment.results dictionary.

  • Successive calls with already processed measures will overwrite prior results.

eradiate.traverse(*args, **kwargs)[source]

Traverse a scene element tree and collect kernel dictionary template and parameter update table data.

Parameters:

node (SceneElement) – Scene element where to start traversal.

Returns:

  • kdict_template (KernelDict) – Kernel dictionary template corresponding to the traversed scene element.

  • umap_template (KernelSceneParameterMap) – Kernel parameter table associated with the traversed scene element.