libera_utils.footprint_matching.product.assemble_fmatch_dataset#
- libera_utils.footprint_matching.product.assemble_fmatch_dataset(mode: OperationalMode, inputs: Sequence[PseudoFootprint] | dict[str, np.ndarray], *, definition: LiberaDataProductDefinition | None = None, algorithm_version: str | None = None, input_files: str | None = None, cloud_fraction_camera: np.ndarray | None = None, source_file_paths: dict[str, Sequence[Path]] | None = None, sources: dict[str, AncillaryReader] | None = None, weigher: PixelWeigher | None = None, allow_placeholders: bool = False) Dataset#
Assemble a conformant FMATCH
xarray.Datasetfor an operational mode.Combines the per-footprint geolocation inputs, the derived viewing geometry from
compute_derived_viewing_geometry(), and the aggregated external variables fromaggregate_external_variables()into the variable dict expected by the mode’s product definition (fromload_fmatch_definition()), then builds the Dataset once viaLiberaDataProductDefinition.create_product_dataset, withalgorithm_versionandInputGranulesas its dynamic attributes, and brings it into conformance withenforce_dataset_conformance.Dispatch is by timescale, because that determines what the mode is built from:
Camera-timescale (
CAM_CAMTIME,IMAGER_CAMTIME) - assembled from the camera pseudo-footprints segmented by the Camera Cloud Fraction algorithm and read from its CF-CAM-CAMTIME product.inputsis that sequence ofPseudoFootprintobjects. See_assemble_camtime_dataset.Radiometer-timescale (
CAM,IMAGER) - assembled from the L1B pass-through arrays the FMATCH runner reads from L1B Daily.inputsis that dict. See_assemble_radiometer_dataset.
In both cases the derived viewing geometry (
Sunglint_Angle) is always computed from the real geolocation angles. The external aggregated variables and the coverage/QA columns are computed from the ancillary inputs (sourcesorsource_file_paths, forwarded toaggregate_external_variables()). A declared variable no input produced raises, unlessallow_placeholders=Trueasks for it to be written as a conformant placeholder. Columns are named as the product definition declares them.- Parameters:
mode (OperationalMode) – The FMATCH operational mode being assembled.
inputs (Sequence[PseudoFootprint] or dict[str, np.ndarray]) – Camera pseudo-footprints for the camera-timescale modes, or the L1B dict (keyed by L1B names) for the radiometer-timescale modes.
definition (LiberaDataProductDefinition, optional) – The product definition. Loaded via
load_fmatch_definition()when omitted.algorithm_version (str, optional) – Value for the dynamic
algorithm_versionglobal attribute. Writing the product requires it; assembly alone does not.input_files (str, optional) – Provenance string for the dynamic
InputGranulesglobal attribute. Writing the product requires it; assembly alone does not.cloud_fraction_camera (np.ndarray, optional) – Per-footprint cloud fraction from the Camera Cloud Fraction (CF-CAM) algorithm (Libera WFOV camera), in percent
[0, 100]withNaNfor a missing value, as a 1-D array indexed by footprint in the same order as the time coordinate. This is an internal algorithm output - it does not come from a reader and is already aggregated to one value per footprint - so it is merged directly into theCloud_Fraction_Cameravariable rather than going throughaggregate_external_variables(). Only the CAM modes (CAM,CAM_CAMTIME) declare this variable: it is required for them unlessallow_placeholdersisTrue, and must beNonefor the IMAGER modes.source_file_paths (dict[str, Sequence[Path]], optional) – Reader-key -> staged ancillary granule(s) map the sources are built from. Pass this or
sources, not both.sources (dict[str, AncillaryReader], optional) – Pre-built readers to aggregate from, keyed by reader registry key: exactly the readers active in
mode. Pass this orsource_file_paths, not both.weigher (PixelWeigher, optional) – PSF weigher for the aggregation. Defaults to
AngularPSFWeigher(seeaggregate_external_variables()).allow_placeholders (bool, optional) – When
True, a declared variable no input produced is written as fill instead of raising: the external,PSF_Coverage_FractionandQuality_Flagcolumns when neithersourcesnorsource_file_pathsis given, a reader’s columns when its source is missing, andCloud_Fraction_Camerawhencloud_fraction_camerais omitted for a CAM mode. Defaults toFalse.
- Returns:
A dataset brought into conformance with the mode’s product definition.
- Return type:
- Raises:
ValueError – If
inputsis empty; if the radiometer-timescaleinputsdict is missing a required L1B key or its arrays have inconsistent lengths; if neithersourcesnorsource_file_pathsis given andallow_placeholdersisFalse, or both are given; ifcloud_fraction_camerais omitted for a CAM mode withoutallow_placeholders, given for an IMAGER mode, not one value per footprint, or has a finite value outside[0, 100]; if any other declared variable no input produced is left withoutallow_placeholders; if a footprint has no finite viewing zenith angle, or no usable cone-angle rate under the default weigher; if a camera-timescale mode is aggregated, since camera pseudo-footprints carry no L1B ephemeris; if a footprint’s time is NaT and a source selects by time; or if assembly produces a column the definition does not declare.KeyError – If the keys of
sourcesorsource_file_pathsare not exactly the readers active inmode.MissingGeolocationError – If a radiometer record’s ephemeris is unusable or its footprint is not visible from the satellite (see
build_radiometer_footprints()).