Adapter base class

class openscm.adapters.Adapter(input_parameters, output_parameters)

Bases: object

All model adapters in OpenSCM are implemented as subclasses of the openscm.adapter.Adapter base class.

Writing a model adapter provides a how-to on implementing an adapter.

A model adapter is responsible for requesting the expected input parameters (in the expected time format and units) for the particular SCM from a openscm.core.ParameterSet. It also runs its wrapped SCM and writes the output data back to a openscm.core.ParameterSet.

__init__(input_parameters, output_parameters)

Initialize.

Parameters
  • input_parameters (ParameterSet) – Input parameter set to use

  • output_parameters (ParameterSet) – Output parameter set to use

_abc_impl = <_abc_data object>
_current_time = None

Current time when using step()

abstract _initialize_model()

To be implemented by specific adapters.

Initialize the model. Called only once but as late as possible before a call to _run() or _step().

Return type

None

abstract _initialize_model_input()

To be implemented by specific adapters.

Initialize the model input. Called before the adapter is used in any way and at most once before a call to _run() or _step().

Return type

None

abstract _initialize_run_parameters()

To be implemented by specific adapters.

Initialize parameters for the run. Called before the adapter is used in any way and at most once before a call to _run() or _step().

Return type

None

_initialized = None

True if model has been initialized via _initialize_model()

_output = None

Output parameter set

_parameters = None

Input parameter set

abstract _reset()

To be implemented by specific adapters.

Reset the model to prepare for a new run. Called once after each call of _run() and to reset the model after several calls to _step().

Return type

None

abstract _run()

To be implemented by specific adapters.

Run the model over the full time range.

Return type

None

abstract _shutdown()

To be implemented by specific adapters.

Shut the model down.

Return type

None

abstract _step()

To be implemented by specific adapters.

Do a single time step.

Return type

None

initialize_model_input()

Initialize the model input.

Called before the adapter is used in any way and at most once before a call to run() or step().

Return type

None

initialize_run_parameters()

Initialize parameters for the run.

Called before the adapter is used in any way and at most once before a call to run() or step().

Return type

None

reset()

Reset the model to prepare for a new run.

Called once after each call of run() and to reset the model after several calls to step().

Return type

None

run()

Run the model over the full time range.

Return type

None

step()

Do a single time step.

Returns

Current time

Return type

np.datetime64