eoio.processors.units.drivers.base module#

eoio.processors.units.drivers.base - base class for unit conversion drivers

class eoio.processors.units.drivers.base.BaseUnitConversionDriver[source]#

Bases: ABC

Abstract base class for unit conversion drivers.

Subclasses implement dataset-specific conversion logic (e.g. Landsat, Sentinel-2) while exposing a common interface to the eoio processor layer.

A driver must: - declare whether it can handle a dataset via matches() - declare which conversions it supports via supported() - perform the conversion via convert()

abstractmethod convert(ds: Dataset, to: str, var_names: Sequence[str] | None, *, context: Mapping[str, Any]) Dataset[source]#

Convert variables in the dataset to the requested target units.

Implementations are responsible for: - determining the source units of each variable - reading any required metadata (from ds or context) - applying the correct conversion formula - updating variable units attributes consistently

This method must not mutate the input dataset in-place unless explicitly documented; returning a modified copy is preferred.

Parameters:
  • ds – Input dataset.

  • to – Target unit name (e.g. "radiance").

  • var_names – Names of variables to convert. If None, the driver should determine a sensible default (e.g. measurement variables only).

  • context – Processing context provided by eoio (reader metadata, resolved config, etc.).

Returns:

Dataset with converted variables.

abstractmethod matches(ds, context) bool[source]#

Determine whether this driver can handle the given dataset.

This method should be cheap and rely on unambiguous indicators, such as normalised eoio metadata (e.g. ds.attrs["eoio:product"]) or values provided in the processing context.

Parameters:
  • ds – Input dataset.

  • context – Processing context provided by eoio (reader metadata, resolved config, etc.).

Returns:

True if this driver can convert units for this dataset, otherwise False.

name: str = 'base'#
abstractmethod supported() Set[Tuple[str, str]][source]#

Return the set of supported unit conversion pairs.

Each entry is a (from_unit, to_unit) tuple using the public eoio unit vocabulary (e.g. ("reflectance", "radiance")).

Returns:

Set of supported (from_unit, to_unit) pairs.