openghg_inversions.hbmcmc.run_hbmcmc#

Compatibility script for running old fixedbasis-style configs through RHIME.

This entry point preserves the historical run_hbmcmc.py command-line surface for old INI files, but translates supported fixedbasis-style parameter names and calls the modern run_rhime pathway.

Run as:

$ python run_hbmcmc.py [start end -c config.ini]

e.g.

$ python run_hbmcmc.py $ python run_hbmcmc.py 2012-01-01 2013-01-01 -c hbmcmc_ch4_run.ini

start - Start of date range to use for MCMC inversion (YYYY-MM-DD) end - End of date range to use for MCMC inversion (YYYY-MM-DD) (must be after start) -c / –config - configuration file. See config/ folder for templates and examples of this input file.

If start and end are specified these will supersede the values within the configuration file, if present. If -c option is not specified, this script will look for configuration file within the acrg_hbmcmc/ directory called hbmcmc_input.ini.

To generate a config file from the template run this script as:

$ python run_hbmcmc.py -r [-c config.ini]

The MCMC run will not be executed. This will be named for your -c input or, if not specified, this will create a configuration file called hbmcmc_input.ini within your acrg_hbmcmc/ directory and exit. This file will need to be edited to add parameters for your MCMC run.

openghg_inversions.hbmcmc.run_hbmcmc.build_parser(default_config_file: Path) ArgumentParser#

Build the legacy run_hbmcmc argument parser.

openghg_inversions.hbmcmc.run_hbmcmc.extract_mcmc_type(config_file: str | Path, default: str = 'fixed_basis') str#

Find value which describes the MCMC function to use.

Checks the input configuration file the “mcmc_type” keyword within the “MCMC.TYPE” section. If not present, the default is used.

Parameters:
  • config_file – Configuration file name. Should be an .ini file.

  • default – Default keyword for MCMC function to use.

Returns:

Keyword for MCMC function to use

openghg_inversions.hbmcmc.run_hbmcmc.fixed_basis_expected_param() list[str]#

Define required parameters for openghg_inversions.hcmcmc.fixedbasisMCMC().

Expected parameters currently include:

species, sites, averaging_period, domain, start_date, end_date, outputpath, outputname

Returns:

required parameter names

Return type:

expected_param

openghg_inversions.hbmcmc.run_hbmcmc.fixedbasis_params_to_rhime(params: dict[str, Any]) dict[str, Any]#

Translate fixedbasis-style script/config parameters into RHIME arguments.

The compatibility shim deliberately stays at the entrypoint boundary: legacy config spellings are normalised here, then the modern run_rhime API performs its existing validation and spec construction.

openghg_inversions.hbmcmc.run_hbmcmc.hbmcmc_extract_param(config_file: str | Path, mcmc_type: str | None = 'fixed_basis', print_param: bool | None = True, **command_line)#

Extract fixedbasis-style parameters from an input configuration file.

Checks the mcmc_type to extract the required parameters.

Parameters:
  • config_file – Configuration file name. Should be an .ini file.

  • mcmc_type – Keyword for MCMC function to use. Default = “fixed_basis” (only option at present)

  • print_param – When set to True, print out extracted parameter names. Default = True

  • command_line – Any additional command line arguments to be added to the param dictionary or to supersede values contained within the config file.

Returns:

Dictionary of parameter names and values from the fixedbasis-style configuration file plus command-line overrides.

Return type:

dict

Raises:

ValueError if expected parameter is missing or has None value.

openghg_inversions.hbmcmc.run_hbmcmc.main(argv: list[str] | None = None) None#

Run fixedbasis-style configs through the modern RHIME path.

openghg_inversions.hbmcmc.run_hbmcmc.validate_rhime_params(params: dict[str, Any]) None#

Validate translated single-sector RHIME params before script side effects.