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: 1 addition & 0 deletions tests/models/plants/test_plants_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def test_PlantsModel_estimate_gpp(fxt_plants_model):
fxt_plants_model.set_shortwave_absorption()

# Calculate GPP
fxt_plants_model.reset_update_vars()
fxt_plants_model.calculate_light_use_efficiency()
fxt_plants_model.estimate_gpp(time_index=0)

Expand Down
2 changes: 2 additions & 0 deletions tests/models/plants/test_subcanopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def test_subcanopy_vegetation_dynamics(
plants_data["shortwave_absorption"] = template.copy()
plants_data["leaf_area_index"] = template.copy()
plants_data["layer_fapar"] = template.copy()
plants_data["transpiration"] = template.copy()

subcanopy = Subcanopy(
data=plants_data,
Expand All @@ -186,6 +187,7 @@ def test_subcanopy_vegetation_dynamics(

# Set the subcanopy shortwave absorption - don't need finesse here - either
# vegetation present or not

subcanopy.set_light_capture(below_canopy_light_fraction=np.ones(4))

subcanopy.calculate_dynamics(
Expand Down
11 changes: 2 additions & 9 deletions virtual_ecosystem/data_variables.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "Transpiration from canopy"
description = "Transpiration from the canopy and subcanopy"
name = "transpiration"
unit = "mm"
variable_type = "float"
Expand Down Expand Up @@ -1517,13 +1517,6 @@ name = "subcanopy_phosphorus_uptake"
unit = "kg"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "Transpiration from subcanopy vegetation"
name = "subcanopy_transpiration"
unit = "mm"
variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "C, N, and P masses for stem turnover in a given timestep"
Expand Down Expand Up @@ -1627,4 +1620,4 @@ axis = ["spatial"]
description = "Average C, N, and P masses of each seed in a PFT"
name = "fallen_seeds_cnp"
unit = "kg"
variable_type = "float"
variable_type = "float"
11 changes: 7 additions & 4 deletions virtual_ecosystem/models/plants/plants_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class PlantsModel(
"subcanopy_ammonium_uptake",
"subcanopy_nitrate_uptake",
"subcanopy_phosphorus_uptake",
"subcanopy_transpiration",
),
vars_populated_by_first_update=(
"stem_turnover_cnp",
Expand Down Expand Up @@ -217,7 +216,6 @@ class PlantsModel(
"subcanopy_ammonium_uptake",
"subcanopy_nitrate_uptake",
"subcanopy_phosphorus_uptake",
"subcanopy_transpiration",
),
):
"""Representation of plants in the Virtual Ecosystem.
Expand Down Expand Up @@ -654,6 +652,9 @@ def reset_update_vars(self) -> None:
for var in pft_cnp_vars:
self.data[var] = self.data_object_templates["cnp_pft"].copy()

# Initialise transpiration array to collect per grid cell values
self.data["transpiration"] = self.layer_structure.from_template("transpiration")

def _update(self, time_index: int, **kwargs: Any) -> None:
"""Update the plants model.

Expand Down Expand Up @@ -1006,8 +1007,10 @@ def estimate_gpp(self, time_index: int) -> None:
community.cohorts.n_individuals * per_layer_transpiration_mm
).sum(axis=1)

# Pass values to data object
self.data["transpiration"] = transpiration
# Write canopy layers to transpiration data array
self.data["transpiration"][self.layer_structure.index_filled_canopy] = (
transpiration[self.layer_structure.index_filled_canopy]
)

def allocate_gpp(self) -> None:
"""Calculate the allocation of GPP to growth and respiration.
Expand Down
6 changes: 4 additions & 2 deletions virtual_ecosystem/models/plants/subcanopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,15 +470,17 @@ def calculate_dynamics(
self.data["cell_id"], self.model_constants.subcanopy_seedbank_lignin
)

# Write nutrient uptakes and transpiration - one m3 is 1000 mm/m2
# Write nutrient uptakes
for name, values in (
("subcanopy_ammonium_uptake", ammonium_uptake_kg),
("subcanopy_nitrate_uptake", nitrate_uptake_kg),
("subcanopy_phosphorus_uptake", phosphorus_uptake_kg),
("subcanopy_transpiration", subcanopy_volume_m3 / 1000),
):
self.data[name] = DataArray(values, coords=coords)

# Write transpiration
self.data["transpiration"][self.layer_index] = subcanopy_volume_m3 / 1000

def set_light_capture(self, below_canopy_light_fraction: NDArray) -> None:
r"""Calculate the leaf area index and absorption of subcanopy vegetation.

Expand Down