eradiate.pipelines#

This module contains definitions for all post-processing pipeline operations. The implementation complies with the Hamilton dataflow framework’s specifications: the post-processing pipeline is modelled as a directed acyclic graph (DAG), and all post-processing operations are a node in that DAG.

Eradiate uses advanced Hamilton features to mutate the pipeline based on configuration input. For example:

  • Node names reflect the processed physical quantity.

  • Viewing angles are only computed if the measure is distant.

  • Post-processing operations vary depending on the active mode. For example, SRF weighted averaging is only performed in CKD modes.

For clarity, the implementation is split as follows:

  • eradiate.pipelines.logic provides the fundamental logic powering each step of post-processing;

  • eradiate.pipelines.definitions contains the pipeline definition and is intended to be consumed by the Hamilton driver constructor for pipeline initialization;

  • eradiate.pipelines.core provides convenience entry points to facilitate post-processing pipeline initialization.

Pipeline configuration#

Post-processing pipelines are configured using a dictionary specifying parameters listed in the table below. This dictionary is used as the input of the eradiate.pipelines.driver() function. It should be noted that eradiate.pipelines.config() can be used to generate a configuration dictionary easily.

Pipeline configuration variables#

Parameter

Type

Description

add_viewing_angles

bool

Whether the measure provides viewing angles that can be mapped to film pixels.

apply_spectral_response

bool

Whether we should apply SRF weighting (a.k.a convolution) to spectral variables.

measure_distant

bool

Whether we are processing the results of a distant measure.

mode_id

str

The ID of the Eradiate mode for which the pipeline is configured.

var_name, var_metadata

str

The name and metadata for the physical variable that is being processed.

Many nodes of the DAG defining the pipeline are tagged for filtering upon query. Tags explicitly used in the pipeline setup and execution are listed in the table below. The eradiate.pipelines.outputs() function leverages these tags to generate a list of default output nodes when running the post-processing pipeline.

Pipeline node tags#

Tag

Value

Description

"final"

"true"

The node’s output will be selected to be part of the default pipeline output.

"kind"

Defines the type of variable the node’s output corresponds to. Data with the "data" tag will be selected to be part of the default result dataset.

"data"

The output is a data variable and can be assembled into a dataset.

"coord"

The output is a coordinate variable.

Hamilton driver creation and manipulation#

Note

The following entry points are defined in the eradiate.pipelines.core module.

config(measure[, mode])

Generate a pipeline configuration for a specific scene setup.

driver(config)

Create a Hamilton Driver instance using the specified configuration.

list_variables(drv[, as_table])

List variables available in a pipeline.

outputs(drv)

Generate a list of default outputs for a given pipeline.

Pipeline logic (eradiate.pipelines.logic)#

Functions:

aggregate_ckd_quad(mode_id, raw_data, ...)

Compute CKD quadrature.

apply_spectral_response(spectral_data, srf)

Apply SRF weighting (a.k.a convolution) to spectral data and turn it into a band aggregate.

compute_albedo(radiosity_data, irradiance_data)

Compute the bi-hemispherical reflectance (a.k.a surface albedo) from radiosity and irradiance records.

compute_bidirectional_reflectance(...)

Compute the spectral bidirectional reflectance distribution function (BRDF) and bidirectional reflectance factor (BRF) from radiance and irradiance records.

extract_irradiance(mode_id, illumination, ...)

Derive an irradiance dataset from the irradiance spectrum of an illuminant, as well as solar angles.

gather_bitmaps(mode_id, var_name, ...)

Gather a collection of Mitsuba bitmaps into xarray data arrays.

radiosity(sector_radiosity)

Aggregate sector radiosity into a full-hemisphere radiosity dataset.

spectral_response(srf)

Evaluate a spectral response function as a data array.

viewing_angles(angles)

Collect viewing angles associated with each film pixel from the measure, if relevant.

eradiate.pipelines.logic.aggregate_ckd_quad(mode_id, raw_data, spectral_set)[source]#

Compute CKD quadrature.

In CKD modes, this pipeline step aggregates spectral data and evaluates the selected quadrature rule. The following updates to the input data are expected:

  • the g dimension is dropped;

  • a bin_wmin (resp. bin_wmax) coordinate is created and contains the lower (resp. upper) spectral bound of each bin;

  • the dataset is reordered by ascending w values.

Parameters:
  • mode_id (str) – Eradiate mode for which this pipeline step is configured. If set to “ckd”, CKD quadrature computation is performed; otherwise, it is a no-op.

  • raw_data (DataArray) – A data array holding raw bitmap data indexed against pixel indices.

  • spectral_set (WavelengthSet or BinSet) – Spectral set for which the CKD quadrature is computed.

Returns:

DataArray – A data array indexed against spectral coordinates associated with each spectral bin.

Notes

  • In non-CKD modes, this step is a no-op.

  • During pipeline assembly, this node expands as a single node named <var>.

  • The spp variable is averaged on the index dimension.

eradiate.pipelines.logic.apply_spectral_response(spectral_data, srf)[source]#

Apply SRF weighting (a.k.a convolution) to spectral data and turn it into a band aggregate.

Parameters:
  • spectral_data (DataArray) – Spectral data to process.

  • srf (Spectrum) – Spectral response function to apply.

Returns:

DataArray or None – A data array where the spectral dimension is removed after applying SRF weighting, or None if the SRF is a MultiDeltaSpectrum.

eradiate.pipelines.logic.compute_albedo(radiosity_data, irradiance_data)[source]#

Compute the bi-hemispherical reflectance (a.k.a surface albedo) from radiosity and irradiance records.

Parameters:
  • radiosity_data (DataArray) – Radiosity record.

  • irradiance_data (DataArray) – Irradiance record.

Returns:

dict – A dictionary with the following content:

albedoxarray.DataArray

An albedo data array.

eradiate.pipelines.logic.compute_bidirectional_reflectance(radiance_data, irradiance_data)[source]#

Compute the spectral bidirectional reflectance distribution function (BRDF) and bidirectional reflectance factor (BRF) from radiance and irradiance records.

Parameters:
  • radiance_data (DataArray) – Radiance record.

  • irradiance_data (DataArray) – Irradiance record.

Returns:

dict – A dictionary with the following content:

brdfxarray.DataArray

A BRDF data array.

brfxarray.DataArray

A BRF data array.

Notes

This function is expanded to brdf and brf nodes during pipeline assembly.

eradiate.pipelines.logic.extract_irradiance(mode_id, illumination, spectral_set)[source]#

Derive an irradiance dataset from the irradiance spectrum of an illuminant, as well as solar angles.

Parameters:
  • mode_id (str) – Eradiate mode for which this pipeline step is to be configured.

  • illumination (Illumination) – The illuminant whose irradiance is to be evaluated.

  • spectral_set (WavelengthSet or BinSet) – Spectral set driving the simulation.

Returns:

dict – A dictionary with the following content:

irradiancexarray.DataArray

A spectral irradiance data array compatible with processed spectral radiance records and suitable for deriving BRDF data.

solar_anglesxarray.Dataset or None

If relevant, a dataset holding solar angles.

Notes

This function is expanded into irradiance and solar_angles nodes during pipeline assembly.

eradiate.pipelines.logic.gather_bitmaps(mode_id, var_name, var_metadata, bitmaps, viewing_angles, solar_angles)[source]#

Gather a collection of Mitsuba bitmaps into xarray data arrays.

Parameters:
  • mode_id (str) – Eradiate mode from which this pipeline step is configured.

  • var_name (str) – Name of the processed physical variable.

  • var_metadata (dict) – A metadata dictionary to be attached to the data array holding the processed physical variable.

  • bitmaps (dict) – A dictionary mapping spectral loop indexes to the corresponding bitmap. Dictionary structure is as follows:

    {
        <loop_index_0>: {
            {"bitmap": <bitmap_0>},
            {"spp": <sample_count_0>},
        },
        <loop_index_1>: {
            {"bitmap": <bitmap_1>},
            {"spp": <sample_count_1>},
        },
        ...
    }
    
  • viewing_angles (Dataset, optional) – A dataset holding the viewing angles associated with each pixel in the processed bitmaps.

  • solar_angles (Dataset, optional) – A dataset holding the solar angles associated with the processed observation data.

Returns:

data_vars (dict[str, DataArray]) – A dictionary mapping data variable names to a corresponding data array. These can easily be aggregated into an xarray dataset, or scattered around other nodes of the post-processing pipeline.

eradiate.pipelines.logic.radiosity(sector_radiosity)[source]#

Aggregate sector radiosity into a full-hemisphere radiosity dataset.

Parameters:

sector_radiosity (DataArray) – Radiosity values for the hemisphere sector corresponding to each film pixel. This quantity is expressed in spectral flux units (typically W/m²/nm) and, when summed over the entire film, aggregates into a spectral radiosity (W/m²/nm).

Returns:

DataArray – A global radiosity record, with no film pixel / viewing angle indexing left.

eradiate.pipelines.logic.spectral_response(srf)[source]#

Evaluate a spectral response function as a data array.

Parameters:

srf (Spectrum) – The spectral function to be evaluated.

Returns:

DataArray – A data array mapping SRF values against the wavelength. To avoid confusion with the spectral coordinate, the wavelength dimension is here named srf_w.

eradiate.pipelines.logic.viewing_angles(angles)[source]#

Collect viewing angles associated with each film pixel from the measure, if relevant.

Parameters:

angles (ndarray) – An array with shape (m, n, 2) containing the processed measure’s viewing angles in degree. Typically obtained by calling DistantMeasure.viewing_angles().

Returns:

Dataset – An xarray dataset holding viewing angle values indexed by film coordinates.