openghg_inversions.rhime.co2.co2_model#

Concrete PyMC graph for the CO2 coherent-reduction recipe.

The recipe is deliberately procedural. It samples one labelled retained state, applies the reduced observation operator, adds the fixed affine prior contribution, and finally constructs the observation likelihood.

openghg_inversions.rhime.co2.co2_model.build_co2_model(flux_sensitivity: DataArray, *, retained_prior: CorrelatedLognormalPrior, fixed_prior_contribution: DataArray, observations: DataArray, observation_error: DataArray, minimum_error: DataArray, aggregation_error: AggregationError, sigma_alignment: SigmaAlignment | None = None, sigma_prior: dict[str, Any] | None = None, fixed_model_mismatch: float | DataArray | None = None, state_activity: StateActivity | None = None, boundary_sensitivity: DataArray | None = None, bc_prior: dict[str, Any] | None = None, bc_state_activity: StateActivity | None = None, offset_prior: dict[str, Any] | None = None, offset_args: dict | None = None) Model#

Build the CO2 coherent-reduction model from explicit scientific arrays.

flux_sensitivity is prepared once as the reduced operator H_alpha: exact-zero columns are omitted from the backend co2_sensitivity while flux_scaling retains the complete labelled scientific state. fixed_prior_contribution is then added with the shared coherent-affine component to produce modelled_concentration.

fixed_prior_contribution is the affine term H m - H_alpha (Pi m). The latter is a fixed prior contribution, not an atmospheric boundary condition. retained_prior contains the complete labelled arithmetic moments for the positive flux state.

Known fixed states remain in the public state and forward calculation but are omitted from the sampled correlated state. fixed_model_mismatch is an optional known concentration standard deviation. openghg_inversions leaves this policy unset by default; the Verification Games fixed likelihood passes 1 ppm explicitly. Inner and outer same-grid states remain in this one flux state and are distinguished by basis_group metadata retained for output-side selection. The model builds only their complete shared flux contribution. Optional boundary and offset terms remain scientifically distinct components named mu_bc and offset.

Direct custom callers are responsible for supplying scientifically coherent arrays from one preparation and for their positional semantics when labels are absent.

Parameters:
  • flux_sensitivity – Reduced CO2 sensitivity with observation dimension nmeasure and one labelled retained-state dimension.

  • retained_prior – Complete labelled arithmetic-moment prior for the retained positive state.

  • fixed_prior_contribution – Fixed coherent-reduction affine intercept named fixed_prior_contribution on nmeasure.

  • observations – Observed CO2 concentrations on nmeasure.

  • observation_error – Reported observation standard deviation.

  • minimum_error – Minimum independent model-data mismatch standard deviation.

  • aggregation_error – Prepared fixed aggregation-error representation.

  • sigma_alignment – Optional grouping policy for inferred additive model error.

  • sigma_prior – Optional prior arguments for inferred additive model error.

  • fixed_model_mismatch – Optional known scalar or labelled concentration standard deviation.

  • state_activity – Optional labelled activity policy for retained flux states.

  • boundary_sensitivity – Optional atmospheric boundary-condition sensitivity already resolved for the model, for example data.

  • bc_prior – Optional prior arguments for boundary-condition scaling.

  • bc_state_activity – Optional labelled activity policy for boundary states.

  • offset_prior – Optional prior for an offset component. When omitted, no offset is added. Site codes are derived from the site coordinate on observations.

  • offset_args – Extra keyword arguments for the offset component.

Returns:

A registered PyMC model containing the complete affine concentration and Gaussian likelihood.

Raises:

ValueError – If shared preparation, prior construction, or registered coordinate alignment fails, or if sigma_prior is supplied without sigma_alignment.