API documentation for the abiotic_simple_model module

The abiotic_simple_model module creates a AbioticSimpleModel class as a child of the BaseModel class. At present a lot of the abstract methods of the parent class (e.g. spinup()) are overwritten using placeholder functions that don’t do anything. This will change as the Virtual Ecosystem model develops. The factory method from_config() exists in a more complete state, and unpacks a small number of parameters from our currently pretty minimal configuration dictionary. These parameters are then used to generate a class instance. If errors crop here when converting the information from the config dictionary to the required types they are caught and then logged, and at the end of the unpacking an error is thrown. This error should be caught and handled by downstream functions so that all model configuration failures can be reported as one.

TODO update temperatures to Kelvin

The AbioticSimpleModel class

class virtual_ecosystem.models.abiotic_simple.abiotic_simple_model.AbioticSimpleModel(data: Data, core_components: CoreComponents, model_constants: AbioticSimpleConsts = AbioticSimpleConsts(), **kwargs: Any)

A class describing the abiotic simple model.

Parameters:
  • data – The data object to be used in the model.

  • core_components – The core components used across models.

  • model_constants – Set of constants for the abiotic_simple model.

Attributes:

bounds

Upper and lower bounds for abiotic variables.

model_constants

Set of constants for the abiotic simple model

Methods:

cleanup()

Placeholder function for abiotic model cleanup.

from_config(data, core_components, config)

Factory function to initialise the abiotic simple model from configuration.

setup()

Function to set up the abiotic simple model.

spinup()

Placeholder function to spin up the abiotic simple model.

update(time_index, **kwargs)

Function to update the abiotic simple model.

bounds

Upper and lower bounds for abiotic variables.

cleanup() None

Placeholder function for abiotic model cleanup.

core_constants: CoreConsts

The core constants used in the model.

data: Data

A Data instance providing access to the shared simulation data.

classmethod from_config(data: Data, core_components: CoreComponents, config: Config) AbioticSimpleModel

Factory function to initialise the abiotic simple model from configuration.

This function unpacks the relevant information from the configuration file, and then uses it to initialise the model. If any information from the config is invalid rather than returning an initialised model instance an error is raised.

Parameters:
  • data – A Data instance.

  • core_components – The core components used across models.

  • config – A validated Virtual Ecosystem model configuration object.

layer_structure: LayerStructure

The LayerStructure details used in the model.

model_constants

Set of constants for the abiotic simple model

model_timing: ModelTiming

The ModelTiming details used in the model.

model_update_bounds: tuple[pint.Quantity, pint.Quantity] = (<Quantity(1, 'day')>, <Quantity(1, 'month')>)

Bounds on model update frequencies.

This class attribute defines two time intervals that define a lower and upper bound on the update frequency that can reasonably be used with a model. Models updated more often than the lower bound may fail to capture transient dynamics and models updated more slowly than the upper bound may fail to capture important temporal patterns.

required_init_vars: tuple[tuple[str, tuple[str, ...]], ...] = (('air_temperature_ref', ('spatial',)), ('relative_humidity_ref', ('spatial',)))

Required variables for model initialisation.

This class property defines a set of variable names that must be present in the Data instance used to initialise an instance of this class. It is a tuple containing zero or more tuples, each providing a variable name and then a tuple of zero or more core axes that the variable must map onto.

For example: (('temperature', ('spatial', 'temporal')),)

setup() None

Function to set up the abiotic simple model.

At the moment, this function only initializes soil temperature for all soil layers and calculates the reference vapour pressure deficit for all time steps. Both variables are added directly to the self.data object.

spinup() None

Placeholder function to spin up the abiotic simple model.

update(time_index: int, **kwargs: Any) None

Function to update the abiotic simple model.

Parameters:

time_index – The index of the current time step in the data object.

vars_updated: tuple[str, ...] = ('air_temperature', 'relative_humidity', 'vapour_pressure_deficit', 'soil_temperature', 'atmospheric_pressure', 'atmospheric_co2')

Variables that are updated by the model.

At the moment, this tuple is used to decide which variables to output from the Data object, i.e. every variable updated by a model used in the specific simulation. In future, this could also be used to prevent multiple models from updating the same variable and similar problems.