openghg_inversions.rhime.co2.co2_o2_model#
Explicit PyMC graph for the CO2/O2 recipe.
- openghg_inversions.rhime.co2.co2_o2_model.build_co2_o2_model(*, observations: DataArray, fixed_prior_contribution: DataArray, co2_sensitivity: DataArray, o2_sensitivity: DataArray, aggregation_error: AggregationError, retained_prior: CorrelatedLognormalPrior, independent_error_sd: DataArray, state_activity: StateActivity | None = None, output_dim: str = 'observation') Model#
Build the shared-state CO2/O2 affine model and fixed-error likelihood.
fixed_prior_contribution, both channel sensitivities, the retained prior, and every block ofaggregation_errormust be products of the same coherent reduction. CO2 and O2 retain separate sensitivity row axes because their numeric units are declared independently for every row. The Verification Games replay uses ppm for both channels; other scientific O2 products may, for example, use per meg. Sensitivity rows must already be expressed in their declared channel units per dimensionless flux scaling; covariance blocks use the corresponding row-by-column unit products, including the CO2/O2 cross-covariance.The O2 sensitivity unconditionally embeds the fixed, signed O2-per-CO2 oxidation ratios declared by CO2/O2 preparation. The two channel sensitivities are therefore gathered and applied to the raw shared state once. A recipe starting from a ratio-free O2 sensitivity would need to apply its labelled species/state ratio factor before constructing that joint sensitivity.
The prepared-input runner validates the external
independent_error_sdas finite and positive. Direct custom callers own that check, exact label alignment, row-unit consistency, coherent covariance provenance, and the embedded-ratio contract before calling this lower-level builder.- Parameters:
observations – Joint CO2-then-O2 observation vector on
output_dim, with row-wise species and unit coordinates.fixed_prior_contribution – Joint coherent affine intercept on the same observation axis and in the corresponding row units.
co2_sensitivity – CO2 sensitivity with its channel observation axis first and the retained-prior state axis second.
o2_sensitivity – O2 sensitivity with its distinct channel observation axis first and the same state axis; its shared-state columns already embed the fixed oxidation ratios.
aggregation_error – Joint fixed aggregation covariance, including its cross-channel block.
retained_prior – Correlated arithmetic-moment prior for the one state vector shared by both channels.
independent_error_sd – Joint per-row independent standard deviations in each observation row’s native units.
state_activity – Optional labelled policy fixing or activating retained states.
output_dim – Joint observation dimension used by the likelihood.
- Returns:
A registered PyMC model containing the shared state, gathered joint linear signal, coherent affine intercept, and joint Gaussian likelihood.
- Raises:
ValueError – If shared-state sensitivity preparation, activity resolution, or registered coordinate alignment fails.
- openghg_inversions.rhime.co2.co2_o2_model.evaluate_co2_o2_prior_forward_mean(*, fixed_prior_contribution: DataArray, co2_sensitivity: DataArray, o2_sensitivity: DataArray, retained_prior: CorrelatedLognormalPrior, state_activity: StateActivity | None = None, output_dim: str = 'observation') DataArray#
Evaluate the reduced model so callers can verify prior-forward preservation.
- Parameters:
fixed_prior_contribution – Joint coherent-reduction intercept on
output_dim.co2_sensitivity – CO2 retained-state sensitivity with its own observation dimension and the retained-prior state dimension.
o2_sensitivity – O2 retained-state sensitivity with a distinct observation dimension and the same retained-prior state dimension.
retained_prior – Correlated retained-state arithmetic moments.
state_activity – Optional labelled policy fixing or activating retained states. Structural zero columns are inactive in both channels.
output_dim – Dimension of the returned joint observation vector.
- Returns:
The labelled joint prior-forward concentration
fixed_prior_contribution + H_joint @ prior_state.- Raises:
ValueError – If the channel sensitivities cannot form one shared-state sensitivity or
state_activitydoes not align with that state.