xpectra.weathering

Band-ratio weathering indicators (carbonyl index) and composition tables.

Two important caveats, both demonstrated in the study:

  1. spectral_moments normalization centers intensities around zero, so raw integrated band areas can be negative and a naive band ratio is unstable. carbonyl_index therefore per-spectrum min-max renormalizes to a positive [0, 1] scale before integrating, and floors the denominator.

  2. The carbonyl index conflates weathering with intrinsic polymer chemistry (pristine PET/PMMA have strong native C=O bands), so it is only a valid oxidation marker within a single polyolefin class (PE/PP). On this heterogeneous, multi-instrument dataset it does not cleanly separate environmental from pristine spectra — which is itself a finding: hand-crafted physical indices are unreliable across instruments, motivating data-driven OOD detection instead.

Functions

band_area(X, wavenumbers, lo, hi[, mode, ...])

Integrated area (or peak height) of a wavenumber window.

carbonyl_index(X, wavenumbers[, carbonyl, ...])

C=O band relative to the CH2-scissoring reference band.

unknown_composition(labels, class_names[, ...])

Class fractions among the unknowns, with and without abstentions.

weathering_report(ci, confidence, ood_scores)

Spearman correlations of carbonyl index vs confidence and OOD scores.

xpectra.weathering.band_area(X, wavenumbers, lo, hi, mode='area', subtract_local_baseline=True)[source]

Integrated area (or peak height) of a wavenumber window.

With subtract_local_baseline, a straight line between the window’s endpoints is removed first — the usual convention for band indices.

Parameters:
Return type:

ndarray

xpectra.weathering.carbonyl_index(X, wavenumbers, carbonyl=(1650.0, 1800.0), ref=(1420.0, 1470.0), mode='area', renormalize=True)[source]

C=O band relative to the CH2-scissoring reference band.

The default bands match TrustConfig.carbonyl_band / reference_band so every call site uses one band definition unless overridden explicitly.

With renormalize=True (default), each spectrum is min-max scaled to [0, 1] first so the band areas are non-negative and the ratio is stable on moments-normalized data. See module docstring for the within-class caveat.

Parameters:
Return type:

ndarray

xpectra.weathering.weathering_report(ci, confidence, ood_scores)[source]

Spearman correlations of carbonyl index vs confidence and OOD scores.

Parameters:
Return type:

DataFrame

xpectra.weathering.unknown_composition(labels, class_names, abstain_label='ABSTAIN')[source]

Class fractions among the unknowns, with and without abstentions.

Parameters:
Return type:

DataFrame