Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ def dummy_litter_data(fixture_core_components):
"root_lignin": [0.2, 0.35, 0.27, 0.4],
"plant_reproductive_tissue_turnover_c_n_ratio": [12.5, 23.8, 15.7, 18.2],
"plant_reproductive_tissue_turnover_c_p_ratio": [125.5, 105.0, 145.0, 189.2],
"root_turnover_c_p_ratio": [656.7, 450.6, 437.3, 371.9],
"litter_consumption_above_metabolic": [0.019785, 0.011631, 0.016129, 0.023456],
"litter_consumption_above_structural": [0.02097, 0.01609, 0.01019, 0.00988],
"litter_consumption_woody": [0.4773833, 0.385701, 0.373456, 0.162192],
Expand Down
26 changes: 0 additions & 26 deletions tests/models/plants/test_plants_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,32 +406,6 @@ def test_PlantsModel_calculate_turnover(fxt_plants_model):
consts.plant_reproductive_tissue_lignin,
)
assert np.allclose(fxt_plants_model.data["root_lignin"], consts.root_lignin)
assert np.allclose(fxt_plants_model.data["leaf_lignin"], consts.leaf_lignin)


def test_PlantsModel_calculate_turnover_constant_override(
plants_data, fixture_configuration, fixture_core_components
):
"""Test that the turnover constants can be overridden by values in config.

TODO - not sure what this actually tests?
"""

from virtual_ecosystem.models.plants.plants_model import PlantsModel

# Force setting of new value on frozen pydantic configuration class.
fixture_configuration.plants.constants.__dict__["leaf_lignin"] = 100.0

plants_model = PlantsModel.from_config(
data=plants_data,
configuration=fixture_configuration,
core_components=fixture_core_components,
)

plants_model.reset_update_vars()
plants_model.calculate_turnover()

assert np.allclose(plants_model.data["leaf_lignin"], 100.0)


def test_PlantsModel_calculate_nutrient_uptake(fxt_plants_model):
Expand Down
35 changes: 19 additions & 16 deletions tests/models/soil/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ def dummy_carbon_data(fixture_core_components):
"animal_ectomycorrhiza_consumption": [9.52e-4, 3.84e-4, 3.77e-4, 9.43e-4],
"animal_arbuscular_mycorrhiza_consumption": [3.43e-4, 4.29e-4, 6.0e-4, 2.30e-4],
"decay_of_fungal_fruiting_bodies": [2.2499e-4, 5.8168e-4, 3.2185e-4, 2.5871e-3],
"new_fungal_fruiting_body_production": [0.0, 0.0, 0.0, 0.0],
"new_amf_n_supply": [0.0, 0.0, 0.0, 0.0],
"new_amf_p_supply": [0.0, 0.0, 0.0, 0.0],
"new_emf_n_supply": [0.0, 0.0, 0.0, 0.0],
"new_emf_p_supply": [0.0, 0.0, 0.0, 0.0],
}

for var_name, var_values in data_values.items():
Expand Down Expand Up @@ -239,18 +234,26 @@ def soil_pool_data(dummy_carbon_data):
from virtual_ecosystem.models.soil.pools import PoolData
from virtual_ecosystem.models.soil.soil_model import SoilModel

# As well as the values stored in the data object, the temporary arrays should be
# added to the pool data
refreshed_variables = [
"new_fungal_fruiting_body_production",
"new_amf_n_supply",
"new_amf_p_supply",
"new_emf_n_supply",
"new_emf_p_supply",
]

pools = {
var: pool
for var, pool in dummy_carbon_data.data.items()
if var in SoilModel.vars_updated
or var
in [
"new_fungal_fruiting_body_production",
"new_amf_n_supply",
"new_amf_p_supply",
"new_emf_n_supply",
"new_emf_p_supply",
]
**{
var: pool
for var, pool in dummy_carbon_data.data.items()
if var in SoilModel.vars_updated
},
**{
name: np.zeros_like(dummy_carbon_data["soil_c_pool_lmwc"])
for name in refreshed_variables
},
}

return PoolData(**pools)
Expand Down
6 changes: 3 additions & 3 deletions tests/models/soil/test_soil_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def test_update(mocker, fixture_soil_model, dummy_carbon_data):
# Set of pools to be returned to test that update does use (mocked) integrator
end_lmwc = [0.04980117, 0.01999411, 0.09992829, 0.00499986]
end_maom = [2.50019883, 1.70000589, 4.50007171, 0.50000014]
end_microbe = [5.8, 2.3, 11.3, 1.0]
end_bacteria = [5.8, 2.3, 11.3, 1.0]
end_pom = [0.25, 2.34, 0.746, 0.3467]
end_necromass = [0.058, 0.015, 0.093, 0.105]

Expand Down Expand Up @@ -334,7 +334,7 @@ def test_update(mocker, fixture_soil_model, dummy_carbon_data):
data_vars=dict(
soil_c_pool_lmwc=DataArray(end_lmwc, dims="cell_id"),
soil_c_pool_maom=DataArray(end_maom, dims="cell_id"),
soil_c_pool_microbe=DataArray(end_microbe, dims="cell_id"),
soil_c_pool_bacteria=DataArray(end_bacteria, dims="cell_id"),
soil_c_pool_pom=DataArray(end_pom, dims="cell_id"),
soil_c_pool_necromass=DataArray(end_necromass, dims="cell_id"),
soil_n_pool_nitrate=DataArray(end_nitrate, dims="cell_id"),
Expand All @@ -358,7 +358,7 @@ def test_update(mocker, fixture_soil_model, dummy_carbon_data):
# Check that data fixture has been updated correctly
assert np.allclose(dummy_carbon_data["soil_c_pool_lmwc"], end_lmwc)
assert np.allclose(dummy_carbon_data["soil_c_pool_maom"], end_maom)
assert np.allclose(dummy_carbon_data["soil_c_pool_microbe"], end_microbe)
assert np.allclose(dummy_carbon_data["soil_c_pool_bacteria"], end_bacteria)
assert np.allclose(dummy_carbon_data["soil_c_pool_pom"], end_pom)
assert np.allclose(dummy_carbon_data["soil_c_pool_necromass"], end_necromass)

Expand Down
63 changes: 0 additions & 63 deletions virtual_ecosystem/data_variables.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1408,69 +1408,6 @@ name = "canopy_non_propagule_c_mass"
unit = "NEEDS UNIT"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "NEEDS DESCRIPTION"
name = "leaf_lignin"
unit = "NEEDS UNIT"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "NEEDS DESCRIPTION"
name = "nitrogen_fixation_carbon_supply"
unit = "NEEDS UNIT"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "NEEDS DESCRIPTION"
name = "new_fungal_fruiting_body_production"
unit = "NEEDS UNIT"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "NEEDS DESCRIPTION"
name = "new_amf_n_supply"
unit = "NEEDS UNIT"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "NEEDS DESCRIPTION"
name = "new_amf_p_supply"
unit = "NEEDS UNIT"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "NEEDS DESCRIPTION"
name = "new_emf_n_supply"
unit = "NEEDS UNIT"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "NEEDS DESCRIPTION"
name = "new_emf_p_supply"
unit = "NEEDS UNIT"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "NEEDS DESCRIPTION"
name = "soil_c_pool_microbe"
unit = "NEEDS UNIT"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "NEEDS DESCRIPTION"
name = "root_turnover_c_p_ratio"
unit = "NEEDS UNIT"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "NEEDS DESCRIPTION"
Expand Down
3 changes: 0 additions & 3 deletions virtual_ecosystem/models/plants/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class PlantsConstants(Configuration):
senesced_leaf_lignin: float = 0.05
"""Fraction of senesced leaf biomass that is lignin."""

leaf_lignin: float = 0.10
"""Fraction of leaf biomass that is lignin."""

plant_reproductive_tissue_lignin: float = 0.01
"""Fraction of plant reproductive tissue biomass that is lignin."""

Expand Down
8 changes: 0 additions & 8 deletions virtual_ecosystem/models/plants/plants_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ class PlantsModel(
"foliage_turnover_cnp",
"root_turnover_cnp",
"fallen_n_propagules",
"nitrogen_fixation_carbon_supply",
"canopy_n_propagules",
"leaf_lignin",
"canopy_non_propagule_c_mass",
"fallen_non_propagule_c_mass",
"plant_ammonium_uptake",
Expand Down Expand Up @@ -1324,19 +1322,13 @@ def calculate_turnover(self) -> None:
self.data["senesced_leaf_lignin"] = xr.full_like(
self.data["elevation"], self.model_constants.senesced_leaf_lignin
)
self.data["leaf_lignin"] = xr.full_like(
self.data["elevation"], self.model_constants.leaf_lignin
)
self.data["plant_reproductive_tissue_lignin"] = xr.full_like(
self.data["elevation"],
self.model_constants.plant_reproductive_tissue_lignin,
)
self.data["root_lignin"] = xr.full_like(
self.data["elevation"], self.model_constants.root_lignin
)
self.data["nitrogen_fixation_carbon_supply"] = xr.full_like(
self.data["elevation"], 0.01
)

def calculate_nutrient_uptake(self) -> None:
"""Calculate uptake of soil nutrients by the plant community.
Expand Down