API documentation for the litter_model module

The litter_model module creates a LitterModel class as a child of the BaseModel class. At present a lot of the abstract methods of the parent class (e.g. setup() and 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 (e.g. timedelta64) 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.

Classes:

LitterModel(data, core_components[, ...])

A class defining the litter model.

class virtual_ecosystem.models.litter.litter_model.LitterModel(data: Data, core_components: CoreComponents, model_constants: LitterConsts = LitterConsts(), **kwargs: Any)

A class defining the litter model.

This model can be configured based on the data object and a config dictionary. At present the underlying model this class wraps is quite simple (i.e. two litter pools), but this will get more complex as the Virtual Ecosystem develops.

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 litter model.

Methods:

cleanup()

Placeholder function for litter model cleanup.

from_config(data, core_components, config)

Factory function to initialise the litter model from configuration.

setup()

Placeholder function to setup up the litter model.

spinup()

Placeholder function to spin up the litter model.

update(time_index, **kwargs)

Calculate changes in the litter pools and use them to update the pools.

Attributes:

model_constants

Set of constants for the litter model.

surface_layer_index

The layer in the data object representing the surface layer.

top_soil_layer_index

The layer in the data object representing the first soil layer.

cleanup() None

Placeholder function for litter 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) LitterModel

Factory function to initialise the litter 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 litter model.

model_timing: ModelTiming

The ModelTiming details used in the model.

model_update_bounds: tuple[pint.Quantity, pint.Quantity] = (<Quantity(30, 'minute')>, <Quantity(3, '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, ...]], ...] = (('litter_pool_above_metabolic', ('spatial',)), ('litter_pool_above_structural', ('spatial',)), ('litter_pool_woody', ('spatial',)), ('litter_pool_below_metabolic', ('spatial',)), ('litter_pool_below_structural', ('spatial',)), ('lignin_above_structural', ('spatial',)), ('lignin_woody', ('spatial',)), ('lignin_below_structural', ('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

Placeholder function to setup up the litter model.

spinup() None

Placeholder function to spin up the litter model.

surface_layer_index: int

The layer in the data object representing the surface layer.

top_soil_layer_index: int

The layer in the data object representing the first soil layer.

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

Calculate changes in the litter pools and use them to update the pools.

Parameters:

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

vars_updated: tuple[str, ...] = ('litter_pool_above_metabolic', 'litter_pool_above_structural', 'litter_pool_woody', 'litter_pool_below_metabolic', 'litter_pool_below_structural', 'lignin_above_structural', 'lignin_woody', 'lignin_below_structural', 'litter_C_mineralisation_rate')

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.