Skip to main content

Perform calibration for simple climate models

Project description

scmcallib is a tool to make it easy to derive parameter sets for Simple Climate Models (SCMs). At the moment, the two focus use cases are:

  • “emulation” of other, typically more complex and computationally expensive models

  • “calibration” to observations i.e. the derivation of parameter sets which allow the SCM response to span the range of uncertainty of historical observations

This package fits into a wider ecosystem of tools which are aiming to create a transparent and reproducible way of generating parameter sets for a wide range of SCMs, observations and climate model outputs in a number of use cases. scmcallib uses scmdata and netcdf-scm to make it easy to interface to a range of SCMs and climate model output, hiding the complexity of running these ‘simple’ climate models and processing complex model output.

Getting Started

A number of the libraries used in scmcallib require compiled libraries and other system dependencies. To make it easier to get started with this project it is recommended to set up a new Conda environment to isolate these libraries. As this package is not currently installable via pypi, you have to install it from source.

$ git clone git://gitlab.com/magicc/scmcallib
$ cd scmcallib
$ conda env create --name scmcallib --file environment.yml
$ conda activate scmcallib
$ pip install -e .

Having installed, the scmcallib package is ready to generate parameter sets.

Emulation

Emulation is the process of finding a set of parameters which best fit output from another model. Once this best fit point in parameter space has been found, the SCM provides a computationally cheap method for exploring how the these larger models would respond under various scenarios.

TODO: Add documention about extracting

Before we can start emulating a model we must define the initial guess of the parameter distributions (i.e. the priors), for the parameters that are being constrained.

[TODO: decide whether to put this example in e.g. a notebook so it’s under CI]

from scmcallib import ParameterSet

best_guess_c1 = 0.631
best_guess_c2 = 0.429
best_guess_a1 = 0.2240

param_set = ParameterSet()
param_set.set_tune('c1', Bound(Normal(mu=best_guess_c1, sd=1.), lower=0.1))
param_set.set_tune('c2', Bound(Normal(mu=best_guess_c2, sd=0.1), lower=0.1))
param_set.set_tune('a1', Bound(Normal(mu=best_guess_a1, sd=0.1), lower=0.0, upper=0.4))

Once we have the data and parameters which describe how the model will be constrained, we can instantiate the PointEstimateFinder. In this example we are using the A5IR SCM [TODO: fill out AR5IR SCM so it actually is the full things], a basic, but very fast model to speed up to emulation process. The first step in emulation is finding the initial starting point for optimisation. This start point is then used by the optimiser to find the point in parameter space which minimise the differences between the SCM output and the target timeseries (typically taken from a more complex model).

from scmcallib import PointEstimateFinder
from scmcallib.scm import AR5IR_SCM
emulator = PointEstimateFinder(param_set, reference_period=(2000, 2010))
emulator.set_target(observed=observed_gmt)

with AR5IR_SCM() as scm:
    results = emulator.find_best_fit(scm, optimiser_name='bayesopt')

results.plot_summary()
results.plot_fit()

scmcallib provides a method for reading tuningcore files which are used by simcap to describe how to tune magicc.

Calibration

Run simple calibration example

  • edit calibration.py and run_calibration.py to fit your personal settings

  • then run python run_calibration.py

  • visualise with notebooks/show_calibration.ipynb

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scmcallib-0.5.0b1.tar.gz (71.8 kB view details)

Uploaded Source

Built Distribution

scmcallib-0.5.0b1-py2.py3-none-any.whl (56.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file scmcallib-0.5.0b1.tar.gz.

File metadata

  • Download URL: scmcallib-0.5.0b1.tar.gz
  • Upload date:
  • Size: 71.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0.post20200113 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for scmcallib-0.5.0b1.tar.gz
Algorithm Hash digest
SHA256 685935e766ea45662f8f88e01a4d284bf2426558462341d1bc24b392697240b8
MD5 4c4f091823d49f336395aa4837cc2476
BLAKE2b-256 c2bdd9f12e4c9ff376cab271d2946a661b666843c41dcaf9c3308ad09417d7d1

See more details on using hashes here.

Provenance

File details

Details for the file scmcallib-0.5.0b1-py2.py3-none-any.whl.

File metadata

  • Download URL: scmcallib-0.5.0b1-py2.py3-none-any.whl
  • Upload date:
  • Size: 56.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0.post20200113 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for scmcallib-0.5.0b1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d467df45d0939a8cd3e6df936b531b9f0533b66d4ba8baaee80a356aebf25841
MD5 95c023a8477038ac7e229d6131ca4e31
BLAKE2b-256 a66974551eadada89dded32d94654dcf7c908e99c29cfc2443b82686cd1e9b9a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page