openghg_inversions.hbmcmc.preparation#
Prepare data for the temporary legacy fixedbasisMCMC workflow.
This module owns the fixed-basis compatibility contract. It composes shared
retrieval, filtering, basis, and labelled-array mechanics from
openghg_inversions.inversion_data.preparation without making that legacy
orchestration part of the modern RHIME preparation surface.
New workflows should use the named stages in
openghg_inversions.rhime.preparation.
- class openghg_inversions.hbmcmc.preparation.FixedBasisPreparedData(fp_all: dict, fp_data: dict | None = None, inv_inputs: Dataset | None = None, sites: list[str] = <factory>, averaging_period: list[str | None] = <factory>, basis_objects: dict[str, ~openghg_inversions.basis.basis_functions.FluxWeightedBasis]=<factory>, basis_artifact_source: str = 'generated', basis_artifact_path: str | None = None, is_column: bool = False)#
Bases:
objectData prepared for the legacy fixed-basis runner.
- Parameters:
fp_all – Raw merged-data container returned by data gathering or reload.
fp_data – Forward-model data after basis functions and filters.
inv_inputs – Canonical inversion inputs consumed by the legacy model.
sites – Retained site names after data gathering and filtering.
averaging_period – Averaging periods aligned to retained sites.
basis_objects – Basis objects returned by
basis_functions_wrapper.basis_artifact_source – Source of the flux basis artifact.
basis_artifact_path – Path to the flux basis artifact, when loaded or saved.
is_column – Whether any retained observation is a column observation.
- basis_objects: dict[str, FluxWeightedBasis]#
- openghg_inversions.hbmcmc.preparation.prepare_fixedbasis_inversion_data(*, species: str, sites: list[str], domain: str, averaging_period: Sequence[str | None] | str | None, start_date: str, end_date: str, output_name: str, flux_sources: list[str] | None, split_by_sectors: bool = False, bc_store: str = 'user', obs_store: str = 'user', footprint_store: str = 'user', emissions_store: str = 'user', met_model: Sequence[str | None] | str | None = None, fp_model: str | None = None, fp_height: Sequence[str | None] | str | None = None, fp_species: str | None = None, inlet: Sequence[str | slice | None] | str | None = None, instrument: Sequence[str | None] | str | None = None, max_level: Sequence[int | None] | int | None = None, calibration_scale: str | None = None, obs_data_level: Sequence[str | None] | str | None = None, platform: Sequence[str | None] | str | None = None, use_tracer: bool = False, use_bc: bool = True, fp_basis_case: str | None = None, basis_directory: str | None = None, bc_basis_case: str = 'NESW', bc_basis_directory: str | Path | None = None, country_directory: str | None = None, bc_input: str | None = None, basis_algorithm: str = 'weighted', nbasis: int = 100, filters: Any = None, fix_basis_outer_regions: bool = False, averaging_error: bool = True, bc_freq: str | None = None, sigma_freq: str | None = None, reload_merged_data: bool = False, save_merged_data: bool = False, merged_data_dir: str | None = None, merged_data_name: str | None = None, basis_output_path: str | None = None, min_error: Literal['percentile', 'residual'] | dict[str, float] | None | int | float = 0.0, calculate_min_error: Literal['percentile', 'residual'] | None = None, min_error_options: Mapping[str, Any] | None = None, return_basis_objects: bool = False, merged_data_only: bool = False, flux_non_finite_check: Literal['lazy', 'count'] = 'lazy') FixedBasisPreparedData#
Prepare data for legacy
fixedbasisMCMCand its output adapters.This adapter preserves the fixed-basis inversion-input contract. Unless
merged_data_onlyis true, the returnedinv_inputsincludessigma_freq_index(nmeasure)derived fromsigma_freqand anchored tostart_date. Modern RHIME preparation intentionally omits this component-specific variable.- Parameters:
sites – Requested observation site names. At least one unique site is required.
averaging_period – Observation averaging period, either scalar or aligned to
sites.inlet – Inlet selector, either scalar or aligned to
sites. Entries may be strings, legacysliceselectors, orNone.fp_height – Footprint inlet height, either scalar or aligned to
sites.instrument – Observation instrument, either scalar or aligned to
sites.platform – Observation platform, either scalar or aligned to
sites.obs_data_level – Observation data level, either scalar or aligned to
sites.met_model – Footprint meteorological model, either scalar or aligned to
sites.max_level – Maximum column level, either scalar or aligned to
sites. Entries must be integers orNone.min_error – Numeric minimum error or
"residual"/"percentile"calculation method.calculate_min_error – Deprecated calculation-method spelling.
min_error_options – Calculated minimum-error options. The only supported key is boolean
by_site.
- Returns:
Prepared legacy data, including forward-model inputs and optional basis objects. When
merged_data_onlyis true, only merged data and retained site metadata are populated.- Raises:
ValueError – If site options are empty, duplicated, misaligned, or have invalid types, or if minimum-error options are invalid.
- Warns:
FutureWarning – If deprecated
calculate_min_erroris supplied.