osmose.community_metricsΒΆ

Community-level ecosystem-state diagnostics from OSMOSE output.

Adds the canonical Sheldon (body-mass) normalized biomass spectrum (NBSS) and a suite of community indicators β€” Mean Trophic Level / Marine Trophic Index, community totals + size diversity, and the Warwick Abundance-Biomass Comparison (ABC) W-statistic β€” on top of the length spectrum in osmose.size_spectrum.

The Sheldon spectrum needs body MASS; OSMOSE writes by-LENGTH size classes, so we convert per species via the config length-weight law W = a * L^b. Each unit fails soft (records a note, returns degraded values) rather than raising past the orchestrator. See docs/superpowers/specs/2026-06-17-community-size-spectrum-extension-design.md.

Functions

community_report(output_dir[, config, ...])

Assemble the full community diagnostics bundle; each unit degrades to None on missing input (recording a top-level note) rather than raising.

compute_abc(output_dir, *[, prefix, ...])

Warwick Abundance-Biomass Comparison W-statistic + cumulative dominance curves.

compute_sheldon_spectrum(output_dir, config, *)

Canonical Sheldon NBSS over equal log2 (octave) body-mass bins + derived metrics.

compute_trophic_indicators(output_dir, *[, ...])

Biomass-weighted community Mean Trophic Level + Marine Trophic Index.

format_community_report(diag)

Markdown summary of whichever community-diagnostic sections are present.

Classes

ABCResult(w_statistic, ranks, ...)

CommunityDiagnostics(sheldon, trophic, abc, ...)

SheldonSpectrum(metric, mass_bin_edges, ...)

TrophicIndicators(mtl, mti, mti_tl_cutoff, ...)