openghg_inversions.hbmcmc.run_hbmcmc#

Wrapper script to read in parameters from a configuration file and run underlying MCMC script.

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 superceed 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.define_mcmc_function(mcmc_type: str) Callable#

Links mcmc_type name to function.

Parameters:

mcmc_type (str) – Keyword for MCMC function to use. Current option “fixed_basis” (openghg_inversions.hbmcmc.fixedbasisMCMC())

Returns:

Function

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

Find value which describes the MCMC function to use.

Checks the input configuation 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.hbmcmc_extract_param(config_file: str, mcmc_type: str | None = 'fixed_basis', print_param: bool | None = True, **command_line)#

Extract parameters from input configuration file and associated MCMC function.

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 – Went 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 superceed values contained within the config file.

Returns:

MCMC function to use, dictionary of parameter names and values passed to MCMC function

Return type:

function,collections.OrderedDict

Raises:

ValueError if expected parameter is missing or has None value.