eomatch.datatree.BuildMUDT.to_datatree

eomatch.datatree.BuildMUDT.to_datatree#

BuildMUDT.to_datatree(product_ds: Iterable[Dataset | DataTree], opt_attrs: dict | None = None, crop_to_shared_valid_extent: bool = True) → DataTree[source]#

Assemble an xarray.DataTree from a list of per-sensor datasets.

Each dataset becomes a child node named by its "collection" attribute (e.g. "LANDSAT_C2L1"). If the same collection appears more than once a numeric suffix is appended ("LANDSAT_C2L1_2", etc.).

Parameters:
  • product_ds – iterable of per-sensor datasets, each carrying a "collection" attribute identifying the STAC collection.

  • opt_attrs – additional attributes to merge into the DataTree root (e.g. {"matchup:id": matchup.stac_id}, as run() passes).

  • crop_to_shared_valid_extent – if True, crop gridded products to their shared valid-data lat/lon extent before assembling the tree (see crop_to_shared_valid_extent()). On by default.

Returns:

DataTree with one child node per sensor and, as root attributes, date_created (plus any opt_attrs) and provenance: title, summary, source (each product’s path) and history (this assembly step).

Raises:

ValueError – if product_ds is None, or – only when crop_to_shared_valid_extent is True – if two or more products’ valid-data extents don’t overlap (see crop_to_shared_valid_extent()). Both cases raise the same exception type.