API documentation for the core_components
module
This submodule contains a dataclass used to generate core common components required
by models. It is used as input to the
BaseModel
, allowing single instances of
these components to be cascaded down to individual model subclass instances via the
__init__
method of the base model..
Classes:
|
Core model components. |
|
Simulation vertical layer structure. |
|
Model timing details. |
- class virtual_ecosystem.core.core_components.CoreComponents(config: InitVar[Config])
Core model components.
This dataclass takes a validated model configuration and uses it to generate a set of core model attributes, populated via the
__init__
method ofBaseModel
and hence inherited by the specific model subclasses.Methods:
__post_init__
(config)Populate the core components from the config.
Attributes:
A validated model configuration.
The core constants definitions for the simulation
The vertical layer structure for the simulation.
The model timing details for the simulation.
- core_constants: CoreConsts
The core constants definitions for the simulation
- layer_structure: LayerStructure
The vertical layer structure for the simulation.
- model_timing: ModelTiming
The model timing details for the simulation.
- class virtual_ecosystem.core.core_components.LayerStructure(config: InitVar[Config])
Simulation vertical layer structure.
This class defines the structure of the vertical dimension of the Virtual Ecosystem from a model configuration. Five values from the
core.layers
configuration section are used to define a set of vertical layers and their heights (or relative heights):canopy_layers
,soil_layers
,above_canopy_height_offset
,surface_layer_height
and``subcanopy_layer_height``. These values are validatated and then assigned to attributes of this class. Then_layers
andlayer_roles
attributes report the total number of layers in the vertical dimension and a tuple of the role of each layer within that dimension.The layer structure is shown below, along with values from the default configuration. All heights are in metres relative to ground level and the canopy layer heights are defined dynamically by the
PlantsModel
.Index
Role
Description
Set by
Default
0
above
Above canopy conditions
above_ground_canopy_offset
+2 m
1
canopy
Height of first canopy layer
PlantsModel
–
…
canopy
Height of other canopy layers
PlantsModel
–
10
canopy
Height of the last canopy layer
PlantsModel
–
11
subcanopy
Subcanopy height
subcanopy_layer_height
1.5 m
12
surface
Near surface conditions
surface_layer_height
0.1 m
13
soil
Upper soil layer depth
soil_layers
-0.25 m
14
soil
Lower soil layer depth
soil_layers
-1.25 m
- Raises:
ConfigurationError – If the configuration elements are incorrect for defining the model timing.
Methods:
__post_init__
(config)Populate the
LayerStructure
instance.Attributes:
The height above the canopy of the provided reference climate variables.
The maximum number of canopy layers.
A validated model configuration.
An tuple of the roles of the vertical layers within the model from top to bottom.
The total number of vertical layers in the model.
A list of the depths of soil layer boundaries.
The height above ground used to represent subcanopy conditions.
The height above ground used to represent surface conditions.
- __post_init__(config: Config) None
Populate the
LayerStructure
instance.This method populates the
LayerStructure
attributes from the providedConfig
instance.- Parameters:
config – A Config instance.
- above_canopy_height_offset: float
The height above the canopy of the provided reference climate variables.
- class virtual_ecosystem.core.core_components.ModelTiming(config: InitVar[Config])
Model timing details.
This data class defines the timing of a Virtual Ecosystem simulation from the
core.timing
section of a validated model configuration. The start time, run length and update interval are all extracted from the configuration and validated.The end time is calculated from the previously extracted timing information. This end time will always be the largest whole multiple of the update interval that exceeds or equal the configured
run_length
.- Raises:
ConfigurationError – If the timing configuration details are incorrect.
Methods:
__post_init__
(config)Populate the
ModelTiming
instance.Attributes:
A validated model configuration.
The calculated end time of the simulation.
The total number of model updates in the configured run.
The difference between start and calculated end time.
The configured run length.
The configured run length as a pint Quantity.
The start time of the simulation.
The configured update interval.
The configured update interval as a pint Quantity.
- __post_init__(config: Config) None
Populate the
ModelTiming
instance.This method populates the
ModelTiming
attributes from the providedConfig
instance.- Parameters:
config – A Config instance.
- end_time: np.datetime64
The calculated end time of the simulation.
- reconciled_run_length: np.timedelta64
The difference between start and calculated end time.
- run_length: np.timedelta64
The configured run length.
- run_length_quantity: Quantity
The configured run length as a pint Quantity.
- start_time: np.datetime64
The start time of the simulation.
- update_interval: np.timedelta64
The configured update interval.
- update_interval_quantity: Quantity
The configured update interval as a pint Quantity.