Base API

Module containing the base for model implementations

class openscm_twolayermodel.base.Model

Bases: abc.ABC

Base class for model implementations

reset()

Reset everything so that a new run can be performed.

Called as late as possible before run().

run()

Run the model.

abstract set_drivers(*args, **kwargs)

Set the model’s drivers

step()

Do a single time step.

class openscm_twolayermodel.base.TwoLayerVariant

Bases: openscm_twolayermodel.base.Model

Base for variations of implementations of the two-layer model

property delta_t

pint.Quantity Time step for forward-differencing approximation

property erf

pint.Quantity Effective radiative forcing

reset()

Reset everything so that a new run can be performed.

Called as late as possible before run().

run()

Run the model.

run_scenarios(scenarios, driver_var='Effective Radiative Forcing', progress=True)

Run scenarios.

The model timestep is automatically adjusted based on the timestep used in scenarios. The timestep used in scenarios must be constant because this implementation has a constant timestep. Pull requests to upgrade the implementation to support variable timesteps are welcome https://github.com/openscm/openscm-twolayermodel/pulls.

Parameters
  • scenarios (ScmDataFrame or ScmRun or pyam.IamDataFrame or pd.DataFrame or np.ndarray or str) – Scenarios to run. The input will be converted to an ScmRun before the run takes place.

  • driver_var (str) – The variable in scenarios to use as the driver of the model

  • progress (bool) – Whether to display a progress bar

Returns

Results of the run (including drivers)

Return type

ScmRun

Raises

ValueError – No data is available for driver_var in the "World" region in scenarios.

set_drivers(erf)

Set drivers for a model run

Parameters

erf (pint.Quantity) – Effective radiative forcing (W/m^2) to use to drive the model

Raises

AssertionErrorerf is not one-dimensional

step()

Do a single time step.