Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f490241
Update pyrealm version
sallymatson Apr 1, 2025
58dd552
Change pyrealm reference to 2.0.0rc2.
sallymatson Apr 1, 2025
22d7a04
Merge branch 'develop' into 750-new-branch-fruit-production
sallymatson Apr 1, 2025
0e2d3fa
Add plant reproductive tissue and gpp topslice integration.
sallymatson Apr 1, 2025
04b42af
Merge pull request #812 from ImperialCollegeLondon/750-new-new-incorp…
sallymatson Apr 1, 2025
69f1251
Split up plant RT turnover into propagule and non-propagule.
sallymatson Apr 1, 2025
517b0c2
Merge pull request #813 from ImperialCollegeLondon/750-new-new-incorp…
sallymatson Apr 1, 2025
e685ef2
Add variables to registry.
sallymatson Apr 1, 2025
ca5f562
Merge branch '750-new-new-incorporate-pyrealm-update' into 750-new-br…
sallymatson Apr 1, 2025
fc157a4
Bug fixes, and changed propagule mass to number of props
sallymatson Apr 3, 2025
954decd
Rename canopy_non_propagule_c_mass for consistency.
sallymatson Apr 3, 2025
525d0f0
Add test for partition_reproductive_tissue
sallymatson Apr 3, 2025
9b5fcaa
Fix docs build error.
sallymatson Apr 3, 2025
f5d0fd8
Add one assertion to partition test, and add todo for storing props b…
sallymatson Apr 3, 2025
3bb02d5
Updating turnover rates in _setup, first draft at splitting propagule…
davidorme Apr 7, 2025
3c83d32
Problem with frozen Flora - update rate rescaling, resizing canopy re…
davidorme Apr 7, 2025
9517512
Scaling up from stems to cohorts, allocating canopy reproductive tiss…
davidorme Apr 7, 2025
9147f49
Typo on non-propagule mass
davidorme Apr 7, 2025
ed679ab
Fixing incorrect yield, fixing tests
davidorme Apr 7, 2025
98da0cc
Refactor of reproductive tissue allocation
davidorme Apr 8, 2025
91c534f
Merge pull request #822 from ImperialCollegeLondon/750-dividing-pft-p…
davidorme Apr 8, 2025
12f1b12
Merge branch 'develop' into 750-new-branch-fruit-production
sallymatson Apr 8, 2025
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,337 changes: 768 additions & 569 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ netcdf4 = "^1.6.5"
numpy = "~2.1" # Pinning numpy less than 2.2.0 until this resolves: https://github.com/numpy/numpy/issues/27957
openpyxl = "^3.1.5"
pint = "^0.24.1"
pyrealm = {version = "^2.0.0rc1", allow-prereleases = true}
pyrealm = {version = "^2.0.0rc2", allow-prereleases = true}
python = ">=3.10,<3.14"
scipy = "^1.9.0"
tomli = {version = "^2.0.1", python = "<3.11"}
Expand Down
12 changes: 10 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,16 @@ def fixture_config(microbial_groups_cfg):
resp_f = 0.1
resp_r = 0.913
resp_s = 0.044
resp_rt = 0.05
rho_s = 200.0
sla = 14.0
tau_f = 4.0
tau_r = 1.04
yld = 0.17
tau_rt = 1
yld = 0.6
zeta = 0.17
gpp_topslice = 0.1
p_foliage_for_reproductive_tissue = 0.05

[[plants.pft_definition]]
a_hd = 116.0
Expand All @@ -237,12 +241,16 @@ def fixture_config(microbial_groups_cfg):
resp_f = 0.1
resp_r = 0.913
resp_s = 0.044
resp_rt = 0.05
rho_s = 200.0
sla = 14.0
tau_f = 4.0
tau_r = 1.04
yld = 0.17
tau_rt = 1
yld = 0.6
zeta = 0.17
gpp_topslice = 0.1
p_foliage_for_reproductive_tissue = 0.05

[[animal.functional_groups]]
name = "carnivorous_bird"
Expand Down
8 changes: 8 additions & 0 deletions tests/core/data/all_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ tau_f = 4.0
tau_r = 1.04
yld = 0.17
zeta = 0.17
resp_rt = 0.05
tau_rt = 1
gpp_topslice = 0.1
p_foliage_for_reproductive_tissue = 0.05

[[plants.pft_definition]]
a_hd = 116.0
Expand All @@ -58,6 +62,10 @@ tau_f = 4.0
tau_r = 1.04
yld = 0.17
zeta = 0.17
resp_rt = 0.05
tau_rt = 1
gpp_topslice = 0.1
p_foliage_for_reproductive_tissue = 0.05

[[animal.functional_groups]]
name = "carnivorous_bird"
Expand Down
8 changes: 8 additions & 0 deletions tests/models/animals/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ def animal_fixture_config():
tau_r = 1.04
yld = 0.17
zeta = 0.17
resp_rt = 0.05
tau_rt = 1
gpp_topslice = 0.1
p_foliage_for_reproductive_tissue = 0.05

[[plants.pft_definition]]
a_hd = 116.0
Expand All @@ -147,6 +151,10 @@ def animal_fixture_config():
tau_r = 1.04
yld = 0.17
zeta = 0.17
resp_rt = 0.05
tau_rt = 1
gpp_topslice = 0.1
p_foliage_for_reproductive_tissue = 0.05

[[animal.functional_groups]]
name = "carnivorous_bird"
Expand Down
2 changes: 1 addition & 1 deletion tests/models/litter/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def dummy_litter_data(fixture_core_components):
"c_p_ratio_below_structural": [550.5, 595.6, 773.1, 651.2],
"deadwood_production": [0.075, 0.099, 0.063, 0.033],
"leaf_turnover": [0.027, 0.0003, 0.021, 0.0285],
"plant_reproductive_tissue_turnover": [0.003, 0.0075, 0.00255, 0.00375],
"fallen_non_propagule_c_mass": [0.003, 0.0075, 0.00255, 0.00375],
"root_turnover": [0.027, 0.021, 0.0003, 0.0249],
"stem_lignin": [0.233, 0.545, 0.612, 0.378],
"senesced_leaf_lignin": [0.05, 0.25, 0.3, 0.57],
Expand Down
6 changes: 3 additions & 3 deletions tests/models/plants/data/pfts.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name,a_hd,ca_ratio,h_max,lai,par_ext,resp_f,resp_r,resp_s,rho_s,sla,tau_f,tau_r,yld,zeta,f_g,m,n
test1,116.0,390.43,25.33,1.8,0.5,0.1,0.913,0.044,200.0,14.0,4.0,1.04,0.17,0.17,0.02,2,5
test2,116.0,390.43,15.33,1.8,0.5,0.1,0.913,0.044,200.0,14.0,4.0,1.04,0.17,0.17,0.02,2,5
name,a_hd,ca_ratio,h_max,lai,par_ext,resp_f,resp_r,resp_s,rho_s,sla,tau_f,tau_r,yld,zeta,f_g,m,n,tau_rt,resp_rt,gpp_topslice,p_foliage_for_reproductive_tissue
test1,116.0,390.43,25.33,1.8,0.5,0.1,0.913,0.044,200.0,14.0,4.0,1.04,0.17,0.17,0.02,2,5,1,0.05,0.1,0.05
test2,116.0,390.43,15.33,1.8,0.5,0.1,0.913,0.044,200.0,14.0,4.0,1.04,0.17,0.17,0.02,2,5,1,0.05,0.1,0.05
26 changes: 23 additions & 3 deletions tests/models/plants/test_plants_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ def test_PlantsModel_allocate_gpp(fxt_plants_model, fixture_core_components):
# Ensure that leaf and root turnover exist and are > 0
assert fxt_plants_model.data["leaf_turnover"][cell_id] > 0
assert fxt_plants_model.data["root_turnover"][cell_id] > 0
assert np.all(fxt_plants_model.data["fallen_n_propagules"][cell_id] >= 0)
assert fxt_plants_model.data["fallen_non_propagule_c_mass"][cell_id] > 0
assert np.all(fxt_plants_model.data["canopy_n_propagules"][cell_id] >= 0)
assert np.all(
fxt_plants_model.data["canopy_non_propagule_c_mass"][cell_id] >= 0
) # For cell_id = 1, only one of the two PFTs is present.
assert fxt_plants_model.data["root_carbohydrate_exudation"][cell_id] > 0
assert fxt_plants_model.data["plant_symbiote_carbon_supply"][cell_id] > 0


def test_PlantsModel_update(
Expand Down Expand Up @@ -228,9 +236,6 @@ def test_PlantsModel_calculate_turnover(fxt_plants_model, fixture_config):
consts = fxt_plants_model.model_constants

# Check that all expected variables are generated and have the correct value
assert np.allclose(
fxt_plants_model.data["plant_reproductive_tissue_turnover"], 0.003
)
assert np.allclose(fxt_plants_model.data["stem_lignin"], consts.stem_lignin)
assert np.allclose(
fxt_plants_model.data["senesced_leaf_lignin"], consts.senesced_leaf_lignin
Expand Down Expand Up @@ -322,3 +327,18 @@ def test_PlantsModel_apply_mortality(fxt_plants_model):
>= fxt_plants_model.communities[cell_id].cohorts.n_individuals
)
assert fxt_plants_model.data["deadwood_production"][cell_id] == deadwood_mass


def test_partition_reproductive_tissue(fxt_plants_model):
"""Tests the partition reproductive tissue function."""

n_propagules, mass_non_propagules = fxt_plants_model.partition_reproductive_tissue(
reproductive_tissue_mass=10.5
)

assert n_propagules == 5
assert mass_non_propagules == 5.5
assert (
n_propagules * fxt_plants_model.model_constants.carbon_mass_per_propagule
+ mass_non_propagules
)
4 changes: 2 additions & 2 deletions virtual_ecosystem/data_variables.toml
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,8 @@ variable_type = "float"

[[variable]]
axis = ["spatial"]
description = "Plant reproductive tissue (fruits and flowers) turnover since last update"
name = "plant_reproductive_tissue_turnover"
description = "Plant reproductive tissue non-propagule turnover since last update"
name = "fallen_non_propagule_c_mass"
unit = "kg C m^-2"
variable_type = "float"

Expand Down
6 changes: 3 additions & 3 deletions virtual_ecosystem/example_data/data/plant_pfts.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name,a_hd,ca_ratio,h_max,lai,par_ext,resp_f,resp_r,resp_s,rho_s,sla,tau_f,tau_r,yld,zeta,f_g,m,n
broadleaf,116.0,390.43,25.33,1.8,0.5,0.1,0.913,0.044,200.0,14.0,4.0,1.04,0.17,0.17,0.02,2,5
shrub,116.0,390.43,15.33,1.8,0.5,0.1,0.913,0.044,200.0,14.0,4.0,1.04,0.17,0.17,0.02,2,5
name,a_hd,ca_ratio,h_max,lai,par_ext,resp_f,resp_r,resp_s,rho_s,sla,tau_f,tau_r,yld,zeta,f_g,m,n,tau_rt,resp_rt,gpp_topslice,p_foliage_for_reproductive_tissue
broadleaf,116.0,390.43,25.33,1.8,0.5,0.1,0.913,0.044,200.0,14.0,4.0,1.04,0.17,0.17,0.02,2,5,1,0.05,0.1,0.05
shrub,116.0,390.43,15.33,1.8,0.5,0.1,0.913,0.044,200.0,14.0,4.0,1.04,0.17,0.17,0.02,2,5,1,0.05,0.1,0.05
2 changes: 1 addition & 1 deletion virtual_ecosystem/models/litter/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def combine_input_sources(data: Data) -> dict[str, NDArray[np.float32]]:
).to_numpy()
root_total = data["root_turnover"]
deadwood_total = data["deadwood_production"]
reprod_total = data["plant_reproductive_tissue_turnover"]
reprod_total = data["fallen_non_propagule_c_mass"]

# Calculate lignin concentrations for each combined pool
leaf_lignin = merge_input_chemical_proportions(
Expand Down
2 changes: 1 addition & 1 deletion virtual_ecosystem/models/litter/litter_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class LitterModel(
"c_p_ratio_below_structural",
"deadwood_production",
"leaf_turnover",
"plant_reproductive_tissue_turnover",
"fallen_non_propagule_c_mass",
"root_turnover",
"stem_lignin",
"senesced_leaf_lignin",
Expand Down
9 changes: 9 additions & 0 deletions virtual_ecosystem/models/plants/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ class PlantsConsts(ConstantsDataclass):

root_turnover_c_p_ratio: float = 656.7
"""Carbon to Phosphorous ratio of root turnover."""

root_exudates: float = 0.5
"""Fraction of GPP topslice allocated to root exudates."""

propagule_mass_portion: float = 0.5
"""Fraction of reprodutive tissue allocated to propagules."""

carbon_mass_per_propagule: float = 1
"""Mass of carbon per propagule in g."""
16 changes: 15 additions & 1 deletion virtual_ecosystem/models/plants/module_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"resp_r": {
"type": "number"
},
"resp_rt": {
"type": "number"
},
"resp_s": {
"type": "number"
},
Expand All @@ -62,6 +65,9 @@
"tau_r": {
"type": "number"
},
"tau_rt": {
"type": "number"
},
"yld": {
"type": "number"
},
Expand All @@ -76,6 +82,12 @@
},
"n": {
"type": "number"
},
"gpp_topslice": {
"type": "number"
},
"p_foliage_for_reproductive_tissue": {
"type": "number"
}
},
"required": [
Expand All @@ -96,7 +108,9 @@
"zeta",
"f_g",
"m",
"n"
"n",
"gpp_topslice",
"p_foliage_for_reproductive_tissue"
]
}
},
Expand Down
Loading