libera_utils.footprint_matching.aggregation#
PSF aggregation engine: collapse a footprint’s native samples to one value.
Where this sits in the pipeline#
This is the last core-processing stage of footprint matching. Upstream, a reader
has served the native SampleSet
inside a footprint’s PSF bounding box, and the
weighting module has assigned each sample
a PSF weight. This module takes those (values, weights) and produces a single
statistic per variable – the number that lands in the SSF-style output product.
It is the only place a sample’s value is combined with another’s.
Two layers#
Pure strategy functions (
weighted_mean,weighted_mode,weighted_log_mean…). Each takes 1-Dvaluesandweightsarrays and returns a smalldictof named sub-results, following the methods in design doc section 2.8.1.4. These are reusable by scientists directly and are what the unit tests exercise. NaN values are excluded from every computation (doc: “NaN values are excluded from all computations”).A product-facing projection (
aggregate_sample_variables()) that walks a reader’s product variable specifications, picks the right value row for each, dispatches to the correct strategy, and returns the single scalar the product definition stores for that variable, once per footprint per source.stack_product_values()then collects a reader’s stacked specs (itsPRODUCT_STACKS, e.g. ERA5 pressure levels) into one array per stacked product variable.
CERES heritage#
The weighted statistics implement CERES ATBD v2.2 Eq. 4.4-17
xbar = sum(w*x) / sum(w) and its companions, and follow the CERES SSF
convention of log-space averaging for pixel cloud optical depth. See
https://ceres.larc.nasa.gov/documents/ATBD/pdf/r2_2/ceres-atbd2.2-s4.4.pdf
Optical depth is averaged in log space only where the samples are imager pixels, as
CERES does when it convolves pixels into a footprint (see weighted_log_mean()).
An optical depth a source has already averaged over its own footprint or grid cell,
and every aerosol optical depth, is combined with the arithmetic mean: CERES takes “an
arithmetic mean … of all imager pixels in the angular bin before they are weighted
by the PSF” for aerosol optical depth (SSF-137, CERES SSF Collection Guide, Release 2,
p. 101, https://ceres.larc.nasa.gov/documents/collect_guide/pdf/SSF_CG_R2V1.pdf).
Functions
|
Run a named aggregation strategy and wrap it with sample bookkeeping. |
|
Aggregate one footprint's samples from one source to one scalar per product variable. |
|
Apply the CERES 75%/95% coverage rule. |
|
Shape one footprint's per-spec scalars from one source into its product variables. |
|
PSF-weighted geometric mean |
|
PSF-weighted mean |
|
PSF-weighted mode |
|
Most common category by PSF weight (rank 0). |
|
Second most common category by PSF weight (rank 1). |
|
Third most common category by PSF weight (rank 2). |
|
PSF-weighted standard deviation over the strictly positive samples. |
|
PSF-weighted standard deviation |
Classes
|
Output of a single aggregation, with sample bookkeeping. |