libera_utils.footprint_matching.aggregation.aggregate_sample_variables#
- libera_utils.footprint_matching.aggregation.aggregate_sample_variables(reader_cls: type[AncillaryReader], samples: SampleSet, weight_field: WeightField) dict[str, float]#
Aggregate one footprint’s samples from one source to one scalar per product variable.
For the given reader, this picks the correct value row for each product variable (see
_map_product_specs), dispatches to that variable’s aggregation strategy with the PSFweight_field, and returns the single scalar the product stores – keyed by the bare spec name (the caller prefixes it with<READER_KEY>_to form the product variable name).An empty or all-NaN sample set yields NaN for every variable (the aggregation strategies return NaN when nothing is usable), which is the signal for a region the source does not cover.
- Parameters:
reader_cls (type[AncillaryReader]) – The reader class whose product variables to compute.
samples (SampleSet) – The native samples inside this footprint’s PSF bounding box.
weight_field (WeightField) – Per-sample PSF weights aligned to
samples.lats/samples.lons.
- Returns:
{spec.name: scalar}for every variable inreader_cls.product_variable_specs().- Return type:
- Raises:
ValueError – If a product variable cannot be mapped to a read variable or names an unregistered aggregation (see
_map_product_specs); ifsamples.valuesis not(len(reader_cls.VARIABLES), samples.n_samples); or ifweight_field.weightsdoes not hold one weight per sample.
Notes
Only the scalar each strategy yields is returned, so this dispatches to the strategy cores directly rather than through
aggregate(). Coverage is the weigher’s (WeightField.coverage, scored bycheck_coverage()), not computed here. Because many product variables derive from the same data plane – a variable and its_Standard_Deviationcompanion, or IGBP’s four ranked-mode scenes off oneSurface_Typeplane – the per-plane_usablemask (continuous) and category histogram (categorical) are computed once and reused across those variables.