openghg_inversions.inversion_data.preparation#
Shared runner-level inversion data preparation.
This module separates legacy fixedbasis preparation from the modern RHIME
prepared-input contract. New RHIME callers use flux_sources to name OpenGHG
flux source metadata values, while lower-level compatibility helpers still
pass those values through older emissions_name parameters internally.
species is the primary gas or tracer name used for object-store lookup and
output naming. use_tracer is retained as an explicit unsupported option for
the current RHIME preparation path because tracer inversions require linked
forward models that are not represented here.
- class openghg_inversions.inversion_data.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)#
Bases:
objectData prepared for the legacy fixedbasis 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 model builders.
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.
- basis_objects: dict[str, FluxWeightedBasis]#
- class openghg_inversions.inversion_data.preparation.RhimePreparedInputs(inv_inputs: Dataset, basis_functions: FluxWeightedBasis, sites: tuple[str, ...], averaging_period: tuple[str | None, ...], basis_artifact_source: str, basis_artifact_path: str | None = None, site_lats: tuple[float, ...] | None = None, site_lons: tuple[float, ...] | None = None)#
Bases:
objectModern RHIME preparation contract.
- Parameters:
inv_inputs – Canonical inversion inputs consumed by RHIME model builders.
basis_functions – Retained flux basis object used to derive output-boundary basis and flux arrays.
sites – Retained site names after data gathering and filtering.
averaging_period – Averaging periods aligned to retained sites.
basis_artifact_source – Description of whether the basis was generated or loaded from an artifact.
basis_artifact_path – Path to the basis artifact, when loaded or saved.
site_lats – Release latitudes aligned to
sites, when available.site_lons – Release longitudes aligned to
sites, when available.
- basis_functions: FluxWeightedBasis#
- openghg_inversions.inversion_data.preparation.prepare_fixedbasis_inversion_data(*, species: str, sites: list[str], domain: str, averaging_period: list[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: Any = None, fp_model: str | None = None, fp_height: Any = None, fp_species: str | None = None, inlet: Any = None, instrument: Any = None, max_level: int | None = None, calibration_scale: str | None = None, obs_data_level: Any = None, platform: Any = 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: dict | 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 fixedbasisMCMC and its output adapters.
- openghg_inversions.inversion_data.preparation.prepare_rhime_inputs(*, species: str, sites: list[str], domain: str, averaging_period: list[str | None] | str | None, start_date: str, end_date: str, output_name: str, flux_sources: list[str], split_by_sectors: bool = False, bc_store: str = 'user', obs_store: str = 'user', footprint_store: str = 'user', emissions_store: str = 'user', met_model: Any = None, fp_model: str | None = None, fp_height: Any = None, fp_species: str | None = None, inlet: Any = None, instrument: Any = None, max_level: int | None = None, calibration_scale: str | None = None, obs_data_level: Any = None, platform: Any = 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, min_error_options: dict | None = None, flux_non_finite_check: Literal['lazy', 'count'] = 'lazy') RhimePreparedInputs#
Prepare modern RHIME inputs without exposing legacy fixedbasis containers.
- Parameters:
species – Primary gas or tracer name used for object-store lookup and output naming.
sites – Requested observation site names.
domain – Model domain name.
averaging_period – Observation averaging period, either scalar or site-aligned.
start_date – Inclusive inversion start date.
end_date – Exclusive inversion end date.
output_name – Base output name used for data and basis artifacts.
flux_sources – OpenGHG flux
sourcevalues requested for the run.split_by_sectors – Whether to keep sector-resolved sensitivity inputs with a
sourcecoordinate.use_tracer – Unsupported placeholder for tracer inversions, where an additional species constrains the primary species through linked forward models.
flux_non_finite_check – Non-finite flux handling mode.
"lazy"applies zero-fill lazily and records attrs;"count"computes count metadata once and warns if non-finite values are present.
- Returns:
Modern RHIME prepared inputs containing canonical
inv_inputsand a retainedBasisFunctionsobject.