libera_utils.footprint_matching.sources.build_sources#

libera_utils.footprint_matching.sources.build_sources(mode: OperationalMode, source_file_paths: dict[str, Sequence[Path]]) → dict[str, AncillaryReader]#

Instantiate the readers active for mode over their staged granules.

Selects the active reader classes via get_readers_for_mode() and instantiates each with the granule paths supplied in source_file_paths. This is the single construction path the product code calls, so the reader wiring lives in one place. Each reader checks at construction that its staged granules exist but opens none of them, so an unreadable staged file raises from the first samples_in() call that loads it.

Parameters:
  • mode (OperationalMode) – Operational mode whose active readers should be built.

  • source_file_paths (dict[str, Sequence[Path]]) – Mapping of reader registry key to the staged local granules for that source. Its keys must be exactly the readers active in mode.

Returns:

Reader registry key to instantiated reader, one entry per source active in mode.

Return type:

dict[str, AncillaryReader]

Raises:
  • KeyError – If source_file_paths holds a key for a source mode does not use, or is missing an entry for any active reader.

  • TypeError – If an entry is a single str or Path rather than a sequence of them.

  • ValueError – If an entry holds no granule.

  • FileNotFoundError – If any staged granule path is not an existing file.